You are not logged in.
Pages: 1
First off, I'm completely new to bash scripting so forgive me if I make any egregious errors. I'm trying to make pop-up reminders for the simple calendar program when. This is what I have so far:
#!/bin/bash
# set the time format for when
#current="$(date +%I:%M\ %p)"
current="$(date +%-l%p)"
today=~/.when/today
# create file for today
when --past=0 --future=1 > $today
# call gxmessage
function when_remind {
gxmessage -center -timeout 900 -name Reminders "$(grep $current $today)"
}
while read line ; do
time=${line##*, }
if [ "$time" = "$current" ] ; then
when_remind
fi
done < $today
The file "~/.when/today" has appointment schedules arranged like so:
2010 feb 20, test, 10PM
2010 feb 20, test2, 10PM
2010 feb 20, test3, 10PM
When I run the script, gxmessage pops up and displays the correct information, but it does so for each line in "~/.when/today" that contains a time that matches the current system time (which would be three pop-ups at 10PM, according to the example). I want it to display the information only once. How can this be accomplished? Is a while loop even the right job for this?
Last edited by supulton (2010-02-21 08:36:46)
Offline
In case anybody will use this script, I figured out (with help) what was wrong; while was not the right tool for the job. Here's the updated script:
#!/bin/bash
# set the time format for when
#current="$(date +%I:%M\ %p)"
current="$(date +%-l%p)"
today=~/.when/today
reminders="$(grep $current $today)"
# create file for today
when --past=0 --future=1 > $today
# call gxmessage
function when_remind {
gxmessage -center -timeout 900 -name Reminders "$reminders"
}
[ "$reminders" ] && when_remind || gxmessage -center -timeout 5 -name Empty "No reminders today."
Last edited by supulton (2010-02-21 08:36:27)
Offline
Pages: 1