summaryrefslogtreecommitdiffstats
path: root/roles/hyprland
diff options
context:
space:
mode:
authorAhmed Abdelhalim <[email protected]>2026-02-09 22:29:25 +0100
committerAhmed Abdelhalim <[email protected]>2026-02-09 22:29:25 +0100
commit4539968d5445c1d245cc2a68e54f850f7577b20d (patch)
tree15cb19159be42559ad4ae491aec7ad5bc0b36e41 /roles/hyprland
parentf7bee0b02aead06ea58451bba8af73440c7a13d2 (diff)
Apply AI verified refactoring
Co-Authored-By: Claude.ai
Diffstat (limited to 'roles/hyprland')
-rwxr-xr-xroles/hyprland/files/scripts/volume.sh53
1 files changed, 25 insertions, 28 deletions
diff --git a/roles/hyprland/files/scripts/volume.sh b/roles/hyprland/files/scripts/volume.sh
index a39fa113..5c2ad3d5 100755
--- a/roles/hyprland/files/scripts/volume.sh
+++ b/roles/hyprland/files/scripts/volume.sh
@@ -1,23 +1,19 @@
#!/bin/bash
get_volume() {
- local volume_status=$(wpctl get-volume @DEFAULT_AUDIO_SINK@)
- if [[ "$volume_status" == *"MUTED"* ]]; then
- muted=true
- else
- muted=false
- fi
- volume=$(echo "$volume_status" | cut -d' ' -f2 | awk '{printf "%d\n", $1 * 100}')
+ local status=$(wpctl get-volume @DEFAULT_AUDIO_SINK@)
+ local vol=$(echo "$status" | cut -d' ' -f2 | awk '{printf "%d\n", $1 * 100}')
+ local muted=false
+ [[ "$status" == *"MUTED"* ]] && muted=true
+ echo "$muted $vol"
}
get_mic() {
- local mic_status=$(wpctl get-volume @DEFAULT_AUDIO_SOURCE@)
- if [[ "$mic_status" == *"MUTED"* ]]; then
- muted=true
- else
- muted=false
- fi
- volume=$(echo "$mic_status" | cut -d' ' -f2 | awk '{printf "%d\n", $1 * 100}')
+ local status=$(wpctl get-volume @DEFAULT_AUDIO_SOURCE@)
+ local vol=$(echo "$status" | cut -d' ' -f2 | awk '{printf "%d\n", $1 * 100}')
+ local muted=false
+ [[ "$status" == *"MUTED"* ]] && muted=true
+ echo "$muted $vol"
}
set_volume() {
@@ -34,6 +30,8 @@ mute_mic() {
notify() {
local label="$1"
+ local muted="$2"
+ local value="$3"
if [[ "$label" == "Volume" ]]; then
local mute_icon=" "
local icon=" "
@@ -41,8 +39,7 @@ notify() {
local mute_icon=" "
local icon=""
fi
- local value="$2"
- if $muted; then
+ if [[ "$muted" == true ]]; then
notify-send -e \
-h string:x-canonical-private-synchronous:volume \
-u low \
@@ -61,33 +58,33 @@ notify() {
STEP="${2:-1}"
case "$1" in
"--get")
- get_volume
- notify "Volume" "$volume"
+ read -r muted volume <<< "$(get_volume)"
+ notify "Volume" "$muted" "$volume"
;;
"--set")
set_volume "${STEP}%"
- get_volume
- notify "Volume" "$volume"
+ read -r muted volume <<< "$(get_volume)"
+ notify "Volume" "$muted" "$volume"
;;
"--inc")
set_volume "${STEP}%+"
- get_volume
- notify "Volume" "$volume"
+ read -r muted volume <<< "$(get_volume)"
+ notify "Volume" "$muted" "$volume"
;;
"--dec")
set_volume "${STEP}%-"
- get_volume
- notify "Volume" "$volume"
+ read -r muted volume <<< "$(get_volume)"
+ notify "Volume" "$muted" "$volume"
;;
"--toggle-mute-vol")
mute_volume
- get_volume
- notify "Volume" "$volume"
+ read -r muted volume <<< "$(get_volume)"
+ notify "Volume" "$muted" "$volume"
;;
"--toggle-mute-mic")
mute_mic
- get_mic
- notify "Mic" "$volume"
+ read -r muted volume <<< "$(get_mic)"
+ notify "Mic" "$muted" "$volume"
;;
*)
echo -e "Usage:"