diff --git a/modules/wm/xmonad/config.hs b/modules/wm/xmonad/config.hs index 4943790..0287136 100644 --- a/modules/wm/xmonad/config.hs +++ b/modules/wm/xmonad/config.hs @@ -10,6 +10,8 @@ import XMonad.Hooks.EwmhDesktops import XMonad.Hooks.SetWMName import qualified XMonad.Hooks.ManageDocks as Docks import qualified XMonad.Util.EZConfig as EZ + +import Numeric.Natural import Control.Monad (when) import Text.Printf (printf) import System.Posix.Process (executeFile) @@ -41,6 +43,26 @@ myLayout = borderResize $ Docks.avoidStruts $ layout main :: IO () main = getDirectories >>= launch myConfig +-- change size of window using direction so that it can be used together with the navigation2D function +-- see: similar to windowGo and windowSwap +windowMoveSplit :: Direction2D -> Bool -> X () +windowMoveSplit direction _ = sendMessage $ MoveSplit direction + +data VolumeCommand = ToggleVolume + | LowerVolume Natural + | RaiseVolume Natural + +interpretVolumeCommand :: VolumeCommand -> String +interpretVolumeCommand command = "amixer -q set Master " <> cmd + where + cmd = case command of + ToggleVolume -> "toggle" + LowerVolume delta -> show delta <> "%-" + RaiseVolume delta -> show delta <> "%+" + +changeVolume :: VolumeCommand -> X () +changeVolume = spawn . interpretVolumeCommand + myConfig = ewmhFullscreen $ ewmh $ Docks.docks $ nav $ def { modMask = mod4Mask -- Use Super instead of Alt , terminal = "alacritty" @@ -61,21 +83,27 @@ myConfig = ewmhFullscreen $ ewmh $ Docks.docks $ nav $ def , ("M-l", WS.toggleWS) , ("M-g", WS.prevWS) , ("M-r", WS.nextWS) + + -- backlight control + , ("", spawn "xbacklight -dec 5") , ("", spawn "xbacklight -inc 5") , ("", spawn "xbacklight -dec 5") , ("", spawn "xbacklight -inc 5") - , ("M-S-c", sendMessage $ MoveSplit U) - , ("M-S-h", sendMessage $ MoveSplit L) - , ("M-S-t", sendMessage $ MoveSplit D) - , ("M-S-n", sendMessage $ MoveSplit R) + + -- volume control + + , ("", changeVolume ToggleVolume) + , ("", changeVolume $ LowerVolume 5) + , ("", changeVolume $ RaiseVolume 5) + , ("M-a", sendMessage Balance) , ("M-S-a", sendMessage Equalize) , ("M-o", sendMessage Rotate) ] where -- navigate using dvorak bindings - nav = navigation2DP def ("c", "h", "t", "n") [("M-", windowGo), ("M-C-", windowSwap)] True + nav = navigation2DP def ("c", "h", "t", "n") [("M-", windowGo), ("M-C-", windowSwap), ("M-S-", windowMoveSplit)] True appLauncher = "rofi -show combi -modes combi -combi-modes window,drun,run,ssh" passLauncher = "rofi-pass"