diff options
| author | Thomas Ulmer <thomasmulmer02@gmail.com> | 2026-02-04 14:24:16 -0800 |
|---|---|---|
| committer | Thomas Ulmer <thomasmulmer02@gmail.com> | 2026-02-04 14:24:16 -0800 |
| commit | 9139a1b136fa2b5adfcac0ac09a4f61aa1ee1ff4 (patch) | |
| tree | de82bc4776b87f1fbb86f14b4a15d35d009ddd28 /config/xmonad/xmonad.hs | |
| parent | a9bf8f30c746f5b28bb7eb6938e8390127081a32 (diff) | |
full reorg
Diffstat (limited to 'config/xmonad/xmonad.hs')
| -rw-r--r-- | config/xmonad/xmonad.hs | 243 |
1 files changed, 243 insertions, 0 deletions
diff --git a/config/xmonad/xmonad.hs b/config/xmonad/xmonad.hs new file mode 100644 index 0000000..77dc3be --- /dev/null +++ b/config/xmonad/xmonad.hs @@ -0,0 +1,243 @@ +import XMonad +import Data.Monoid +import System.Exit + +import qualified XMonad.StackSet as W +import qualified Data.Map as M + +import XMonad.Util.NamedWindows (getName) + +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 XMonad.Layout.ResizableThreeColumns +import qualified XMonad.Layout.BoringWindows as BW + +myBringerConfig :: WindowBringerConfig +myBringerConfig = WindowBringerConfig + { menuCommand = "dmenu" + , menuArgs = ["-i"] + , windowTitler = decorateName + , windowFilter = \_ -> return True + } + where decorateName ws w = do + name <- show <$> getName w + return $ name ++ " [" ++ W.tag ws ++ "]" + +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 myLauncher) + , ((modm, xK_e ), spawn myBrowser) + , ((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 ), gotoMenuConfig myBringerConfig) + , ((modm .|. shiftMask, xK_b ), bringMenuConfig myBringerConfig) + + , ((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) + , ((modm .|. shiftMask, xK_h ), sendMessage MirrorShrink) + , ((modm .|. shiftMask, xK_l ), sendMessage MirrorExpand) + + -- 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 Full ||| smartBorders threeCol ||| smartBorders tiled + where + threeCol = ResizableThreeCol nmaster delta (1/3) [] + tiled = Tall nmaster delta (3/5) + nmaster = 1 + 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 = 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 + } |
