import XMonad import Data.Monoid import System.Exit import qualified XMonad.StackSet as W import qualified Data.Map as M import Graphics.X11.ExtraTypes.XF86 (xF86XK_AudioMute, xF86XK_AudioLowerVolume, xF86XK_AudioRaiseVolume, xF86XK_MonBrightnessDown, xF86XK_MonBrightnessUp) import XMonad.Hooks.StatusBar import XMonad.Hooks.StatusBar.PP import XMonad.Hooks.EwmhDesktops import XMonad.Hooks.ManageDocks (ToggleStruts(..)) import XMonad.Actions.WindowBringer import XMonad.Actions.Minimize (minimizeWindow, withLastMinimized, maximizeWindowAndFocus) import XMonad.Layout.NoBorders (noBorders, smartBorders) import XMonad.Layout.Minimize (minimize) import qualified XMonad.Layout.BoringWindows as BW myTerminal = "urxvt" myBrowser = "glide" myLauncher = "dmenu_run" myBrightnessDown = "brightnessdown" myBrightnessUp = "brightnessup" myVolumeDown = "pactl set-sink-volume @DEFAULT_SINK@ -5%" myVolumeUp = "pactl set-sink-volume @DEFAULT_SINK@ +5%" myVolumeMute = "pactl set-sink-mute @DEFAULT_SINK@ toggle" myFocusFollowsMouse :: Bool myFocusFollowsMouse = False myClickJustFocuses :: Bool myClickJustFocuses = False myBorderWidth = 1 myNormalBorderColor = "#bbbbbb" myFocusedBorderColor = "#6904f7" myModMask = mod4Mask myWorkspaces = ["1","2","3","4","5","6","7","8","9"] ------------------------------------------------------------------------ myKeys conf@(XConfig {XMonad.modMask = modm}) = M.fromList $ [ ((modm .|. shiftMask, xK_Return), spawn $ XMonad.terminal conf) , ((modm, xK_d ), spawn myBrowser) , ((modm, xK_e ), spawn myLauncher) , ((noModMask , xF86XK_AudioMute), spawn myVolumeMute) , ((noModMask , xF86XK_AudioLowerVolume), spawn myVolumeDown) , ((noModMask , xF86XK_AudioRaiseVolume), spawn myVolumeUp) , ((noModMask , xF86XK_MonBrightnessDown), spawn myBrightnessDown) , ((noModMask , xF86XK_MonBrightnessUp), spawn myBrightnessUp) , ((modm .|. shiftMask, xK_g ), gotoMenu) , ((modm .|. shiftMask, xK_b ), bringMenu) , ((modm .|. shiftMask, xK_c ), kill) , ((modm, xK_space ), sendMessage NextLayout) , ((modm .|. shiftMask, xK_space ), setLayout $ XMonad.layoutHook conf) , ((modm, xK_n ), refresh) , ((modm, xK_Tab ), windows W.focusDown) , ((modm, xK_j ), windows W.focusDown) , ((modm, xK_k ), windows W.focusUp) , ((modm, xK_m ), windows W.focusMaster) , ((modm, xK_Return), windows W.swapMaster) , ((modm .|. shiftMask, xK_j ), windows W.swapDown ) , ((modm .|. shiftMask, xK_k ), windows W.swapUp ) , ((modm, xK_h ), sendMessage Shrink) , ((modm, xK_l ), sendMessage Expand) -- floating -> tiling , ((modm, xK_t ), withFocused $ windows . W.sink) -- push and pop from the hidden window stack , ((modm, xK_backslash), withFocused minimizeWindow) , ((modm .|. shiftMask, xK_backslash), withLastMinimized maximizeWindowAndFocus) , ((modm , xK_comma ), sendMessage (IncMasterN 1)) , ((modm , xK_period), sendMessage (IncMasterN (-1))) , ((modm , xK_b ), sendMessage ToggleStruts) , ((modm .|. shiftMask, xK_q ), io exitSuccess) , ((modm , xK_q ), spawn "xmonad --recompile; xmonad --restart") ] ++ -- -- mod-[1..9], Switch to workspace N -- mod-shift-[1..9], Move client to workspace N -- [((m .|. modm, k), windows $ f i) | (i, k) <- zip (XMonad.workspaces conf) [xK_1 .. xK_9] , (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]] ++ -- -- mod-{u,i,o}, Switch to physical/Xinerama screens 1, 2, or 3 -- mod-shift-{u,i,o}, Move client to screen 1, 2, or 3 -- [((m .|. modm, key), screenWorkspace sc >>= flip whenJust (windows . f)) | (key, sc) <- zip [xK_u, xK_i, xK_o] [0..] , (f, m) <- [(W.view, 0), (W.shift, shiftMask)]] ------------------------------------------------------------------------ myMouseBindings (XConfig {XMonad.modMask = modm}) = M.fromList -- mod-button1, Set the window to floating mode and move by dragging [ ((modm, button1), \w -> focus w >> mouseMoveWindow w >> windows W.shiftMaster) -- mod-button2, Raise the window to the top of the stack , ((modm, button2), \w -> focus w >> windows W.shiftMaster) -- mod-button3, Set the window to floating mode and resize by dragging , ((modm, button3), \w -> focus w >> mouseResizeWindow w >> windows W.shiftMaster) -- you may also bind events to the mouse scroll wheel (button4 and button5) ] ------------------------------------------------------------------------ -- Layouts: myLayout = smartBorders tiled ||| noBorders Full where tiled = Tall nmaster delta ratio nmaster = 1 ratio = 3/5 delta = 2/100 ------------------------------------------------------------------------ -- Window rules: -- Execute arbitrary actions and WindowSet manipulations when managing -- a new window. You can use this to, for example, always float a -- particular program, or have a client always appear on a particular -- workspace. -- -- To find the property name associated with a program, use -- > xprop | grep WM_CLASS -- and click on the client you're interested in. -- -- To match on the WM_NAME, you can use 'title' in the same way that -- 'className' and 'resource' are used below. -- myManageHook = composeAll [ className =? "MPlayer" --> doFloat , className =? "mpv" --> doFloat , className =? "Gimp" --> doFloat , resource =? "desktop_window" --> doIgnore , resource =? "kdesktop" --> doIgnore ] ------------------------------------------------------------------------ -- Event handling -- * EwmhDesktops users should change this to ewmhDesktopsEventHook -- -- Defines a custom handler function for X Events. The function should -- return (All True) if the default handler is to be run afterwards. To -- combine event hooks use mappend or mconcat from Data.Monoid. -- myEventHook = ewmhDesktopsEventHook -- handleEventHook def ------------------------------------------------------------------------ -- Status bars and logging -- Perform an arbitrary action on each internal state change or X event. -- See the 'XMonad.Hooks.DynamicLog' extension for examples. -- myLogHook = return () ------------------------------------------------------------------------ -- Startup hook -- Perform an arbitrary action each time xmonad starts or is restarted -- with mod-q. Used by, e.g., XMonad.Layout.PerWorkspace to initialize -- per-workspace layout choices. -- -- By default, do nothing. myStartupHook = return () ------------------------------------------------------------------------ -- Status bar mySB = statusBarProp "xmobar" (pure xmobarPP) ------------------------------------------------------------------------ -- Now run xmonad with all the defaults we set up. -- Run xmonad with the settings you specify. No need to modify this. -- main = xmonad $ withEasySB mySB defToggleStrutsKey defaults -- A structure containing your configuration settings, overriding -- fields in the default config. Any you don't override, will -- use the defaults defined in xmonad/XMonad/Config.hs -- -- No need to modify this. -- defaults = ewmhFullscreen . ewmh $ def { terminal = myTerminal, focusFollowsMouse = myFocusFollowsMouse, clickJustFocuses = myClickJustFocuses, borderWidth = myBorderWidth, modMask = myModMask, workspaces = myWorkspaces, normalBorderColor = myNormalBorderColor, focusedBorderColor = myFocusedBorderColor, keys = myKeys, mouseBindings = myMouseBindings, layoutHook = minimize . BW.boringWindows $ myLayout, manageHook = myManageHook, handleEventHook = myEventHook, logHook = myLogHook, startupHook = myStartupHook }