]> git.armaanb.net Git - bin.git/commitdiff
Combine *-set, status into setter
authorArmaan Bhojwani <me@armaanb.net>
Mon, 8 Feb 2021 15:42:01 +0000 (10:42 -0500)
committerArmaan Bhojwani <me@armaanb.net>
Mon, 8 Feb 2021 15:47:46 +0000 (10:47 -0500)
audio-set [deleted file]
brightness-set [deleted file]
setter [new file with mode: 0755]
status [deleted file]

diff --git a/audio-set b/audio-set
deleted file mode 100755 (executable)
index ba02f98..0000000
--- a/audio-set
+++ /dev/null
@@ -1,18 +0,0 @@
-#!/usr/bin/env bash
-# When changing volume, if muted, unmute
-
-if [[ ${1} ]]; then
-  [[ $(amixer sget Master | tail -n 1 | grep "off") ]] &&
-    pactl set-sink-mute 0 toggle
-  pactl set-sink-volume 0 ${1}%
-  mutes="Unmuted"
-else
-  pactl set-sink-mute 0 toggle
-  mutes="Muted"
-fi
-
-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
diff --git a/brightness-set b/brightness-set
deleted file mode 100755 (executable)
index 61244e9..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/usr/bin/env sh
-# Show a notification and change screen brightness
-
-brightnessctl set ${1}
-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
diff --git a/setter b/setter
new file mode 100755 (executable)
index 0000000..e1f895a
--- /dev/null
+++ b/setter
@@ -0,0 +1,36 @@
+#!/usr/bin/env bash
+# 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") ]] &&
+      pactl set-sink-mute 0 toggle
+    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
+fi
diff --git a/status b/status
deleted file mode 100755 (executable)
index 9ca669b..0000000
--- a/status
+++ /dev/null
@@ -1,17 +0,0 @@
-#!/usr/bin/env bash
-# Sends a notification with the time, battery level, and volume
-
-time_set() {
-  date "+%A %Y-%m-%d, %r"
-}
-
-power_set() {
-  echo $(acpi | tail -c +12)
-}
-
-volume_set() {
-  echo "$(amixer sget Master | tail -n 1 | cut -d " " -f 7-)"
-}
-
-dunstify -h string:x-canonical-private-synchronous:status \
- "$(time_set)" "$(power_set)\n$(volume_set)" \