Skip to content

Instantly share code, notes, and snippets.

@andersonfraga
Created May 27, 2016 20:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andersonfraga/34b5048fd1aa0778e60bae223b43448d to your computer and use it in GitHub Desktop.
Save andersonfraga/34b5048fd1aa0778e60bae223b43448d to your computer and use it in GitHub Desktop.
Execute notify-send via cronjob
#!/bin/bash
# * * * * * /bin/sh cronjob.sh "Teste 1 2 3"
{
PID=$(/usr/bin/pgrep gnome-session)
dbus=$(/bin/grep -z DBUS_SESSION_BUS_ADDRESS /proc/$PID/environ|cut -d= -f2-)
export DBUS_SESSION_BUS_ADDRESS=$dbus
DISPLAY=:0.0 /usr/bin/notify-send --urgency=critical "Alert using crontab" "$1"
} >> $HOME/crontab/alert.log 2>&1
@andersonfraga
Copy link
Author

O 'DISPLAY=:0.0' "garante" que funcione sempre. Sem ele, fica inconsistente

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment