Fixed volume and media keybinds

This commit is contained in:
Michel Fedde 2025-05-30 23:04:26 +02:00
parent 0e111ad114
commit 88bda96496
4 changed files with 40 additions and 17 deletions

View file

@ -2,42 +2,66 @@
# /* ---- 💫 https://github.com/JaKooLit 💫 ---- */ ## # /* ---- 💫 https://github.com/JaKooLit 💫 ---- */ ##
# Playerctl # Playerctl
music_icon="$HOME/.config/swaync/icons/music.png" iconPath="/usr/share/icons/Qogir/24/actions"
nextIcon="$iconPath/gtk-media-next-ltr.svg"
previousIcon="$iconPath/gtk-media-previous-ltr.svg"
stopIcon="$iconPath/gtk-media-stop.svg"
playIcon="$iconPath/gtk-media-play-ltr.svg"
pauseIcon="$iconPath/gtk-media-pause.svg"
# Play the next track # Play the next track
play_next() { play_next() {
playerctl next playerctl next
show_music_notification show_music_notification next
} }
# Play the previous track # Play the previous track
play_previous() { play_previous() {
playerctl previous playerctl previous
show_music_notification show_music_notification previous
} }
# Toggle play/pause # Toggle play/pause
toggle_play_pause() { toggle_play_pause() {
playerctl play-pause playerctl play-pause
show_music_notification show_music_notification toggle
} }
# Stop playback # Stop playback
stop_playback() { stop_playback() {
playerctl stop playerctl stop
notify-send -e -u low -i $music_icon " Playback:" " Stopped" notify-send -e -u low -i $stopIcon " Playback:" " Stopped"
} }
# Display notification with song information # Display notification with song information
show_music_notification() { show_music_notification() {
sleep 0.5s sleep 0.5s
status=$(playerctl status) status=$(playerctl status)
icon=""
case "$1" in
"next")
icon=$nextIcon
;;
"previous")
icon=$previousIcon
;;
"toggle")
if [[ "$status" == "Paused" ]]; then
icon=$pauseIcon
else
icon=$playIcon
fi
;;
esac
if [[ "$status" == "Playing" ]]; then if [[ "$status" == "Playing" ]]; then
song_title=$(playerctl metadata title) song_title=$(playerctl metadata title)
song_artist=$(playerctl metadata artist) song_artist=$(playerctl metadata artist)
notify-send -e -u low -i $music_icon "Now Playing:" "$song_title by $song_artist" notify-send -e -u low -i $icon "Now Playing:" "$song_title by $song_artist"
elif [[ "$status" == "Paused" ]]; then elif [[ "$status" == "Paused" ]]; then
notify-send -e -u low -i $music_icon " Playback:" " Paused" notify-send -e -u low -i $icon " Playback:" " Paused"
fi fi
} }

View file

@ -2,7 +2,7 @@
# /* ---- 💫 https://github.com/JaKooLit 💫 ---- */ ## # /* ---- 💫 https://github.com/JaKooLit 💫 ---- */ ##
# Scripts for volume controls for audio and mic # Scripts for volume controls for audio and mic
iDIR="$HOME/.config/swaync/icons" iDIR="/usr/share/icons/Qogir/24/actions"
sDIR="$HOME/.config/hypr/scripts" sDIR="$HOME/.config/hypr/scripts"
# Get Volume # Get Volume
@ -19,13 +19,13 @@ get_volume() {
get_icon() { get_icon() {
current=$(get_volume) current=$(get_volume)
if [[ "$current" == "Muted" ]]; then if [[ "$current" == "Muted" ]]; then
echo "$iDIR/volume-mute.png" echo "$iDIR/audio-volume-muted.svg"
elif [[ "${current%\%}" -le 30 ]]; then elif [[ "${current%\%}" -le 30 ]]; then
echo "$iDIR/volume-low.png" echo "$iDIR/audio-volume-low.svg"
elif [[ "${current%\%}" -le 60 ]]; then elif [[ "${current%\%}" -le 60 ]]; then
echo "$iDIR/volume-mid.png" echo "$iDIR/audio-volume-medium.svg"
else else
echo "$iDIR/volume-high.png" echo "$iDIR/audio-volume-high.svg"
fi fi
} }
@ -60,7 +60,7 @@ dec_volume() {
# Toggle Mute # Toggle Mute
toggle_mute() { toggle_mute() {
if [ "$(pamixer --get-mute)" == "false" ]; then if [ "$(pamixer --get-mute)" == "false" ]; then
pamixer -m && notify-send -e -u low -i "$iDIR/volume-mute.png" " Mute" pamixer -m && notify-send -e -u low -i "$iDIR/audio-volume-muted.svg" " Mute"
elif [ "$(pamixer --get-mute)" == "true" ]; then elif [ "$(pamixer --get-mute)" == "true" ]; then
pamixer -u && notify-send -e -u low -i "$(get_icon)" " Volume:" " Switched ON" pamixer -u && notify-send -e -u low -i "$(get_icon)" " Volume:" " Switched ON"
fi fi

View file

@ -31,5 +31,6 @@ if [ $XDG_SESSION_DESKTOP = "Hyprland" ]; then
darkman \ darkman \
anyrun-git \ anyrun-git \
hyprshade-git \ hyprshade-git \
posy-improved-cursors posy-improved-cursors \
pamixer
fi fi

View file

@ -112,8 +112,6 @@ let g:WhichKeyDesc_errors_prev = "<leader>ep Go to previous error in solution"
"" Key mappings "" Key mappings
"" ======================================================== "" ========================================================
inoremap jj <Esc>
" Tab navigation " Tab navigation
nnoremap <S-l> :tabnext<CR> nnoremap <S-l> :tabnext<CR>
nnoremap <S-h> :tabprev<CR> nnoremap <S-h> :tabprev<CR>
@ -180,7 +178,7 @@ map <leader>fl <action>(RecentLocations)
map <leader>fs <action>(NewScratchFile) map <leader>fs <action>(NewScratchFile)
" Close active tab " Close active tab
map <leader>q <action>(CloseContent) map q <action>(CloseContent)
" Refactoring " Refactoring
map <leader>rn <Action>(RenameElement) map <leader>rn <Action>(RenameElement)