determine a display used by gnome-session

Jeff Hanson jhansonxi at gmail.com
Sat Dec 31 15:08:00 UTC 2011


On Sat, Dec 31, 2011 at 9:51 AM, Jeff Hanson <jhansonxi at gmail.com> wrote:
> I suggest using notify-send as root to send the message unless you
> need to check some kind of response from the user.

Here is a bit of code I use:
for xttypid in $(ps a o pid= o tty= | sed -n
's/^\([[:space:]]*\)\([[:digit:]]\+\)\([[:space:]]tty[[:digit:]]\+\)$/\2/p');
do
    export DISPLAY=$(sed -n
's/\(.*[^[:alpha:]]*DISPLAY=\+\)\(:[[:digit:]]\+\)\(.*\)/\2/p'
/proc/$xttypid/environ)
    /usr/bin/notify-send \
    --urgency="$1" \
    --category="$2" \
    --icon="$3" \
    --expire-time="$4" \
    "$5" "$6" 2>/dev/null
done




More information about the Ubuntu-devel-discuss mailing list