diff --git a/dotfiles/config/xmonad/xmonad.hs b/dotfiles/config/xmonad/xmonad.hs index f41efd79..95468e81 100644 --- a/dotfiles/config/xmonad/xmonad.hs +++ b/dotfiles/config/xmonad/xmonad.hs @@ -461,7 +461,6 @@ myReplaceWindow = -- Workspace Names for EWMH - setWorkspaceNames :: X () setWorkspaceNames = withWindowSet $ \s -> withDisplay $ \dpy -> do sort' <- getSortByIndex @@ -865,6 +864,10 @@ goToNextScreenX = windows goToNextScreen -- Key bindings +volumeUp = spawn "set_volume.sh --unmute --change-volume +5" +volumeDown = spawn "set_volume.sh --unmute --change-volume -5" +mute = spawn "set_volume.sh --toggle-mute" + shiftToEmptyOnScreen direction = followingWindow (windowToScreen direction True) >> shiftToEmptyAndView @@ -907,7 +910,7 @@ addKeys conf@XConfig { modMask = modm } = , ((modalt, xK_Return), deactivateFullAnd restoreAllMinimized) , ((modm .|. controlMask, xK_t), setReplaceTarget >> spawn "chromix-too open chrome://newtab") - , ((mod .|. controlMask, xK_c), chromeReplaceKill) + , ((modm .|. controlMask, xK_c), chromeReplaceKill) , ((hyper, xK_g), gatherThisClass) -- Directional navigation @@ -1005,12 +1008,12 @@ addKeys conf@XConfig { modMask = modm } = , ((0, xF86XK_AudioPrev), spawn "playerctl previous") -- Volume control - , ((0, xF86XK_AudioRaiseVolume), spawn "set_volume.sh up") - , ((0, xF86XK_AudioLowerVolume), spawn "set_volume.sh down") - , ((0, xF86XK_AudioMute), spawn "set_volume.sh mute") - , ((modm, xK_i), spawn "set_volume.sh up") - , ((modm, xK_k), spawn "set_volume.sh down") - , ((modm, xK_u), spawn "set_volume.sh mute") + , ((0, xF86XK_AudioRaiseVolume), volumeUp) + , ((0, xF86XK_AudioLowerVolume), volumeDown) + , ((0, xF86XK_AudioMute), mute) + , ((modm, xK_i), volumeUp) + , ((modm, xK_k), volumeDown) + , ((modm, xK_u), mute) , ((hyper .|. shiftMask, xK_q), spawn "toggle_mute_current_window.sh") , ((hctrl, xK_q), spawn "toggle_mute_current_window.sh only") diff --git a/dotfiles/lib/bin/set_volume.sh b/dotfiles/lib/bin/set_volume.sh index b2771cc6..f89dedd3 100755 --- a/dotfiles/lib/bin/set_volume.sh +++ b/dotfiles/lib/bin/set_volume.sh @@ -10,7 +10,8 @@ function switch_sink_applications() } current_default=$(pahelper.sh list | grep '*' | all_after_char ":" | xargs) -environment_variable_exists USE_ONLY_ONE_PASINK && pahelper.sh "$current_default" +environment_variable_exists USE_ONLY_O_PASINK && pahelper.sh "$current_default" -pulseaudio-ctl "$@" +# XXX: this does not prevent volumes higher than 100 +pulsemixer "$@" pashowvolume diff --git a/dotfiles/lib/setup_functions.sh b/dotfiles/lib/setup_functions.sh index e98a4d67..4c9a753f 100644 --- a/dotfiles/lib/setup_functions.sh +++ b/dotfiles/lib/setup_functions.sh @@ -60,7 +60,6 @@ function get_linux_distro { return 1 } - function is_osx() { if command_exists uname; then case `uname` in @@ -82,3 +81,7 @@ function source_directory_files { source "$filename" done } + +function min { + [ $1 -le $2 ] && echo "$1" || echo "$2" +} diff --git a/dotfiles/lib/shellenv/linux.sh b/dotfiles/lib/shellenv/linux.sh index 95c74d59..3fc459e6 100644 --- a/dotfiles/lib/shellenv/linux.sh +++ b/dotfiles/lib/shellenv/linux.sh @@ -13,7 +13,7 @@ pasink() { pavolume () { pacmd list-sinks | awk '/^\s+name: /{indefault = $2 == "<'"$(pasink)"'>"} - /^\s+volume: / && indefault {print $5; exit}' + /^\s+volume: / && indefault {print $5; exit}' | grep -Eo "[0-9]*" } paismuted () { @@ -24,7 +24,7 @@ pashowvolume () { if paismuted; then volnoti-show -m else - volnoti-show "$(pavolume)" + volnoti-show "$(min $(pavolume) 100)" fi }