summaryrefslogtreecommitdiffstats
path: root/public/.local
diff options
context:
space:
mode:
authorMitsuo Tokumori <[email protected]>2024-10-12 14:26:44 +0900
committerMitsuo Tokumori <[email protected]>2024-10-12 14:26:44 +0900
commit5b14106c4aae906c0fe907ca2e002dbb00a7707b (patch)
treece7b531ca696571294f84027527ba8fbd67c9ed6 /public/.local
parent1163cd2e55e947874db656ce6857c929b0c32d39 (diff)
downloaddotfiles-5b14106c4aae906c0fe907ca2e002dbb00a7707b.tar.gz
dotfiles-5b14106c4aae906c0fe907ca2e002dbb00a7707b.tar.bz2
dotfiles-5b14106c4aae906c0fe907ca2e002dbb00a7707b.zip
Add sb-stopwatch
Diffstat (limited to 'public/.local')
-rwxr-xr-xpublic/.local/bin/sb-stopwatch55
-rwxr-xr-xpublic/.local/bin/stopwatch_control.sh19
2 files changed, 74 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)
diff --git a/public/.local/bin/stopwatch_control.sh b/public/.local/bin/stopwatch_control.sh
new file mode 100755
index 0000000..59a9d0e
--- /dev/null
+++ b/public/.local/bin/stopwatch_control.sh
@@ -0,0 +1,19 @@
+#!/bin/bash
+
+STATE_FILE="/tmp/sb-stopwatch.state"
+signal=5
+
+# signal dwmblocks to update block
+send_signal() {
+ pkill -RTMIN+$signal dwmblocks
+}
+
+
+if [ -z "$1" ]; then
+ echo "Usage: $0 <minutes>"
+ exit 1
+fi
+
+end_time=$(($(date +%s) + $1 * 60))
+echo "$end_time" > "$STATE_FILE"
+send_signal