You are not logged in.
Sorry in advance for being noobish, or posting in the wrong thread.
Alright Guys.. I'm having trouble here and I'm a little stumped.
I cut a snippet of the file I'm working on. For a Dzen bar.
...
WEATHER(){
Weather=$(Weather 10039)
printf "${BGC}${FG2}${AL}${BG2} ${FGB}${P}NYC Weather, $Weather${PC} "
return
}
...
What it does, Displays weather to my Dzen bar,
Everything else refreshes in 1 second.
But, I want The Weather only to refresh every 30mins or so.
Any Ideas?
The full code, If anyone wants to see.
#!/bin/bash
# Oblivious June 2014
# Dzen Right Side
# Source
. $HOME/Gmnbox/ZenBash/Settings
CPU() {
Temp=$(sensors | awk '/Core0/ {print +$3}')
if [[ "$Temp" -lt "$Cool" ]];
then
printf "${Htop}${BG1}${FG0}${AL}${BG0} ${HTC1}${HT}${CC} "
elif
[[ "$Temp" -le "$Warm" ]];
then
printf "${Htop}${BG1}${FG0}${AL}${BG0} ${HTC2}${HT}${CC} "
else
printf "${Htop}${BG1}${FG0}${AL}${BG0} ${HTC3}${HT}${CC} "
fi
return
}
HOST() {
Username=$(printf "$USER" | sed -e "s/\b\(.\)/\u\1/g")
printf "${BG2}${FG1}${AL}${BG1} ${FGA}${P}${Username}${PC} "
return
}
WEATHER(){
Weather=$(Weather 10039)
printf "${BGC}${FG2}${AL}${BG2} ${FGB}${P}NYC Weather, $Weather${PC} "
return
}
EDIT() {
printf "${EditB} ${CC}${CC}"
return
}
while true
do
sleep 1
echo "$(EDIT)$(WEATHER)$(HOST)$(CPU)"
done | dzen2 -dock -x ${WB} -w ${WB} -h ${HB} -fn ${FN} -bg ${BG} -ta r -p
# End of File
Last edited by ObliviousGmn (2014-06-18 21:22:00)
- The Github -
Offline
Change the while loop:
loops=0
while true; do
[[ loops -eq 1800 ]] && loops=0
[[ loops -eq 0 ]] && W=$(WEATHER)
loops=$(( loops + 1 ))
echo "$(EDIT)$W$(HOST)$(CPU)"
sleep 1
done | dzen ...
Last edited by Trilby (2014-06-18 20:32:08)
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
You could have a separate script to call your weather program every 30 minutes and have weather direct output to a temporary file. In your 1 second refresh script just 'cat' the temporary file.
Offline
You could have a separate script to call your weather program every 30 minutes and have weather direct output to a temporary file. In your 1 second refresh script just 'cat' the temporary file.
This is exactly what shaman is for...
Offline
Offline