You are not logged in.

#1 2011-06-08 20:40:37

walterjwhite
Member
Registered: 2011-05-01
Posts: 207

gnome 3 notification on event

Hi all,

I want to create a popup whenever new packages were automatically installed via a script, or a firewall blocked a certain rule, etc.  How do I create custom popups?

Thanks,

Walter

Last edited by walterjwhite (2011-06-10 15:05:28)

Offline

#2 2011-06-08 20:42:50

Inxsible
Forum Fellow
From: Chicago
Registered: 2008-06-09
Posts: 9,183

Re: gnome 3 notification on event

look into zenity


Forum Rules

There's no such thing as a stupid question, but there sure are a lot of inquisitive idiots !

Offline

#3 2011-06-08 22:09:24

walterjwhite
Member
Registered: 2011-05-01
Posts: 207

Re: gnome 3 notification on event

Hi Inxsible,

Thanks for your post - I'll check it out.


Walter

Offline

#4 2011-06-09 01:32:49

walterjwhite
Member
Registered: 2011-05-01
Posts: 207

Re: gnome 3 notification on event

Hi,

I got it working, but I would still like to use the gnome 3 notification-system.  I'll do some more reading into how to get that component working, if you know where to start, let me know.


Walter

Offline

#5 2011-06-09 10:39:09

Wey
Member
Registered: 2011-04-22
Posts: 217

Re: gnome 3 notification on event

in bash you could use notify-send:

notify-send 'Hello, World!'

It comes with libnotify.

edit: it seems using single-quotes solves some problems with special characters.

Last edited by Wey (2011-06-09 12:44:36)

Offline

#6 2011-06-09 11:25:45

walterjwhite
Member
Registered: 2011-05-01
Posts: 207

Re: gnome 3 notification on event

Nice, that is more of what I am looking for.

I can easily specify a title / summary along with a long message body which should be exactly what I need.


Walter

Offline

#7 2011-06-10 15:06:41

walterjwhite
Member
Registered: 2011-05-01
Posts: 207

Re: gnome 3 notification on event

Actually, I did all of my testing as the current user.  When cron runs and calls notify-send or zenity, I get errors trying to raise the notification.  How can I push that information to any and all logged in users?


Thanks,

Walter

Offline

#8 2011-06-10 15:54:03

Wey
Member
Registered: 2011-04-22
Posts: 217

Re: gnome 3 notification on event

Getting a list of logged in users may be a bit tricky depending on your setup. If you are not using startx/xinit from a tty login (which could be obtained with "users") you have to dig in how your display manager keeps track of logins.

To send the message to an actual user, you might have a look at this tutorial, describing how to send notifications from a remote location: http://cweiske.de/tagebuch/DBus%20notif … etwork.htm. It could be transferred to a cron scenario.

It basically boils down to giving sudo NOPASSWD rights for /usr/bin/notify-send on your user(s), exporting a DISPLAY, an XAUTHORITY, and then sudoing notify-send as your targeted user.

export DISPLAY=:0 && export XAUTHORITY=/home/$USER/.Xauthority && sudo -u $USER notify-send 'Test!' 2>&1

I haven't tested it yet though, and it may not be an entirely security sensitive approach (I'm especially thinking of denial of service here).

Offline

#9 2011-06-10 16:17:22

Cdh
Member
Registered: 2009-02-03
Posts: 1,098

Re: gnome 3 notification on event

Why not send to every user running a "notification-daemon"?

for i in $(ps ux | grep notification-daemon | cut -f 1 -d " " | sort | uniq); do sudo -u ${i} notify-send "foobar"; done;

I'm not sure if you need the x authority for doing that:

for i in $(ps ux | grep notification-daemon | cut -f 1 -d " " | sort | uniq); do sudo -u ${i} XAUTHORITY=/home/${i}/.Xauthority notify-send "foobar"; done;

Parsing ps output is not nice, there's probably a better way.

edit: sudo shouldn't need a password since cron is already running as root, right?

Last edited by Cdh (2011-06-10 16:18:19)


฿ 18PRsqbZCrwPUrVnJe1BZvza7bwSDbpxZz

Offline

Board footer

Powered by FluxBB