Created
May 14, 2020 02:33
-
-
Save letam/a5c9cfb421fb441e0dd6996822a4c044 to your computer and use it in GitHub Desktop.
Break Timer using Zenity (requires Linux and GTK)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Break Timer using Zenity (requires Linux and GTK) | |
[[ $# != 1 ]] && >&2 echo "Usage: $0 MINUTES" && exit 1 | |
minutes=$1 | |
pyp() { python -c "print($1)"; } | |
if grep -q '\.' <<<$minutes; then | |
seconds=$(pyp "int($minutes*60)") | |
else | |
seconds=$((minutes*60)) | |
fi | |
display_dimensions=$(xdpyinfo | awk '/dimensions/{print $2}') | |
width=$(cut -f1 -dx <<< $display_dimensions) | |
height=$(cut -f2 -dx <<< $display_dimensions) | |
sleep $seconds && \ | |
zenity --timeout 15 --warning --text="Step away from the machine." --width $width --height $height | |
exit | |
## References | |
- [Pomodoro Timer for Linux](https://superuser.com/questions/224265/pomodoro-timer-for-linux/669811#669811) | |
- [Bash, zenity progress bar without cancel](https://stackoverflow.com/questions/4907381/bash-zenity-progress-bar-without-cancel) | |
- [Control the size of the content in a zenity window](https://stackoverflow.com/questions/18234920/control-the-size-of-the-content-in-a-zenity-window) | |
- [How can I get the monitor resolution using the command line?](https://askubuntu.com/questions/584688/how-can-i-get-the-monitor-resolution-using-the-command-line) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment