You are not logged in.
I am using this script to receive an alarm with some text in x minutes:
#!/bin/sh
text="$2\n\n`date '+%T'`"
(sleep $[$1*60] && (zenity --info --text=$text &) && (aplay /home/m/alarm.wav &)) > /dev/null 2>&1 & disown
In the Zenity window \n is correctly converted to a line break. Great.
Then I have this similar script where \n becomes "n" without a line break:
#!/bin/sh
text="$2\n\n`date '+%T'`"
echo "DISPLAY=:0 zenity --info --text=$text" | at $1 > dev/null 2>&1
echo "aplay /home/m/alarm.wav" | at $1 > /dev/null 2>&1
Invoking the script with the arguments "now" and "hello!" will result in "hello!nn09:16:17".
How can I make it honor \n in this case?
Last edited by Markus00000 (2011-04-20 07:05:53)
Offline
echo "DISPLAY=:0 zenity --info --text=$text" | at $1 > dev/null 2>&1
You need to pass the quotes to 'at' as well:
#!/bin/sh
text="$2\n\n`date '+%T'`"
echo "DISPLAY=:0 zenity --info --text=\"$text\"" | at $1 > dev/null 2>&1
echo "aplay /home/m/alarm.wav" | at $1 > /dev/null 2>&1
A better way to do this (IMHO) is:
#!/bin/sh
text="$2\n\n`date '+%T'`"
at $1 > dev/null 2>&1 <<EOT
aplay /home/m/alarm.wav &
DISPLAY=:0 zenity --info --text="$text"
EOT
Last edited by fukawi2 (2011-04-15 08:58:35)
Are you familiar with our Forum Rules, and How To Ask Questions The Smart Way?
BlueHackers // fscanary // resticctl
Offline
Thanks a lot! Really appreciated.
Note: The notification window will unfortunately display the time when the alarm was scheduled, not the time when the alarm went off.
Last edited by Markus00000 (2011-04-20 07:20:19)
Offline
This will show the timestamp of when the alarm activates, rather than when it was set
#!/bin/sh
text="$2"
at $1 > dev/null 2>&1 <<EOT
aplay /home/m/alarm.wav &
DISPLAY=:0 zenity --info --text="$text\n\n$(date '+%T')"
EOT
Are you familiar with our Forum Rules, and How To Ask Questions The Smart Way?
BlueHackers // fscanary // resticctl
Offline
Excellent, thanks for saving me time and educating me.
Offline