Notify all users

Yan Seiner yan at seiner.com
Tue Sep 9 09:30:08 PDT 2008


On Tue, September 9, 2008 8:51 am, Bill Crawford wrote:
> On 09/09/2008, Yan Seiner <yan at seiner.com> wrote:
> ...
>> Because most of my users will not have a terminal session open.
>> Typically
>> they use a browser full-screen, so I need a popup to notify them.
>
> Spawn a sub-shell for each user, run "sudo -u $user zenity --warning
> 'about to reboot'" ... ? (it should work, tested here on F8).

Barely tested xwall based on libnotify.  Should work for xfce4 sessions;
change the second line to look for gnome, kde, etc.

#!/bin/sh
pids=`pgrep xfce4-session`
title=$1
text=$2
timeout=$3

echo $pids

if [ -z "$title" ]; then
        echo You need to give me a title >&2
        exit 1
fi
if [ -z "$text" ]; then
        text=$title
fi
if [ -z "$timeout" ]; then
        timeout=60000
fi

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=//'`
        UNAME=`grep -z USERNAME \
                /proc/$pid/environ | sed -e 's/USERNAME=//'`
        DISP=`grep -z DISPLAY \
                /proc/$pid/environ | sed -e 's/DISPLAY=//'`
        XAUTH=`grep -z XAUTHORITY \
                /proc/$pid/environ | sed -e 's/XAUTHORITY=//'`
        echo $UNAME $DBUS_SESSION_BUS_ADDRESS $DISP $XAUTHORITY
        # use it
        DISPLAY=$DISP DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS
XAUTHORITY=$XAUTH \
        sudo -u $UNAME notify-send -u low -t $timeout "$title" "$text"
done

-- 
  o__
  ,>/'_          o__
  (_)\(_)        ,>/'_        o__
Yan Seiner      (_)\(_)       ,>/'_     o__
       Personal Trainer      (_)\(_)    ,>/'_        o__
             Professional Engineer     (_)\(_)       ,>/'_
Who says engineers have to be pencil necked geeks?  (_)\(_)

As long as nobody gets hurt, a decent explosion livens up any experiment.





More information about the xorg mailing list