[polybar] Add pomo timer as git submodule
Using [jsspencer/pomo](https://github.com/jsspencer/pomo) as the timer of choice. It is simple, it works well, and it uses a very elegant way of tracking the time. I can think about implementing my own version later, but this will handily suffice for now. Polybar script will now limit the pomo timer to a single 'running' instance containing the notification function, by putting its running instance PID in a lockfile and killing it before restarting or changing the timer. Added running and paused tomato icons; as well as break coffee icon. Removed display of seconds, unless the last minute of a timer is running.
This commit is contained in:
parent
9b362cae38
commit
050bac9c55
6 changed files with 63 additions and 3 deletions
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
while true; do
|
||||
all="$(bib-due -u 'fri this week' | wc -l)"
|
||||
all="$(bib-due -u 'fri this week' -p3 | wc -l)"
|
||||
required="$(bib-due -u 'fri this week' -p1 | wc -l)"
|
||||
|
||||
# add polybar formatting to color required readings red
|
||||
|
|
|
|||
41
polybar/.config/polybar/scripts/poly-pomo
Executable file
41
polybar/.config/polybar/scripts/poly-pomo
Executable file
|
|
@ -0,0 +1,41 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
run_notify() {
|
||||
pomo notify &
|
||||
PID_NOTIFY="$!"
|
||||
echo "$PID_NOTIFY" >"${XDG_RUNTIME_DIR:-$HOME}"/.running-pomo.lock
|
||||
}
|
||||
|
||||
# create background notify process; close it when this process is killed
|
||||
close_notify() {
|
||||
lockfile="${XDG_RUNTIME_DIR:-$HOME}"/.running-pomo.lock
|
||||
[ -f "$lockfile" ] && kill "$(cat "$lockfile")"
|
||||
kill "$PID_NOTIFY"
|
||||
rm "${XDG_RUNTIME_DIR:-$HOME}"/.running-pomo.lock
|
||||
}
|
||||
trap close_notify EXIT
|
||||
|
||||
restart_notify() {
|
||||
close_notify
|
||||
run_notify
|
||||
}
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
run_notify
|
||||
while true; do
|
||||
display=$(pomo clock)
|
||||
# replace W (work)
|
||||
# B (break)
|
||||
# P (paused) with pomodoro symbols
|
||||
# remove seconds *except for* when 00 minutes reached
|
||||
display=$(echo "$display" | sed -e 's/P.*$/ /;s/W/ /;s/B/ /;/00:/! { s/:[[:digit:]]\+$// }')
|
||||
echo "$display"
|
||||
sleep 1
|
||||
done
|
||||
elif [ "$1" = "toggle" ]; then
|
||||
pomo pause
|
||||
restart_notify
|
||||
elif [ "$1" = "restart" ]; then
|
||||
pomo stop && pomo start
|
||||
restart_notify
|
||||
fi
|
||||
Loading…
Add table
Add a link
Reference in a new issue