-
-
Save jameswpm/2833c89b18fc3f571985779cbee0a2b8 to your computer and use it in GitHub Desktop.
#!/bin/bash | |
# | |
# Minimalistic_Pomodoro_Timer | |
# | |
# Based on the SU answer found here: https://superuser.com/questions/224265/pomodoro-timer-for-linux/669811#669811 | |
# | |
# Tested in Ubuntu 16.04 and Arch | |
pomodorotime () { | |
notify-send "Time to Work" "Focus" -u normal -a 'Pomodoro' -i $HOME/Documentos/icon.png | |
paplay /usr/share/sounds/freedesktop/stereo/window-attention.oga | |
} | |
shortbreaktime () { | |
notify-send "Short Break Time" -u critical -a 'Pomodoro' -i $HOME/Documentos/icon.png | |
paplay /usr/share/sounds/freedesktop/stereo/complete.oga | |
# uncomment line below to lock your screen during the short break (needs to install xtrlock for your distribution) | |
# sleep 5 && xtrlock -b & sleep 250 && pkill xtrlock | |
} | |
longbreaktime () { | |
notify-send "Long Break Time" "Take a Rest" -u critical -a 'Pomodoro' -i $HOME/Documentos/icon.png | |
paplay /usr/share/sounds/freedesktop/stereo/complete.oga | |
} | |
case "$1" in | |
'start') | |
echo "Starting Pomodoro" | |
counter=0 | |
while true; do | |
now=`date +"%H:%M"` | |
pomodorotime | |
counter=$((counter+1)) | |
echo "Pomodoro number: $counter started at: $now" | |
sleep 1500 && shortbreaktime | |
sleep 300 && pomodorotime | |
now=`date +"%H:%M"` | |
counter=$((counter+1)) | |
echo "Pomodoro number: $counter started at: $now" | |
sleep 1500 && shortbreaktime | |
sleep 300 && pomodorotime | |
now=`date +"%H:%M"` | |
counter=$((counter+1)) | |
echo "Pomodoro number: $counter started at: $now" | |
sleep 1500 && shortbreaktime | |
sleep 300 && pomodorotime | |
now=`date +"%H:%M"` | |
counter=$((counter+1)) | |
echo "Pomodoro number: $counter started at: $now" | |
sleep 1500 && longbreaktime | |
echo "Long break time" | |
sleep 900 | |
done | |
;; | |
'pomo') | |
pomodorotime | |
sleep 1500 && shortbreaktime | |
;; | |
'sb') | |
sleep 300 && pomodorotime | |
;; | |
'lb') | |
sleep 900 && pomodorotime | |
;; | |
*) | |
echo | |
echo "Usage: $0 { start | pomo | sb | lb }" | |
echo | |
exit 1 | |
;; | |
esac | |
exit 0 |
@jameswpm I like it too! Ubuntu 18.04 -- works fine. But can u explain what is the -a 'Pomodoro'
option? In the man it's not described.
@alexeygorelov. On the options, the main use is start the script with start
that will work as any pomodoro timer. The other options are just usefull if you want to control your own timer. Use sb
to start a short break time, lb
to start a long break time and pomo
(I guess that is your question) to start a pomodoro time.
In short the use is
./pomodoro.sh start
or
./pomodoro.sh lb
or
./pomodoro.sh sb
or
./pomodoro.sh pomo
I'm sorry, but not quite. Although it is also useful.
For the notify-send
program, what does the -a
option and what is the option-argument 'Pomodoro'
.
The man notify-send
does not describe it.
Right, I got your question now. @alexeygorelov
The -a option it's just used to define a name for the icon of the running "application". I really don't know why it isn't in the man page, but you can see it with the command notify-send --help
. The result is something like below:
Usage:
notify-send [OPTION...] <SUMMARY> [BODY] - create a notification
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 basic extra data to pass. Valid types are int, double, string and byte.
-v, --version Version of the package.
Actually, I think that doesn't make any difference, so you can ignore it. Hope that it answer your question.
Yes, this is really what I asked. Thank you very much.
I am very ashamed!
man
info
--help
I had to first check all these options. From now on I will try to prevent this.
This lesson was much more useful than what I learned the meaning of the -a
option.
Once again, I apologize for my ignorance.
Hi, thank you for this script.
I want to use it maybe modify it a little bit.
What is the license for that script.
Hey, @marc31
I didn't include any license for it because it's just a toy project, so "Do What the Fuck You Want To" ;-)
Good job! Working fine here on Arch. I just had to rename the "Documents" folder due to localization differences. I've also added "sleep 5 && xtrlock -b & sleep 250 && pkill xtrlock" to line 16 to have the screen locked during the short breaks (thus forcing me to take a break from the PC). Cheers!