Aphoxema
February 17th, 2010, 01:07 AM
As a not-terribly-adept-but-still-well-experienced user, I've been fooling around with some scripts involving the lib-notify executable, notify-send.
Here's my first success...
#!/bin/sh
user=`whoami`
pids=`pgrep -u $user gnome-session`
title="The time is now"
text="`date +"%R on %d, %A %B %Y"`"
timeout=60000
image="/usr/share/pixmaps/gnome-set-time.png"
for pid in $pids; do
# find DBUS session bus for this session
DBUS_SESSION_BUS_ADDRESS=`grep -z DBUS_SESSION_BUS_ADDRESS \
/proc/$pid/environ | sed -e 's/DBUS_SESSION_BUS_ADDRESS=//'`
# use it
DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS \
notify-send -u low -t $timeout "$title" "$text" -i "$image"
done
as a file in /home/user/bin and
*/5 * * * * /home/user/bin/announcetime
In my per-user crontab.
What this does is every 5 minutes a short message telling me (well, any DBUS session) the time and date it currently is. This is useful to me because I'm playing with a minimal desktop and I'm very bad at keeping track of time between classes but any little movement catches my attention.
What's nice about this script (lifted from http://gnome-hacks.org/hacks.html?id=82 ) is you can change $title and $text to any command or string you want.
What else does anyone thing notify-send would be useful for?
Here's my first success...
#!/bin/sh
user=`whoami`
pids=`pgrep -u $user gnome-session`
title="The time is now"
text="`date +"%R on %d, %A %B %Y"`"
timeout=60000
image="/usr/share/pixmaps/gnome-set-time.png"
for pid in $pids; do
# find DBUS session bus for this session
DBUS_SESSION_BUS_ADDRESS=`grep -z DBUS_SESSION_BUS_ADDRESS \
/proc/$pid/environ | sed -e 's/DBUS_SESSION_BUS_ADDRESS=//'`
# use it
DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS \
notify-send -u low -t $timeout "$title" "$text" -i "$image"
done
as a file in /home/user/bin and
*/5 * * * * /home/user/bin/announcetime
In my per-user crontab.
What this does is every 5 minutes a short message telling me (well, any DBUS session) the time and date it currently is. This is useful to me because I'm playing with a minimal desktop and I'm very bad at keeping track of time between classes but any little movement catches my attention.
What's nice about this script (lifted from http://gnome-hacks.org/hacks.html?id=82 ) is you can change $title and $text to any command or string you want.
What else does anyone thing notify-send would be useful for?