Changes in: bin,dunst,gtk-3.0,gtk-4.0,hypr,waybar,

This commit is contained in:
Gopher 2025-03-22 20:38:29 +05:30
parent 9920450b17
commit 50cc31d4e1
43 changed files with 2807 additions and 215 deletions

View file

@ -1,55 +1,170 @@
#!/bin/sh
#!/bin/bash
iDIR="$HOME/.config/dunst/icons/vol"
case $1 in
up)
wpctl set-mute @DEFAULT_AUDIO_SINK@ 0
wpctl set-volume -l 2.0 @DEFAULT_AUDIO_SINK@ 2%+
;;
down)
wpctl set-mute @DEFAULT_AUDIO_SINK@ 0
wpctl set-volume -l 2.0 @DEFAULT_AUDIO_SINK@ 2%-
;;
mute)
wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle
;;
*)
echo "Usage: $0 {up|down|mute}"
exit 1
;;
esac
VOLUME=$(wpctl get-volume @DEFAULT_AUDIO_SINK@ | awk '{print int($2 * 100)}')
NORMALIZED_VOLUME=$((VOLUME / 2))
send_notification() {
# if [ "$1" = "mute" ]; then
# ICON='' # Mute icon
# MSG="Muted"
# elif [ "$NORMALIZED_VOLUME" -lt 50 ]; then
# ICON='' # Low volume icon
# MSG="Volume: $NORMALIZED_VOLUME%"
# elif [ "$NORMALIZED_VOLUME" -lt 90 ]; then
# ICON='' # Medium volume icon
# MSG="Volume: $NORMALIZED_VOLUME%"
# else
# ICON='' # High volume icon
# MSG="Volume: $NORMALIZED_VOLUME%"
# fi
dunstify -u normal -h "int:value:$NORMALIZED_VOLUME" -a "Volume" "Volume" -t 2000
# Get Volume
get_volume() {
volume=$(pamixer --get-volume)
if [[ "$volume" -eq "0" ]]; then
echo "Muted"
else
echo "$volume%"
fi
}
case $1 in
mute)
if wpctl get-volume @DEFAULT_AUDIO_SINK@ | grep -q "MUTED"; then
send_notification mute
else
send_notification
fi
;;
*)
send_notification
;;
esac
# Get icons
get_icon() {
current=$(get_volume)
if [[ "$current" == "Muted" ]]; then
echo "$iDIR/muted-speaker.svg"
elif [[ "${current%\%}" = 5 ]]; then
echo "$iDIR/vol-5.svg"
elif [[ "${current%\%}" = 10 ]]; then
echo "$iDIR/vol-10.svg"
elif [[ "${current%\%}" = 15 ]]; then
echo "$iDIR/vol-15.svg"
elif [[ "${current%\%}" = 20 ]]; then
echo "$iDIR/vol-20.svg"
elif [[ "${current%\%}" = 25 ]]; then
echo "$iDIR/vol-25.svg"
elif [[ "${current%\%}" = 30 ]]; then
echo "$iDIR/vol-30.svg"
elif [[ "${current%\%}" = 35 ]]; then
echo "$iDIR/vol-35.svg"
elif [[ "${current%\%}" = 40 ]]; then
echo "$iDIR/vol-40.svg"
elif [[ "${current%\%}" = 45 ]]; then
echo "$iDIR/vol-45.svg"
elif [[ "${current%\%}" = 50 ]]; then
echo "$iDIR/vol-50.svg"
elif [[ "${current%\%}" = 55 ]]; then
echo "$iDIR/vol-55.svg"
elif [[ "${current%\%}" = 60 ]]; then
echo "$iDIR/vol-60.svg"
elif [[ "${current%\%}" = 65 ]]; then
echo "$iDIR/vol-65.svg"
elif [[ "${current%\%}" = 70 ]]; then
echo "$iDIR/vol-70.svg"
elif [[ "${current%\%}" = 75 ]]; then
echo "$iDIR/vol-75.svg"
elif [[ "${current%\%}" = 80 ]]; then
echo "$iDIR/vol-80.svg"
elif [[ "${current%\%}" = 85 ]]; then
echo "$iDIR/vol-85.svg"
elif [[ "${current%\%}" = 90 ]]; then
echo "$iDIR/vol-90.svg"
elif [[ "${current%\%}" = 95 ]]; then
echo "$iDIR/vol-95.svg"
else
echo "$iDIR/vol-100.svg"
fi
}
# Notify
notify_user() {
if [[ "$(get_volume)" == " " ]]; then
notify-send -a -r -h string:x-dunst-stack-tag:volume_notif -i "$(get_icon)" "Volume: Muted"
else
notify-send -a -r -h string:x-dunst-stack-tag:volume_notif -i "$(get_icon)" "Volume: $(get_volume)"
fi
}
# Increase Volume
inc_volume() {
if [ "$(pamixer --get-mute)" == "true" ]; then
pamixer -u && notify_user
fi
pamixer -i 5 && notify_user
}
# Decrease Volume
dec_volume() {
if [ "$(pamixer --get-mute)" == "true" ]; then
pamixer -u && notify_user
fi
pamixer -d 5 && notify_user
}
# Toggle Mute
toggle_mute() {
if [ "$(pamixer --get-mute)" == "false" ]; then
pamixer -m && notify-send -a -h -i "$iDIR/muted-speaker.svg" "Volume Switched OFF"
elif [ "$(pamixer --get-mute)" == "true" ]; then
pamixer -u && notify-send -a -h -i "$iDIR/unmuted-speaker.svg" "Volume Switched ON"
fi
}
# Toggle Mic
toggle_mic() {
if [ "$(pamixer --default-source --get-mute)" == "false" ]; then
pamixer --default-source -m && notify-send -e -u low -i "$iDIR/muted-mic.svg" "Microphone Switched OFF"
elif [ "$(pamixer --default-source --get-mute)" == "true" ]; then
pamixer --default-source -u && notify-send -e -u low -i "$iDIR/unmuted-mic.svg" "Microphone Switched ON"
fi
}
# Get Mic Icon
get_mic_icon() {
current=$(pamixer --default-source --get-volume)
if [[ "$current" -eq "0" ]]; then
echo "$iDIR/muted-mic.svg"
else
echo "$iDIR/unmuted-mic.svg"
fi
}
# Get Microphone Volume
get_mic_volume() {
volume=$(pamixer --default-source --get-volume)
if [[ "$volume" -eq "0" ]]; then
echo "Muted"
else
echo "$volume%"
fi
}
# Notify for Microphone
notify_mic_user() {
volume=$(get_mic_volume)
icon=$(get_mic_icon)
notify-send -a -r 91190 -t 800 -i "$icon" "Mic=vel: $volume"
}
# Increase MIC Volume
inc_mic_volume() {
if [ "$(pamixer --default-source --get-mute)" == "true" ]; then
pamixer --default-source -u && notify_mic_user
fi
pamixer --default-source -i 5 && notify_mic_user
}
# Decrease MIC Volume
dec_mic_volume() {
if [ "$(pamixer --default-source --get-mute)" == "true" ]; then
pamixer --default-source -u && notify_mic_user
fi
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