From 5b14106c4aae906c0fe907ca2e002dbb00a7707b Mon Sep 17 00:00:00 2001 From: Mitsuo Tokumori Date: Sat, 12 Oct 2024 14:26:44 +0900 Subject: Add sb-stopwatch --- public/.local/bin/sb-stopwatch | 55 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100755 public/.local/bin/sb-stopwatch (limited to 'public/.local/bin/sb-stopwatch') 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) -- cgit v1.2.3