Skip to content

Instantly share code, notes, and snippets.

@denzuko
Forked from apraga/notify.sh
Last active January 3, 2016 01:49
Show Gist options
  • Select an option

  • Save denzuko/8391682 to your computer and use it in GitHub Desktop.

Select an option

Save denzuko/8391682 to your computer and use it in GitHub Desktop.
#!/bin/bash
# popup a small notification with 'notify-send'
dis=`formail -X From: -X Subject:`
#TODO: replace the following with sed/read
from=`echo "$dis" | formail -X From:`
sub=`echo "$dis" | formail -X Subject:`
# tweaks < > are special
from=${from//</\(}
from=${from//>/\)}
from=${from//&/\.}
sub=${sub//</\(}
sub=${sub//>/\)}
sub=${sub//&/\.}
sub=${sub:0:75}
from=${from:0:75}
TM=2000
pids=`pgrep -u denzuko dbus-launch`
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 \
/usr/bin/notify-send -u normal -t $TM "$sub" "$from"
# TODO: replace with irc-send.sh
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment