diff options
| -rwxr-xr-x | public/.local/bin/sb-stopwatch | 55 | ||||
| -rwxr-xr-x | public/.local/bin/stopwatch_control.sh | 19 | ||||
| -rw-r--r-- | public/.xbindkeysrc | 6 | ||||
| -rw-r--r-- | public/code/dwmblocks/config.h | 13 |
4 files changed, 87 insertions, 6 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 diff --git a/public/.xbindkeysrc b/public/.xbindkeysrc index 7acb6fe..7171126 100644 --- a/public/.xbindkeysrc +++ b/public/.xbindkeysrc @@ -132,6 +132,12 @@ "network_control.sh isolatetoggle" Shift+Mod4 + b +"stopwatch_control.sh 50" + Mod4 + p + +"stopwatch_control.sh 5" + Mod4 + o + # Suckless desktop # -------------------- diff --git a/public/code/dwmblocks/config.h b/public/code/dwmblocks/config.h index 6587a09..a53a306 100644 --- a/public/code/dwmblocks/config.h +++ b/public/code/dwmblocks/config.h @@ -12,12 +12,13 @@ static const Block blocks[] = { /*Icon*/ /*Command*/ /*Update Interval*/ /*Update Signal*/ - {"", "sb-input", 0, 20}, - {"", "sb-audio", 0, 10}, - {"", "sb-battery", 5, 0}, - {"ð§ ", "sensors | grep 'Tctl' | awk '{print $2}'", 5, 0}, - {"ð", "free | awk '/^Mem/ { printf \"%.0f%\", $3/$2*100 }'", 5, 0}, - {"", "sb-network", 30, 30}, + {"", "sb-stopwatch", 20, 5}, + {"", "sb-input", 0, 20}, + {"", "sb-audio", 0, 10}, + {"", "sb-battery", 20, 0}, + {"ð§ ", "sensors | grep 'Tctl' | awk '{print $2}'", 5, 0}, + {"ð", "free | awk '/^Mem/ { printf \"%.0f%\", $3/$2*100 }'", 5, 0}, + {"", "sb-network", 30, 30}, {"", "date '+Q%qW%V%a %mæ%dæ¥ %H:%M'", 12, 0}, }; |
