You are not logged in.

#1 2011-10-11 15:30:51

Markus00000
Member
Registered: 2011-03-27
Posts: 333

[SOLVED] Root cronjob and zenity

I created a tiny script to display a notification when package updates are available:

#!/bin/bash
updates=`pacman -Syup | grep "pkg.tar.xz" | wc -l`
if [[ $updates != 0 ]]; then
	DISPLAY=:0 zenity --info --text="Updated packages: $updates"
fi

This works whether run with sudo or from a root terminal.

I made the script a cronjob of root. It is being executed but it does not show any notifications. I tried to run the zenity command using "sudo -u myself ..." but that also did not work.

How can I make it display that notification when run as a cronjob?

Last edited by Markus00000 (2011-10-11 16:57:54)

Offline

#2 2011-10-11 15:47:39

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [SOLVED] Root cronjob and zenity

Have you tried http://promberger.info/linux/2009/01/02 … y-problem/ ?
There's also another script for what you're doing http://bashlnx.blogspot.com/2011/05/hey … rt-ii.html (you can copy just the pacman part and add your zenity stuff)

Offline

#3 2011-10-11 16:57:29

Markus00000
Member
Registered: 2011-03-27
Posts: 333

Re: [SOLVED] Root cronjob and zenity

Excellent help! Thanks a lot.

Offline

#4 2011-11-03 10:58:21

rwd
Member
Registered: 2009-02-08
Posts: 671

Re: [SOLVED] Root cronjob and zenity

I use this for cron-job notifications:

export DISPLAY=:0.0
export XAUTHORITY=/home/myusername/.Xauthority
su myusername -c 'notify-send -t 0 "hello" '

Offline

Board footer

Powered by FluxBB