domingo, 8 de janeiro de 2017

Linux - Pomodoro Script

I was looking for a app to use the pomodoro technique and I had not found anything valuable, but I found a blog post that create a bash script and I just increment the script a little bit and put on github.

So if you want to use the script just clone the https://github.com/diegogusava/pomodoro repository.

I also create a symbolic link on /usr/local/bin to point to the pomodoro script:
ln -s ~/my/path/pomodoro/pomodoro pomodoro
The full script
#!/bin/bash

clear

printf "Pomodoro (minutes): "
read pomodoro

printf "Rest (minutes): "
read rest

function loop() {
 time=$1
 while [ $time -gt 0 ] 
 do
  time=$(( $time - 1 ))
  now=$(date +"%T")
  sleep 1
  printf "$now: $(( $time / 60 )) minute(s) and $(( $time % 60 )) second(s) left\n"
 done
}

printf "New pomodoro starts. You have ${pomodoro} minute(s) to work.\n"

pomodoro=$(( $pomodoro * 60 ))
rest=$(( $rest * 60 ))

image=$(readlink -f pomodoro.png)

DISPLAY=:0 notify-send -t 1000 -i $image "New pomodoro starts" "You have 25 minutes to work."

loop $pomodoro

clear

now=$(date +"%T")

printf "Pomodoro ends at $now\n"

DISPLAY=:0 notify-send -t 1000 -i $image "pomodoro ends" "Take a rest!"

printf "Take a rest! Press any key to continue!!"

read whatever

loop $rest

now=$(date +"%T")

printf "Rest ends at $now\n"

Nenhum comentário:

Postar um comentário