Zenity and timeout option

categories:

Lately I installed rsnapshot on my lappy to get my files backed up on my home server during the night, in case the laptop is on.

Rsnapshot is only CLI, I still somewhat wanted to get some kind of visual notification saying the backup was starting (and ending).. just to avoid shutting down my machine while the backup process was still on, for example.

Rsnapshot allows you, throught the cmd_postexec and cmd_preexec options, to run scripts before and after the backup job.

I came up with scripts using Zenity for visual notifications.

The thing is, the cmd_postexec script must complete before the backup can begin, and the only documented way I found to start the backup was to click OK on the zenity notification. This would be annoying if I’m not at the computer at that time (which is very likely :) ). The notification popup would just wait for my input to start the backup job.. not good.

I tried to figure out a decent way to get rid of the popup after a few second, but I didn’t have to search for too long.. Indeed, Marco spotted that Zenity has an undocumented timeout option doing exactly what I wanted.

Odd that it is not documented..

Thanks to Marco !

For the curious, here’s the cmd_postexec script (rsnapshot running as root and opening the popup on the user’s desktop) :

#!/bin/bash su USERNAME -c 'export DISPLAY=:0.0; zenity --timeout 30 --info --text "Rsnapshot backup will start in 30 seconds"' exit 0




Thanks for reading this post!


Did you find an issue in this article?

- click on the following Github link
- log into Github with your account
- click on the line number containing the error
- click on the "..." button
- choose "Reference in new issue"
- add a title and your comment
- click "Submit new issue"

Your feedback is much appreciated! πŸ€œπŸΌπŸ€›πŸΌ

You can also drop me a line below!