I was wondering if it is possible to get a custom desktop notification every third hour from the computer starts and how do I do that?
create a systemd user timer that runs in that interval. You want a monotonic timer with
Start with that timer a systemd user service that runs
notify-send with the options you want.
notify-send usually works on all DE's but depending on your DE there might be a better DE specific command.
User timers and services are stored in
notify-send from then you could easily write a simple bash script.
#!/usr/bin/env python import time import subprocess while True: time.sleep(180) subprocess.run('notify-send "Hello !!!"', shell=True, check=True)
Another way is the cron.
Create script "notifymeevery3rdhour" something like:
export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus && notify-send "your message"
add to crontab:
0 */3 * * * $HOME/bin/notifymeevery3rdhour
cron can be cranky about using notify-send. you can do some extra work to make sure notify-send knows where to send it, or you can be lazy like me and use xmessage instead.
Okay so I solved this by using xircons python script and making a systemd service which starts that script on startup. Thanks again guys for all the help. Cheers!
I also modified the script a little and added sound to the notification using python-vlc. So as you can see in this script. I wanted to have a notification that reminded me to drink something every third hour.
#!/usr/bin/env python import vlc import time import subprocess sound_file = vlc.MediaPlayer("/path/to/sound.mp3") while True: time.sleep(10800) subprocess.run('notify-send "Make sure you stay hydrated. Right now you should at least have consumed a glass of ' 'water or any other type of beverage"', shell=True, check=True) sound_file.play() time.sleep(6) sound_file.stop()
I need no reminders
[Glad you got it working ... and you learned some python, scripting, desktop-notifications, and systemd along the way. I like seeing things like this happen.]
I already knew a bit of this. But I learned a bit more. Also it feels so nice when you've made it yourself. It's like making your own food it taste different when you make yourself, usually in a good way.
You never met my mother.
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.