aboutsummaryrefslogtreecommitdiffstats
path: root/config/hypr/scripts/Volume.sh
diff options
context:
space:
mode:
authorMartin Guzman <55927935+brockar@users.noreply.github.com>2026-01-21 16:18:43 -0300
committerGitHub <noreply@github.com>2026-01-21 16:18:43 -0300
commitc6198c1bedeffd08ec3f60f7ba3a41e6c5870885 (patch)
tree458c030873b4e70ff9eda0baed5df257434871f4 /config/hypr/scripts/Volume.sh
parent7dedbe3d4a4560ac15987fdf8164dbbb1f4701bf (diff)
parent88a09344e8cc7cffe69a017eb752e8c6fa17ddcb (diff)
Merge pull request #927 from JaKooLit/development
Merge Development to main branch for release
Diffstat (limited to 'config/hypr/scripts/Volume.sh')
-rwxr-xr-xconfig/hypr/scripts/Volume.sh132
1 files changed, 92 insertions, 40 deletions
diff --git a/config/hypr/scripts/Volume.sh b/config/hypr/scripts/Volume.sh
index 4c82f543..e1034a68 100755
--- a/config/hypr/scripts/Volume.sh
+++ b/config/hypr/scripts/Volume.sh
@@ -7,8 +7,14 @@ sDIR="$HOME/.config/hypr/scripts"
# Get Volume
get_volume() {
+ if [[ "$(pamixer --get-mute)" == "true" ]]; then
+ echo "Muted"
+ return
+ fi
+
+ local volume
volume=$(pamixer --get-volume)
- if [[ "$volume" -eq "0" ]]; then
+ if [[ "$volume" -eq 0 ]]; then
echo "Muted"
else
echo "$volume %"
@@ -17,12 +23,15 @@ get_volume() {
# Get icons
get_icon() {
- current=$(get_volume)
- if [[ "$current" == "Muted" ]]; then
+ if [[ "$(pamixer --get-mute)" == "true" ]]; then
echo "$iDIR/volume-mute.png"
- elif [[ "${current%\%}" -le 30 ]]; then
+ return
+ fi
+
+ current=$(pamixer --get-volume)
+ if [[ "$current" -le 30 ]]; then
echo "$iDIR/volume-low.png"
- elif [[ "${current%\%}" -le 60 ]]; then
+ elif [[ "$current" -le 60 ]]; then
echo "$iDIR/volume-mid.png"
else
echo "$iDIR/volume-high.png"
@@ -31,11 +40,18 @@ get_icon() {
# Notify
notify_user() {
- if [[ "$(get_volume)" == "Muted" ]]; then
- notify-send -e -h string:x-canonical-private-synchronous:volume_notif -h boolean:SWAYNC_BYPASS_DND:true -u low -i "$(get_icon)" " Volume:" " Muted"
+ local muted="$(pamixer --get-mute)"
+ local level="$(pamixer --get-volume)"
+
+ if [[ "$muted" == "true" || "$level" -eq 0 ]]; then
+ notify-send -e -h string:x-canonical-private-synchronous:volume_notif \
+ -h boolean:SWAYNC_BYPASS_DND:true -u low -i "$(get_icon)" \
+ " Volume:" " Muted"
else
- notify-send -e -h int:value:"$(get_volume | sed 's/%//')" -h string:x-canonical-private-synchronous:volume_notif -h boolean:SWAYNC_BYPASS_DND:true -u low -i "$(get_icon)" " Volume Level:" " $(get_volume)" &&
- "$sDIR/Sounds.sh" --volume
+ notify-send -e -h int:value:"$level" -h string:x-canonical-private-synchronous:volume_notif \
+ -h boolean:SWAYNC_BYPASS_DND:true -u low -i "$(get_icon)" \
+ " Volume Level:" " ${level}%" &&
+ "$sDIR/Sounds.sh" --volume
fi
}
@@ -44,7 +60,7 @@ inc_volume() {
if [ "$(pamixer --get-mute)" == "true" ]; then
toggle_mute
else
- pamixer -i 5 --allow-boost --set-limit 150 && notify_user
+ pamixer -i "$1" --allow-boost --set-limit 150 && notify_user
fi
}
@@ -53,7 +69,7 @@ dec_volume() {
if [ "$(pamixer --get-mute)" == "true" ]; then
toggle_mute
else
- pamixer -d 5 && notify_user
+ pamixer -d "$1" && notify_user
fi
}
@@ -71,13 +87,14 @@ toggle_mic() {
if [ "$(pamixer --default-source --get-mute)" == "false" ]; then
pamixer --default-source -m && notify-send -e -u low -h boolean:SWAYNC_BYPASS_DND:true -i "$iDIR/microphone-mute.png" " Microphone:" " Switched OFF"
elif [ "$(pamixer --default-source --get-mute)" == "true" ]; then
- pamixer -u --default-source u && notify-send -e -u low -h boolean:SWAYNC_BYPASS_DND:true -i "$iDIR/microphone.png" " Microphone:" " Switched ON"
+ pamixer --default-source -u && notify-send -e -u low -h boolean:SWAYNC_BYPASS_DND:true -i "$iDIR/microphone.png" " Microphone:" " Switched ON"
fi
}
# Get Mic Icon
get_mic_icon() {
- current=$(pamixer --default-source --get-volume)
- if [[ "$current" -eq "0" ]]; then
+ local muted="$(pamixer --default-source --get-mute)"
+ local current="$(pamixer --default-source --get-volume)"
+ if [[ "$muted" == "true" || "$current" -eq "0" ]]; then
echo "$iDIR/microphone-mute.png"
else
echo "$iDIR/microphone.png"
@@ -86,8 +103,14 @@ get_mic_icon() {
# Get Microphone Volume
get_mic_volume() {
+ if [[ "$(pamixer --default-source --get-mute)" == "true" ]]; then
+ echo "Muted"
+ return
+ fi
+
+ local volume
volume=$(pamixer --default-source --get-volume)
- if [[ "$volume" -eq "0" ]]; then
+ if [[ "$volume" -eq 0 ]]; then
echo "Muted"
else
echo "$volume %"
@@ -96,9 +119,21 @@ get_mic_volume() {
# Notify for Microphone
notify_mic_user() {
- volume=$(get_mic_volume)
- icon=$(get_mic_icon)
- notify-send -e -h int:value:"$volume" -h "string:x-canonical-private-synchronous:volume_notif" -h boolean:SWAYNC_BYPASS_DND:true -u low -i "$icon" " Mic Level:" " $volume"
+ local muted="$(pamixer --default-source --get-mute)"
+ local level="$(pamixer --default-source --get-volume)"
+ local icon message
+
+ if [[ "$muted" == "true" || "$level" -eq 0 ]]; then
+ icon="$iDIR/microphone-mute.png"
+ notify-send -e -h "string:x-canonical-private-synchronous:volume_notif" \
+ -h boolean:SWAYNC_BYPASS_DND:true -u low -i "$icon" \
+ " Mic Level:" " Muted"
+ else
+ icon="$iDIR/microphone.png"
+ notify-send -e -h int:value:"$level" -h "string:x-canonical-private-synchronous:volume_notif" \
+ -h boolean:SWAYNC_BYPASS_DND:true -u low -i "$icon" \
+ " Mic Level:" " ${level}%"
+ fi
}
# Increase MIC Volume
@@ -113,31 +148,48 @@ inc_mic_volume() {
# Decrease MIC Volume
dec_mic_volume() {
if [ "$(pamixer --default-source --get-mute)" == "true" ]; then
- toggle-mic
+ toggle_mic
else
pamixer --default-source -d 5 && notify_mic_user
fi
}
# Execute accordingly
-if [[ "$1" == "--get" ]]; then
- get_volume
-elif [[ "$1" == "--inc" ]]; then
- inc_volume
-elif [[ "$1" == "--dec" ]]; then
- dec_volume
-elif [[ "$1" == "--toggle" ]]; then
- toggle_mute
-elif [[ "$1" == "--toggle-mic" ]]; then
- toggle_mic
-elif [[ "$1" == "--get-icon" ]]; then
- get_icon
-elif [[ "$1" == "--get-mic-icon" ]]; then
- get_mic_icon
-elif [[ "$1" == "--mic-inc" ]]; then
- inc_mic_volume
-elif [[ "$1" == "--mic-dec" ]]; then
- dec_mic_volume
-else
- get_volume
-fi \ No newline at end of file
+case "$1" in
+"--get")
+ get_volume
+ ;;
+"--inc")
+ inc_volume 5
+ ;;
+"--inc-precise")
+ inc_volume 1
+ ;;
+"--dec")
+ dec_volume 5
+ ;;
+"--dec-precise")
+ dec_volume 1
+ ;;
+"--toggle")
+ toggle_mute
+ ;;
+"--toggle-mic")
+ toggle_mic
+ ;;
+"--get-icon")
+ get_icon
+ ;;
+"--get-mic-icon")
+ get_mic_icon
+ ;;
+"--mic-inc")
+ inc_mic_volume
+ ;;
+"--mic-dec")
+ dec_mic_volume
+ ;;
+*)
+ get_volume
+ ;;
+esac
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage