Skip to main content
replaced http://unix.stackexchange.com/ with https://unix.stackexchange.com/
Source Link

I am using Arch Linux with KDE/Awesome WM. I am trying to get notify-send to work with cron.

I have tried setting DISPLAY/XAUTHORITY variables, and running notify-send with "sudo -u", all without result.

I am able to call notify-send interactively from the session and get notifications.

FWIW, the cron job is running fine which I verified by echoing stuff to a temporary file. It is just the "notify-send" that fails to work.

Code:

[matrix@morpheus ~]$ crontab -l
* * * * *  /home/matrix/scripts/notify.sh

[matrix@morpheus ~]$ cat /home/matrix/scripts/notify.sh
#!/bin/bash
export DISPLAY=127.0.0.1:0.0
export XAUTHORITY=/home/matrix/.Xauthority
echo "testing cron" >/tmp/crontest
sudo -u matrix /usr/bin/notify-send "hello"
echo "now tested notify-send" >>/tmp/crontest

[matrix@morpheus ~]$ cat /tmp/crontest
testing cron
now tested notify-send

[matrix@morpheus ~]$ 

As you can see the echo before & after notify-send worked.
Also I have tried setting DISPLAY=:0.0

UPDATE: I searched a bit more and found that DBUS_SESSION_BUS_ADDRESSfound that DBUS_SESSION_BUS_ADDRESS needs to be set. And after hardcoding this using the value I got from my interactive session, the tiny little "hello" message started popping up on the screen every minute!

But the catch is this variable is not permanent per that post, so I'll have try the the named pipe solution suggested there.

[matrix@morpheus ~]$ cat scripts/notify.sh
#!/bin/bash
export DISPLAY=127.0.0.1:0.0
export XAUTHORITY=/home/matrix/.Xauthority
export DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-BouFPQKgqg,guid=64b483d7678f2196e780849752e67d3c
echo "testing cron" >/tmp/crontest
/usr/bin/notify-send "hello"
echo "now tested notify-send" >>/tmp/crontest

Since cron doesn't seem to support notify-send (at least not directly) is there some other notification system that is more cron friendly that I can use?

I am using Arch Linux with KDE/Awesome WM. I am trying to get notify-send to work with cron.

I have tried setting DISPLAY/XAUTHORITY variables, and running notify-send with "sudo -u", all without result.

I am able to call notify-send interactively from the session and get notifications.

FWIW, the cron job is running fine which I verified by echoing stuff to a temporary file. It is just the "notify-send" that fails to work.

Code:

[matrix@morpheus ~]$ crontab -l
* * * * *  /home/matrix/scripts/notify.sh

[matrix@morpheus ~]$ cat /home/matrix/scripts/notify.sh
#!/bin/bash
export DISPLAY=127.0.0.1:0.0
export XAUTHORITY=/home/matrix/.Xauthority
echo "testing cron" >/tmp/crontest
sudo -u matrix /usr/bin/notify-send "hello"
echo "now tested notify-send" >>/tmp/crontest

[matrix@morpheus ~]$ cat /tmp/crontest
testing cron
now tested notify-send

[matrix@morpheus ~]$ 

As you can see the echo before & after notify-send worked.
Also I have tried setting DISPLAY=:0.0

UPDATE: I searched a bit more and found that DBUS_SESSION_BUS_ADDRESS needs to be set. And after hardcoding this using the value I got from my interactive session, the tiny little "hello" message started popping up on the screen every minute!

But the catch is this variable is not permanent per that post, so I'll have try the the named pipe solution suggested there.

[matrix@morpheus ~]$ cat scripts/notify.sh
#!/bin/bash
export DISPLAY=127.0.0.1:0.0
export XAUTHORITY=/home/matrix/.Xauthority
export DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-BouFPQKgqg,guid=64b483d7678f2196e780849752e67d3c
echo "testing cron" >/tmp/crontest
/usr/bin/notify-send "hello"
echo "now tested notify-send" >>/tmp/crontest

Since cron doesn't seem to support notify-send (at least not directly) is there some other notification system that is more cron friendly that I can use?

I am using Arch Linux with KDE/Awesome WM. I am trying to get notify-send to work with cron.

I have tried setting DISPLAY/XAUTHORITY variables, and running notify-send with "sudo -u", all without result.

I am able to call notify-send interactively from the session and get notifications.

FWIW, the cron job is running fine which I verified by echoing stuff to a temporary file. It is just the "notify-send" that fails to work.

Code:

[matrix@morpheus ~]$ crontab -l
* * * * *  /home/matrix/scripts/notify.sh

[matrix@morpheus ~]$ cat /home/matrix/scripts/notify.sh
#!/bin/bash
export DISPLAY=127.0.0.1:0.0
export XAUTHORITY=/home/matrix/.Xauthority
echo "testing cron" >/tmp/crontest
sudo -u matrix /usr/bin/notify-send "hello"
echo "now tested notify-send" >>/tmp/crontest

[matrix@morpheus ~]$ cat /tmp/crontest
testing cron
now tested notify-send

[matrix@morpheus ~]$ 

As you can see the echo before & after notify-send worked.
Also I have tried setting DISPLAY=:0.0

UPDATE: I searched a bit more and found that DBUS_SESSION_BUS_ADDRESS needs to be set. And after hardcoding this using the value I got from my interactive session, the tiny little "hello" message started popping up on the screen every minute!

But the catch is this variable is not permanent per that post, so I'll have try the the named pipe solution suggested there.

[matrix@morpheus ~]$ cat scripts/notify.sh
#!/bin/bash
export DISPLAY=127.0.0.1:0.0
export XAUTHORITY=/home/matrix/.Xauthority
export DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-BouFPQKgqg,guid=64b483d7678f2196e780849752e67d3c
echo "testing cron" >/tmp/crontest
/usr/bin/notify-send "hello"
echo "now tested notify-send" >>/tmp/crontest

Since cron doesn't seem to support notify-send (at least not directly) is there some other notification system that is more cron friendly that I can use?

correct looking
Source Link
Eric Renouf
  • 18.7k
  • 7
  • 51
  • 66

I am using Arch Linux with KDE/Awesome WM. I am trying to get notify-send to work with cron.

I have tried setting DISPLAY/XAUTHORITY variables, and running notify-send with "sudo -u", all without result.

I am able to call notify-send interactively from the session and get notifications.

FWIW, the cron job is running fine which I verified by echoing stuff to a temporary file. It is just the "notify-send" that fails to work.

Code:

[matrix@morpheus ~]$ crontab -l
* * * * *  /home/matrix/scripts/notify.sh

[matrix@morpheus ~]$ cat /home/matrix/scripts/notify.sh
#!/bin/bash
export DISPLAY=127.0.0.1:0.0
export XAUTHORITY=/home/matrix/.Xauthority
echo "testing cron" >/tmp/crontest
sudo -u matrix /usr/bin/notify-send "hello"
echo "now tested notify-send" >>/tmp/crontest

[matrix@morpheus ~]$ cat /tmp/crontest
testing cron
now tested notify-send

[matrix@morpheus ~]$ 

As you can see the echo before & after notify-send worked.
Also I have tried setting DISPLAY=:0.0

UPDATE: I searched a bit more and found that DBUS_SESSION_BUS_ADDRESS needs to be set. And after hardcoding this using the value I got from my interactive session, the tiny little "hello" message started popping up on the screen every minute!

But the catch is this variable is not permanent per that post, so I'll have try the the named pipe solution suggested there.

[matrix@morpheus ~]$ cat scripts/notify.sh
 
#!/bin/bash
 
export DISPLAY=127.0.0.1:0.0
export XAUTHORITY=/home/matrix/.Xauthority
export DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-BouFPQKgqg,guid=64b483d7678f2196e780849752e67d3c
echo "testing cron" >/tmp/crontest
 
/usr/bin/notify-send "hello"
 
echo "now tested notify-send" >>/tmp/crontest

Since cron doesn't seem to support notify-send (at least not directly) is there some other notification system that is more cron friendly that I can use?

I am using Arch Linux with KDE/Awesome WM. I am trying to get notify-send to work with cron.

I have tried setting DISPLAY/XAUTHORITY variables, and running notify-send with "sudo -u", all without result.

I am able to call notify-send interactively from the session and get notifications.

FWIW, the cron job is running fine which I verified by echoing stuff to a temporary file. It is just the "notify-send" that fails to work.

Code:

[matrix@morpheus ~]$ crontab -l
* * * * *  /home/matrix/scripts/notify.sh

[matrix@morpheus ~]$ cat /home/matrix/scripts/notify.sh
#!/bin/bash
export DISPLAY=127.0.0.1:0.0
export XAUTHORITY=/home/matrix/.Xauthority
echo "testing cron" >/tmp/crontest
sudo -u matrix /usr/bin/notify-send "hello"
echo "now tested notify-send" >>/tmp/crontest

[matrix@morpheus ~]$ cat /tmp/crontest
testing cron
now tested notify-send

[matrix@morpheus ~]$ 

As you can see the echo before & after notify-send worked.
Also I have tried setting DISPLAY=:0.0

UPDATE: I searched a bit more and found that DBUS_SESSION_BUS_ADDRESS needs to be set. And after hardcoding this using the value I got from my interactive session, the tiny little "hello" message started popping up on the screen every minute!

But the catch is this variable is not permanent per that post, so I'll have try the the named pipe solution suggested there.

[matrix@morpheus ~]$ cat scripts/notify.sh
 
#!/bin/bash
 
export DISPLAY=127.0.0.1:0.0
export XAUTHORITY=/home/matrix/.Xauthority
export DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-BouFPQKgqg,guid=64b483d7678f2196e780849752e67d3c
echo "testing cron" >/tmp/crontest
 
/usr/bin/notify-send "hello"
 
echo "now tested notify-send" >>/tmp/crontest

Since cron doesn't seem to support notify-send (at least not directly) is there some other notification system that is more cron friendly that I can use?

I am using Arch Linux with KDE/Awesome WM. I am trying to get notify-send to work with cron.

I have tried setting DISPLAY/XAUTHORITY variables, and running notify-send with "sudo -u", all without result.

I am able to call notify-send interactively from the session and get notifications.

FWIW, the cron job is running fine which I verified by echoing stuff to a temporary file. It is just the "notify-send" that fails to work.

Code:

[matrix@morpheus ~]$ crontab -l
* * * * *  /home/matrix/scripts/notify.sh

[matrix@morpheus ~]$ cat /home/matrix/scripts/notify.sh
#!/bin/bash
export DISPLAY=127.0.0.1:0.0
export XAUTHORITY=/home/matrix/.Xauthority
echo "testing cron" >/tmp/crontest
sudo -u matrix /usr/bin/notify-send "hello"
echo "now tested notify-send" >>/tmp/crontest

[matrix@morpheus ~]$ cat /tmp/crontest
testing cron
now tested notify-send

[matrix@morpheus ~]$ 

As you can see the echo before & after notify-send worked.
Also I have tried setting DISPLAY=:0.0

UPDATE: I searched a bit more and found that DBUS_SESSION_BUS_ADDRESS needs to be set. And after hardcoding this using the value I got from my interactive session, the tiny little "hello" message started popping up on the screen every minute!

But the catch is this variable is not permanent per that post, so I'll have try the the named pipe solution suggested there.

[matrix@morpheus ~]$ cat scripts/notify.sh
#!/bin/bash
export DISPLAY=127.0.0.1:0.0
export XAUTHORITY=/home/matrix/.Xauthority
export DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-BouFPQKgqg,guid=64b483d7678f2196e780849752e67d3c
echo "testing cron" >/tmp/crontest
/usr/bin/notify-send "hello"
echo "now tested notify-send" >>/tmp/crontest

Since cron doesn't seem to support notify-send (at least not directly) is there some other notification system that is more cron friendly that I can use?

I am using Arch Linux with KDE/Awesome WM. I am trying to get    notify-send to work with cron. 

I have tried setting DISPLAY/XAUTHORITY variables, and running notify-send with "sudo -u", all without result.

I am able to call notify-send interactively from the session and get notifications. FWIW

FWIW, the cron job is running fine which I verified by echoing stuff to a temporary file. It is just the "notify-send" that fails to work.

Code:

[matrix@morpheus ~]$ crontab -l
* * * * *  /home/matrix/scripts/notify.sh 

[matrix@morpheus ~]$ cat /home/matrix/scripts/notify.sh
#!/bin/bash
export DISPLAY=127.0.0.1:0.0
export XAUTHORITY=/home/matrix/.Xauthority
echo "testing cron" >/tmp/crontest
sudo -u matrix /usr/bin/notify-send "hello"
echo "now tested notify-send" >>/tmp/crontest 

[matrix@morpheus ~]$ cat /tmp/crontest
testing cron
now tested notify-send 

[matrix@morpheus ~]$ 

As you can see the echo before & after notify-send worked. Also
Also I have tried setting DISPLAY=:0.0

UPDATE: I searched a bit more and found that DBUS_SESSION_BUS_ADDRESS needs to be set. And after hardcoding this using the value I got from my interactive session, the tiny little "hello" message started popping up on the screen every minute! 

But the catch is this variable is not permanent per that post, so I'll have try the the named pipe solution suggested there.

[matrix@morpheus ~]$ cat scripts/notify.sh 

#!/bin/bash 

export DISPLAY=127.0.0.1:0.0
export XAUTHORITY=/home/matrix/.Xauthority
export DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-BouFPQKgqg,guid=64b483d7678f2196e780849752e67d3c
echo "testing cron" >/tmp/crontest 

/usr/bin/notify-send "hello" 

echo "now tested notify-send" >>/tmp/crontest
[matrix@morpheus ~]$ 

Since cron doesn't seem to support notify-send (at least not directly) is there some other notification system that is more cron friendly that I can use?

I am using Arch Linux with KDE/Awesome WM. I am trying to get  notify-send to work with cron. I have tried setting DISPLAY/XAUTHORITY variables, and running notify-send with "sudo -u", all without result.

I am able to call notify-send interactively from the session and get notifications. FWIW, the cron job is running fine which I verified by echoing stuff to a temporary file. It is just the "notify-send" that fails to work.

Code:

[matrix@morpheus ~]$ crontab -l
* * * * *  /home/matrix/scripts/notify.sh
[matrix@morpheus ~]$ cat /home/matrix/scripts/notify.sh
#!/bin/bash
export DISPLAY=127.0.0.1:0.0
export XAUTHORITY=/home/matrix/.Xauthority
echo "testing cron" >/tmp/crontest
sudo -u matrix /usr/bin/notify-send "hello"
echo "now tested notify-send" >>/tmp/crontest
[matrix@morpheus ~]$ cat /tmp/crontest
testing cron
now tested notify-send
[matrix@morpheus ~]$ 

As you can see the echo before & after notify-send worked. Also I have tried setting DISPLAY=:0.0

UPDATE: I searched a bit more and found that DBUS_SESSION_BUS_ADDRESS needs to be set. And after hardcoding this using the value I got from my interactive session, the tiny little "hello" message started popping up on the screen every minute! But the catch is this variable is not permanent per that post, so I'll have try the the named pipe solution suggested there.

[matrix@morpheus ~]$ cat scripts/notify.sh
#!/bin/bash
export DISPLAY=127.0.0.1:0.0
export XAUTHORITY=/home/matrix/.Xauthority
export DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-BouFPQKgqg,guid=64b483d7678f2196e780849752e67d3c
echo "testing cron" >/tmp/crontest
/usr/bin/notify-send "hello"
echo "now tested notify-send" >>/tmp/crontest
[matrix@morpheus ~]$ 

Since cron doesn't seem to support notify-send (at least not directly) is there some other notification system that is more cron friendly that I can use?

I am using Arch Linux with KDE/Awesome WM. I am trying to get  notify-send to work with cron. 

I have tried setting DISPLAY/XAUTHORITY variables, and running notify-send with "sudo -u", all without result.

I am able to call notify-send interactively from the session and get notifications.

FWIW, the cron job is running fine which I verified by echoing stuff to a temporary file. It is just the "notify-send" that fails to work.

Code:

[matrix@morpheus ~]$ crontab -l
* * * * *  /home/matrix/scripts/notify.sh 

[matrix@morpheus ~]$ cat /home/matrix/scripts/notify.sh
#!/bin/bash
export DISPLAY=127.0.0.1:0.0
export XAUTHORITY=/home/matrix/.Xauthority
echo "testing cron" >/tmp/crontest
sudo -u matrix /usr/bin/notify-send "hello"
echo "now tested notify-send" >>/tmp/crontest 

[matrix@morpheus ~]$ cat /tmp/crontest
testing cron
now tested notify-send 

[matrix@morpheus ~]$ 

As you can see the echo before & after notify-send worked.
Also I have tried setting DISPLAY=:0.0

UPDATE: I searched a bit more and found that DBUS_SESSION_BUS_ADDRESS needs to be set. And after hardcoding this using the value I got from my interactive session, the tiny little "hello" message started popping up on the screen every minute! 

But the catch is this variable is not permanent per that post, so I'll have try the the named pipe solution suggested there.

[matrix@morpheus ~]$ cat scripts/notify.sh 

#!/bin/bash 

export DISPLAY=127.0.0.1:0.0
export XAUTHORITY=/home/matrix/.Xauthority
export DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-BouFPQKgqg,guid=64b483d7678f2196e780849752e67d3c
echo "testing cron" >/tmp/crontest 

/usr/bin/notify-send "hello" 

echo "now tested notify-send" >>/tmp/crontest

Since cron doesn't seem to support notify-send (at least not directly) is there some other notification system that is more cron friendly that I can use?

edited tags
Link
Braiam
  • 36.9k
  • 29
  • 114
  • 176
Loading
deleted 34 characters in body
Source Link
Timo
  • 6.5k
  • 1
  • 28
  • 30
Loading
cleaned up so far, removed thanks so far, so also corrected some more
Source Link
Loading
Tweeted twitter.com/#!/StackUnix/status/427932095366041600
added 1171 characters in body
Source Link
justsomeone
  • 475
  • 1
  • 4
  • 5
Loading
Source Link
justsomeone
  • 475
  • 1
  • 4
  • 5
Loading