Ubuntu notify-send Scheduled Notifications
When using Ubuntu for work or school, you may want to schedule reminders, such as when to drink water or clock out. Using notify-send and crontab makes this easy:
➜ ~ env |grep -E 'DISP|DBUS' DISPLAY=:0 DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus ➜ ~ crontab -l |grep -v ^#
-
-
-
-
- DISPLAY=:0 DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus notify-send 'Emergency Notice' ' Is this world very quiet? ' -i /home/mephisto/Pictures/404.jpg
➜ ~ cat /etc/issue
Ubuntu 22.04 LTS \n \l
➜ ~ notify-send --help
Usage:
notify-send [OPTION…]
[BODY] - create a notification
- DISPLAY=:0 DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus notify-send 'Emergency Notice' ' Is this world very quiet? ' -i /home/mephisto/Pictures/404.jpg
➜ ~ cat /etc/issue
Ubuntu 22.04 LTS \n \l
➜ ~ notify-send --help
Usage:
notify-send [OPTION…]
-
-
-
Help Options: -?, --help Show help options
Application Options: -u, --urgency=LEVEL Specifies the urgency level (low, normal, critical). -t, --expire-time=TIME Specifies the timeout in milliseconds at which to expire the notification. -a, --app-name=APP_NAME Specifies the app name for the icon -i, --icon=ICON[,ICON...] Specifies an icon filename or stock icon to display. -c, --category=TYPE[,TYPE...] Specifies the notification category. -h, --hint=TYPE:NAME:VALUE Specifies passing basic extra data. Valid types are int, double, string, and byte. -v, --version Version of the package.
First, check the values of the environment variables DISPLAY and DBUS_SESSION_BUS_ADDRESS. Then, as shown above, add your own prompt task. After testing, I found that DISPLAY isn't required. The second environment variable setting seems a bit complicated, and since this is a small feature with limited usage, I'm too lazy to verify it. Those with the energy and interest are welcome to explore it.
Copyright statement:
- All content that is not sourced is original., please do not reprint without authorization (because the typesetting is often disordered after reprinting, the content is uncontrollable, and cannot be continuously updated, etc.);
- For non-profit purposes, to deduce any content of this blog, please give the relevant webpage address of this site in the form of 'source of original text' or 'reference link' (for the convenience of readers).