Skip to content

Commit 8fb30e4

Browse files
authored
Merge pull request ruanyf#8 from Kiailandi/pomodoro.sh
Add pomodoro.sh - a simple pomodoro app written in bash
2 parents a936556 + 269e341 commit 8fb30e4

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ A collection of simple Bash scripts.
1515
1. [up.sh](scripts/up.sh): move up a directory in shell script
1616
1. [Randomfile.sh](scripts/Randomfile.sh): create unique file/folder automatically with date and time stamp
1717
1. [weather.sh] (scripts/weather.sh): check the weather in a specified location or using the geolocation of the ip address by default.
18+
1. [pomodoro.sh](scripts/pomodoro.sh): a simple pomodoro app written in bash
1819

1920
## Programming
2021

scripts/pomodoro.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
3+
# A simple shell script to use as a pomodoro app.
4+
# The first argument is the focus time length.
5+
# The second argument is the break length.
6+
# Made by Kiailandi (https://github.com/kiailandi)
7+
8+
wseconds=${1:-25}*60;
9+
pseconds=${2:-wseconds/300}*60;
10+
11+
while true; do
12+
date1=$((`date +%s` + $wseconds));
13+
while [ "$date1" -ge `date +%s` ]; do
14+
echo -ne "$(date -u --date @$(($date1 - `date +%s` )) +%H:%M:%S)\r";
15+
done
16+
notify-send "Break" "Time to walk and rest";
17+
read -n1 -rsp $'Press any key to continue or Ctrl+C to exit...\n';
18+
date2=$((`date +%s` + $pseconds));
19+
while [ "$date2" -ge `date +%s` ]; do
20+
echo -ne "$(date -u --date @$(($date2 - `date +%s` )) +%H:%M:%S)\r";
21+
done
22+
notify-send "Work" "Time to get back to work";
23+
read -n1 -rsp $'Press any key to continue or Ctrl+C to exit...\n';
24+
done

0 commit comments

Comments
 (0)