aboutsummaryrefslogtreecommitdiffstats
path: root/config/hypr/scripts/Volume.sh
diff options
context:
space:
mode:
authorJaKooLit <jimmielovejay@gmail.com>2023-10-22 15:55:57 +0900
committerJaKooLit <jimmielovejay@gmail.com>2023-10-22 15:55:57 +0900
commitc222e1bad2ba5e779c3af5b956906c82ead43271 (patch)
treea5253e0861c200ff90354169e1f67ef42ebf0ef9 /config/hypr/scripts/Volume.sh
parentbb0be21dba7980fc1c047eaba24eda1712bd7f31 (diff)
Initial upload
Diffstat (limited to 'config/hypr/scripts/Volume.sh')
-rwxr-xr-xconfig/hypr/scripts/Volume.sh109
1 files changed, 109 insertions, 0 deletions
diff --git a/config/hypr/scripts/Volume.sh b/config/hypr/scripts/Volume.sh
new file mode 100755
index 00000000..c5eab801
--- /dev/null
+++ b/config/hypr/scripts/Volume.sh
@@ -0,0 +1,109 @@
+#!/bin/bash
+
+iDIR="$HOME/.config/dunst/icons"
+
+# Get Volume
+get_volume() {
+ volume=$(pamixer --get-volume)
+ echo "$volume"
+}
+
+# Get icons
+get_icon() {
+ current=$(get_volume)
+ if [[ "$current" -eq "0" ]]; then
+ echo "$iDIR/volume-mute.png"
+ elif [[ ("$current" -ge "0") && ("$current" -le "30") ]]; then
+ echo "$iDIR/volume-low.png"
+ elif [[ ("$current" -ge "30") && ("$current" -le "60") ]]; then
+ echo "$iDIR/volume-mid.png"
+ elif [[ ("$current" -ge "60") && ("$current" -le "100") ]]; then
+ echo "$iDIR/volume-high.png"
+ fi
+}
+
+# Notify
+notify_user() {
+# notify-send -h string:x-canonical-private-synchronous:sys-notify -u normal -i "$(get_icon)" "Volume : $(get_volume) %"
+ notify-send -h int:value:$(get_volume) -h "string:x-dunst-stack-tag:volume_notif" -u low -i "$(get_icon)" "Volume : $(get_volume) %"
+
+}
+
+# Increase Volume
+inc_volume() {
+ pamixer -i 5 && notify_user
+}
+
+# Decrease Volume
+dec_volume() {
+ pamixer -d 5 && notify_user
+}
+
+# Toggle Mute
+toggle_mute() {
+ if [ "$(pamixer --get-mute)" == "false" ]; then
+ pamixer -m && notify-send -h string:x-canonical-private-synchronous:sys-notify -u low -i "$iDIR/volume-mute.png" "Volume Switched OFF"
+ elif [ "$(pamixer --get-mute)" == "true" ]; then
+ pamixer -u && notify-send -h string:x-canonical-private-synchronous:sys-notify -u low -i "$(get_icon)" "Volume Switched ON"
+ fi
+}
+
+# Toggle Mic
+toggle_mic() {
+ if [ "$(pamixer --default-source --get-mute)" == "false" ]; then
+ pamixer --default-source -m && notify-send -h string:x-canonical-private-synchronous:sys-notify -u low -i "$iDIR/microphone-mute.png" "Microphone Switched OFF"
+ elif [ "$(pamixer --default-source --get-mute)" == "true" ]; then
+ pamixer -u --default-source u && notify-send -h string:x-canonical-private-synchronous:sys-notify -u low -i "$iDIR/microphone.png" "Microphone Switched ON"
+ fi
+}
+# Get icons
+get_mic_icon() {
+ current=$(pamixer --default-source --get-volume)
+ if [[ "$current" -eq "0" ]]; then
+ echo "$iDIR/microphone.png"
+ elif [[ ("$current" -ge "0") && ("$current" -le "30") ]]; then
+ echo "$iDIR/microphone.png"
+ elif [[ ("$current" -ge "30") && ("$current" -le "60") ]]; then
+ echo "$iDIR/microphone.png"
+ elif [[ ("$current" -ge "60") && ("$current" -le "100") ]]; then
+ echo "$iDIR/microphone.png"
+ fi
+}
+# Notify
+notify_mic_user() {
+# notify-send -h string:x-canonical-private-synchronous:sys-notify -u low -i "$(get_mic_icon)" "Mic-Level : $(pamixer --default-source --get-volume) %"
+ notify-send -h int:value:$(pamixer --default-source --get-volume) -h "string:x-dunst-stack-tag:volume_notif" -u low -i "$(get_mic_icon)" "Mic-Level : $(pamixer --default-source --get-volume) %"
+}
+
+# Increase MIC Volume
+inc_mic_volume() {
+ pamixer --default-source -i 5 && notify_mic_user
+}
+
+# Decrease MIC Volume
+dec_mic_volume() {
+ pamixer --default-source -d 5 && notify_mic_user
+}
+
+# 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
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage