summaryrefslogtreecommitdiffstats
path: root/public/.local/bin/sb-stopwatch
diff options
context:
space:
mode:
Diffstat (limited to 'public/.local/bin/sb-stopwatch')
-rwxr-xr-xpublic/.local/bin/sb-stopwatch55
1 files changed, 55 insertions, 0 deletions
diff --git a/public/.local/bin/sb-stopwatch b/public/.local/bin/sb-stopwatch
new file mode 100755
index 0000000..06aa0e6
--- /dev/null
+++ b/public/.local/bin/sb-stopwatch
@@ -0,0 +1,55 @@
+#!/bin/sh
+
+# Custom stopwatch for "timeblocking"
+
+STATE_FILE="/tmp/sb-stopwatch.state"
+
+case $BLOCK_BUTTON in
+ 1) setsid -w -f "$TERMINAL" -e pulsemixer; pkill -RTMIN+10 "${STATUSBAR:-dwmblocks}" ;;
+ 2) wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle ;;
+ 4) wpctl set-volume @DEFAULT_AUDIO_SINK@ 1%+ ;;
+ 5) wpctl set-volume @DEFAULT_AUDIO_SINK@ 1%- ;;
+ 3) notify-send "📢 Volume module" "\- Shows volume 🔊, 🔇 if muted.
+- Middle click to mute.
+- Scroll to change." ;;
+ 6) "$TERMINAL" -e "$EDITOR" "$0" ;;
+esac
+
+
+read_timer() {
+ if [ ! -f "$STATE_FILE" ]; then
+ # If no state file, then no counter, exit
+ exit 0
+ fi
+
+ #if ! [[ "$end_time" =~ ^[0-9]+$ ]]; then
+ # echo "Invalid end_time in the state file."
+ # exit 1
+ #fi
+
+ end_time=$(cat "$STATE_FILE")
+ current_time=$(date +%s)
+ remaining_time=$((end_time - current_time))
+
+ if [ $remaining_time -lt 0 ]; then
+ # Time's up! Beep and exit
+ rm $STATE_FILE
+ paplay /opt/suckless/sb-stopwatch.wav
+ exit 0
+ fi
+
+ remaining_minutes=$((remaining_time / 60))
+}
+
+
+read_timer
+echo "⏳${remaining_minutes}m"
+
+# Emoji related to stopwatch:
+#⏱️ — Stopwatch
+#⏳ — Hourglass with flowing sand
+#🕰️ — Mantelpiece clock
+#🕒 — Clock face showing 3:00
+#⏰ — Alarm clock
+#🕰️ — Clock face
+#⏮️ — Previous track button (for rewind, related to time)