From 31e692b48e37e3de9c11075e151426458b9f62ca Mon Sep 17 00:00:00 2001 From: frosty Date: Tue, 28 May 2024 05:23:36 -0400 Subject: [PATCH] add block button handles for status bar scripts --- bin/.local/bin/statusbar/sb-battery | 4 ++++ bin/.local/bin/statusbar/sb-cpu | 4 ++++ bin/.local/bin/statusbar/sb-date | 5 +++++ bin/.local/bin/statusbar/sb-disk | 4 ++++ bin/.local/bin/statusbar/sb-memory | 6 +++++- bin/.local/bin/statusbar/sb-network | 4 ++++ bin/.local/bin/statusbar/sb-uptime | 4 ++++ bin/.local/bin/statusbar/sb-user | 4 ++++ bin/.local/bin/statusbar/sb-volume | 16 ++++++++++++++++ 9 files changed, 50 insertions(+), 1 deletion(-) diff --git a/bin/.local/bin/statusbar/sb-battery b/bin/.local/bin/statusbar/sb-battery index 28b4d5f..5f42bf7 100755 --- a/bin/.local/bin/statusbar/sb-battery +++ b/bin/.local/bin/statusbar/sb-battery @@ -2,6 +2,10 @@ BATTERY="BAT1" +case "$BLOCK_BUTTON" in + 6) setsid -f "$TERMINAL" -e "$EDITOR" "$0" ;; +esac + get_status_icon() { case "$1" in "Full" | "Charging") printf ' \n' ;; diff --git a/bin/.local/bin/statusbar/sb-cpu b/bin/.local/bin/statusbar/sb-cpu index a7d4829..ace3807 100755 --- a/bin/.local/bin/statusbar/sb-cpu +++ b/bin/.local/bin/statusbar/sb-cpu @@ -1,5 +1,9 @@ #!/bin/sh +case "$BLOCK_BUTTON" in + 6) setsid -f "$TERMINAL" -e "$EDITOR" "$0" ;; +esac + value=$(top -b -n 1 | awk '/%Cpu\(s\)/{print int($2)}') icon=" " diff --git a/bin/.local/bin/statusbar/sb-date b/bin/.local/bin/statusbar/sb-date index 2b1dea1..89972cc 100755 --- a/bin/.local/bin/statusbar/sb-date +++ b/bin/.local/bin/statusbar/sb-date @@ -1,5 +1,10 @@ #!/bin/sh +case "$BLOCK_BUTTON" in + 1) notify-send "$(cal)" ;; + 6) setsid -f "$TERMINAL" -e "$EDITOR" "$0" ;; +esac + value=$(date '+%b %-d %Y %-I:%M %p') icon=" " diff --git a/bin/.local/bin/statusbar/sb-disk b/bin/.local/bin/statusbar/sb-disk index 7b6b247..4aa96d6 100755 --- a/bin/.local/bin/statusbar/sb-disk +++ b/bin/.local/bin/statusbar/sb-disk @@ -2,6 +2,10 @@ DEFAULT_LOCATION="/" +case "$BLOCK_BUTTON" in + 6) setsid -f "$TERMINAL" -e "$EDITOR" "$0" ;; +esac + get_location_icon() { case "$1" in "/home"*) printf ' \n' ;; diff --git a/bin/.local/bin/statusbar/sb-memory b/bin/.local/bin/statusbar/sb-memory index 052b640..0698f7d 100755 --- a/bin/.local/bin/statusbar/sb-memory +++ b/bin/.local/bin/statusbar/sb-memory @@ -1,6 +1,10 @@ #!/bin/sh -value=$(free -h | awk '/Mem/ {gsub(/Gi/, "G", $3); gsub(/Mi/, "M", $3); print $3"/"$2}') +case "$BLOCK_BUTTON" in + 6) setsid -f "$TERMINAL" -e "$EDITOR" "$0" ;; +esac + +value=$(free -h | awk '/Mem/ {print $3"/"$2}' | sed 's/Gi/G/g; s/Mi/M/g') icon=" " printf ' %s %s\n' "$icon" "$value" diff --git a/bin/.local/bin/statusbar/sb-network b/bin/.local/bin/statusbar/sb-network index 927a530..eaa174e 100755 --- a/bin/.local/bin/statusbar/sb-network +++ b/bin/.local/bin/statusbar/sb-network @@ -1,5 +1,9 @@ #!/bin/sh +case "$BLOCK_BUTTON" in + 6) setsid -f "$TERMINAL" -e "$EDITOR" "$0" ;; +esac + get_local_ip() { if ! local_ip=$(ip route get 1); then printf 'Offline\n' diff --git a/bin/.local/bin/statusbar/sb-uptime b/bin/.local/bin/statusbar/sb-uptime index a28c933..924cc8d 100755 --- a/bin/.local/bin/statusbar/sb-uptime +++ b/bin/.local/bin/statusbar/sb-uptime @@ -1,5 +1,9 @@ #!/bin/sh +case "$BLOCK_BUTTON" in + 6) setsid -f "$TERMINAL" -e "$EDITOR" "$0" ;; +esac + value=$(uptime -p | sed 's/ day[s]*\b/d/g; s/ hour[s]*\b/h/g; s/ minute[s]*\b/m/g; s/up //; s/,//g') icon=" " diff --git a/bin/.local/bin/statusbar/sb-user b/bin/.local/bin/statusbar/sb-user index 284546f..5f42f17 100755 --- a/bin/.local/bin/statusbar/sb-user +++ b/bin/.local/bin/statusbar/sb-user @@ -1,5 +1,9 @@ #!/bin/sh +case "$BLOCK_BUTTON" in + 6) setsid -f "$TERMINAL" -e "$EDITOR" "$0" ;; +esac + value=$(whoami) icon=" " diff --git a/bin/.local/bin/statusbar/sb-volume b/bin/.local/bin/statusbar/sb-volume index 7742013..2d7cdf2 100755 --- a/bin/.local/bin/statusbar/sb-volume +++ b/bin/.local/bin/statusbar/sb-volume @@ -1,6 +1,22 @@ #!/bin/sh AUDIO_SINK="@DEFAULT_AUDIO_SINK@" +AUDIO_LIMIT=1 +AUDIO_STEP=2 + +case "$BLOCK_BUTTON" in + 1) wpctl set-mute "$AUDIO_SINK" toggle ;; + 3) setsid -f "$TERMINAL" -e pulsemixer ;; + 4) + wpctl set-mute "$AUDIO_SINK" 0 + wpctl set-volume -l "$AUDIO_LIMIT" "$AUDIO_SINK" "$AUDIO_STEP"%+ + ;; + 5) + wpctl set-mute "$AUDIO_SINK" 0 + wpctl set-volume -l "$AUDIO_LIMIT" "$AUDIO_SINK" "$AUDIO_STEP"%- + ;; + 6) setsid -f "$TERMINAL" -e "$EDITOR" "$0" ;; +esac get_volume_icon() { case "$1" in