]> git.armaanb.net Git - bin.git/commitdiff
setter: make posix and modify argument parsing
authorArmaan Bhojwani <me@armaanb.net>
Mon, 31 May 2021 21:17:05 +0000 (21:17 +0000)
committerArmaan Bhojwani <me@armaanb.net>
Tue, 1 Jun 2021 03:42:29 +0000 (23:42 -0400)
man/setter.1.scd
setter

index 72722099404ac0e4c0b7fcc9de9390b6ea1cc5aa..fe6e2db2240f2afeccea32af821b5ba9412548e0 100644 (file)
@@ -11,7 +11,7 @@ setter - media hotkey backend
 
 # DESCRIPTION
 The various subcommands of setter are designed to be bound to various media
-keys. setter without a subcommand is an alias to "status".
+keys.
 
 # SUBCOMMANDS
 *status*
diff --git a/setter b/setter
index b13adfbfffa5328a91a6383dafffeb461015803f..6d6be9cef8d07e8fce44a5c0fc16fb3a6f47c40e 100755 (executable)
--- a/setter
+++ b/setter
@@ -1,35 +1,25 @@
-#!/usr/bin/env bash
+#!/usr/bin/env sh
 # Sends a notification with the time, battery level, and volume
 
-if [[ ${1} == "status" || -z ${1} ]]; then
-               dunstify -h string:x-canonical-private-synchronous:status \
-                                                "$(date "+%A %Y-%m-%d, %r")"\
-                                                "$(acpi | tail -c +12)\n$(amixer sget Master | tail -n 1 \
-        | cut -d " " -f 7-)" \
-                                                -t 2000
-
-elif [[ ${1} == "audio" ]]; then
-               if [[ ${2} ]]; then
-                               [[ $(amixer sget Master | tail -n 1 | grep "off") ]] &&
+pkill -SIGUSR1 herbe
+if [ "$1" = "status" ]; then
+               herbe "$(date "+%A %Y-%m-%d, %r")" \
+                                       "$(acpi | tail -c +12)" \
+                                       "$(amixer sget Master | tail -n 1 | cut -d " " -f 7-)"
+elif [ "$1" = "audio" ]; then
+               if [ "$2" ]; then
+                               amixer sget Master | tail -n 1 | grep "off" && \
                                                pactl set-sink-mute 0 toggle
-                               pactl set-sink-volume 0 ${2}%
+                               pactl set-sink-volume 0 "$2%"
                else
                                pactl set-sink-mute 0 toggle
                fi
 
-               mutes="Unmuted"
-               [[ $(amixer sget Master | tail -n 1 | grep "off") ]] && mutes="Muted"
-
-               dunstify -h string:x-canonical-private-synchronous:audio \
-                                                "Volume" "${mutes}" \
-                                                -h int:value:"$(amixer sget Master | tail -n 1 | cut -d '[' -f 2 | \
-               head -c +2)" \
-                                                -t 1000
-
-elif [[ ${1} == "brightness" ]]; then
-               brightnessctl set ${2}
-               dunstify -h string:x-canonical-private-synchronous:brightness \
-                                                "Brightness" "$(brightnessctl | grep % | tail -c +22)" \
-                                                -h int:value:"$(brightnessctl | grep % | cut -d '(' -f 2 | head -c +3)" \
-                                                -t 1000
+               herbe "Volume" "$(amixer sget Master | tail -n 1 | cut -d " " -f 7-)"
+elif [ "$1" = "brightness" ]; then
+               brightnessctl set "$2"
+               herbe "Brightness" "$(brightnessctl | grep % | tail -c +22)"
+else
+               echo "setter: unknown subcommand"
+               exit 1
 fi