summaryrefslogtreecommitdiffstats
path: root/roles/hyprland/files/scripts
diff options
context:
space:
mode:
authorAhmed Abdelhalim <[email protected]>2026-02-09 22:20:36 +0100
committerAhmed Abdelhalim <[email protected]>2026-02-09 22:20:36 +0100
commitf7bee0b02aead06ea58451bba8af73440c7a13d2 (patch)
tree3a8aad96972e024c4d24ff9fe845c0c3d25f0001 /roles/hyprland/files/scripts
parent7d149e3763138de600661bf0acc6aa9ec283f4d3 (diff)
Minor styling to volume.sh to handle mic too (not tested)
Diffstat (limited to 'roles/hyprland/files/scripts')
-rwxr-xr-xroles/hyprland/files/scripts/volume.sh51
1 files changed, 34 insertions, 17 deletions
diff --git a/roles/hyprland/files/scripts/volume.sh b/roles/hyprland/files/scripts/volume.sh
index c5ea8b6d..a39fa113 100755
--- a/roles/hyprland/files/scripts/volume.sh
+++ b/roles/hyprland/files/scripts/volume.sh
@@ -10,9 +10,18 @@ get_volume() {
volume=$(echo "$volume_status" | cut -d' ' -f2 | awk '{printf "%d\n", $1 * 100}')
}
+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}')
+}
+
set_volume() {
- local volume=$1
- wpctl set-volume -l 1 @DEFAULT_AUDIO_SINK@ $volume
+ wpctl set-volume -l 1 @DEFAULT_AUDIO_SINK@ "$1"
}
mute_volume() {
@@ -24,19 +33,27 @@ mute_mic() {
}
notify() {
- value="$1"
+ local label="$1"
+ if [[ "$label" == "Volume" ]]; then
+ local mute_icon=" "
+ local icon=" "
+ elif [[ "$label" == "Mic" ]]; then
+ local mute_icon=" "
+ local icon=""
+ fi
+ local value="$2"
if $muted; then
notify-send -e \
-h string:x-canonical-private-synchronous:volume \
-u low \
- "Volume" \
- " \tmute"
+ "$label" \
+ "$mute_icon\tmute"
else
notify-send -e \
-h string:x-canonical-private-synchronous:volume \
-u low \
- "Volume" \
- " \t$value%"
+ "$label" \
+ "$icon\t${value}%"
fi
}
@@ -45,32 +62,32 @@ STEP="${2:-1}"
case "$1" in
"--get")
get_volume
- notify $volume
+ notify "Volume" "$volume"
;;
"--set")
- set_volume $STEP%
+ set_volume "${STEP}%"
get_volume
- notify $volume
+ notify "Volume" "$volume"
;;
"--inc")
- set_volume $STEP%+
+ set_volume "${STEP}%+"
get_volume
- notify $volume
+ notify "Volume" "$volume"
;;
"--dec")
- set_volume $STEP%-
+ set_volume "${STEP}%-"
get_volume
- notify $volume
+ notify "Volume" "$volume"
;;
"--toggle-mute-vol")
mute_volume
get_volume
- notify $volume
+ notify "Volume" "$volume"
;;
"--toggle-mute-mic")
mute_mic
- get_volume
- notify $volume
+ get_mic
+ notify "Mic" "$volume"
;;
*)
echo -e "Usage:"