Skip to content

Commit 71211f9

Browse files
author
cofincup
committed
update pomo.sh
1 parent 3967564 commit 71211f9

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ Useful scripts that I use, not all mine.
44
[connectivity_scan](https://github.com/CofinCup/nerd-scripts/blob/main/connectivity_test.py) is a multithreading python script that scans the local net for connectivity issues. The script works much faster than Fping(1 min for 32766 successful pings, while fping needs 6min for the same work), and has a fancy progressbar! (AND IT WAS WRITTEN BY CHATGPT, though I spent a lot of time tinkering with the prompts.)
55

66
![connectivity_scan](https://github.com/CofinCup/nerd-scripts/blob/main/connectivity_test/1.png)
7+
8+
[pomo.sh](https://github.com/CofinCup/nerd-scripts/blob/main/pomo.sh) is a countdown bash script that beeps & gives a system notification when countdown falls to zero.

pomo.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash
2+
3+
# get user input in minutes
4+
read -p "Enter countdown time in minutes: " countdown_minutes
5+
6+
# convert minutes to seconds
7+
countdown_time=$((countdown_minutes * 60))
8+
9+
# countdown loop
10+
for i in $(seq $countdown_time -1 1); do
11+
# calculate progress percentage
12+
progress=$(echo "scale=2; ($countdown_time - $i + 1) * 100 / $countdown_time" | bc)
13+
14+
# build progress bar
15+
bar=$(printf "%-${countdown_minutes}s" " ")
16+
bar=${bar// /#}
17+
bar="${bar:0:$((i / 60))}>"
18+
19+
# output progress bar and countdown timer
20+
echo -ne "$bar $progress% ($(date -u -d @$i +%M:%S))\r"
21+
22+
sleep 1
23+
done
24+
25+
# beep and send notification when countdown is complete
26+
echo "Time is up!"
27+
paplay /usr/share/sounds/freedesktop/stereo/complete.oga &
28+
notify-send "Countdown complete!" "The countdown has finished."
29+

0 commit comments

Comments
 (0)