diff options
| author | Cori Barker <coribarker2@gmail.com> | 2026-06-23 17:08:01 +0100 |
|---|---|---|
| committer | Cori Barker <coribarker2@gmail.com> | 2026-06-23 17:08:01 +0100 |
| commit | d332dd6bfc4c9716b500ddeb682845a2783da87b (patch) | |
| tree | 53e4982111d88d1f0349f16b56d7063bcb860986 | |
Initial Commitcori-laptop
| -rw-r--r-- | xmonad.hs | 201 |
1 files changed, 201 insertions, 0 deletions
diff --git a/xmonad.hs b/xmonad.hs new file mode 100644 index 0000000..da209dd --- /dev/null +++ b/xmonad.hs @@ -0,0 +1,201 @@ +-- xmonad.hs + +import XMonad +import XMonad.Hooks.DynamicLog +import XMonad.Hooks.ManageDocks +import XMonad.Hooks.ManageHelpers +import XMonad.Hooks.EwmhDesktops +import XMonad.Layout.NoBorders +import XMonad.Util.EZConfig (additionalKeysP) +import XMonad.Util.SpawnOnce +import XMonad.Util.Run (spawnPipe) + +import qualified XMonad.StackSet as W +import qualified Data.Map as M + +import System.IO (hPutStrLn, Handle) +import System.Exit (exitSuccess) +import System.Random (randomRIO) + +------------------------------------------------------------------------ +-- Basic settings +------------------------------------------------------------------------ + +myModMask :: KeyMask +myModMask = mod1Mask + +myTerminal :: String +myTerminal = "urxvtc" + +myBorderWidth :: Dimension +myBorderWidth = 1 + +myNormalBorderColor :: String +myNormalBorderColor = "#222222" + +myFocusedBorderColor :: String +myFocusedBorderColor = "#285577" + +myFocusFollowsMouse :: Bool +myFocusFollowsMouse = True + +------------------------------------------------------------------------ +-- Workspaces +------------------------------------------------------------------------ + +myWorkspaces :: [String] +myWorkspaces = map show [1..10] + +------------------------------------------------------------------------ +-- Layouts +------------------------------------------------------------------------ + +myLayout = avoidStruts $ smartBorders $ + tiled ||| Mirror tiled ||| Full + where + tiled = Tall nmaster delta ratio + nmaster = 1 + ratio = 1/2 + delta = 3/100 + +------------------------------------------------------------------------ +-- Manage hook +------------------------------------------------------------------------ + +myManageHook :: ManageHook +myManageHook = composeAll + [ isFullscreen --> doFullFloat ] <+> manageDocks + +------------------------------------------------------------------------ +-- Startup hook +------------------------------------------------------------------------ + +myStartupHook :: X () +myStartupHook = do + spawnOnce "picom" + spawnOnce "nitrogen --restore" + spawnOnce "nm-applet" + spawnOnce "pipewire" + spawnOnce "pipewire-pulse" + spawnOnce "pa-applet" + spawnOnce "xrdb -merge ~/.Xresources" + spawnOnce "xset r rate 300 50" + spawnOnce "xsetroot -cursor_name left_ptr" + spawnOnce "parcellite" + spawnOnce "flameshot" + spawnOnce "/opt/piavpn/bin/pia-client" + spawnOnce "dunst" + spawnOnce "~/.config/polybar/polybar-launch.sh" + spawnOnce "urxvtd -q -o -f" + spawnOnce "/usr/bin/emacs --daemon --init-dir ~/.config/emacs/" + +------------------------------------------------------------------------ +-- Key bindings +------------------------------------------------------------------------ + +myKeys :: [(String, X ())] +myKeys = + [ ("M-<Return>", spawn myTerminal) + , ("M-g", spawn "waterfox") + , ("M-t", spawn "pcmanfm") + , ("M-e", spawn "emacsclient -c") + , ("M-q", kill) + , ("M-d", spawn "dmenu_run -nb '#111111' -nf '#aaaaaa' -sb '#285577' -sf '#ffffff' -fn 'Fira Code-10'") + + , ("M-S-c", spawn "xmonad --recompile && xmonad --restart") + , ("M-S-r", spawn "xmonad --restart") + , ("M-S-e", io exitSuccess) + , ("M-S-x", spawn "xsecurelock") + + , ("M-j", windows W.focusDown) + , ("M-k", windows W.focusUp) + , ("M-h", windows W.focusMaster) + , ("M-l", windows W.focusDown) + + , ("M-S-j", windows W.swapDown) + , ("M-S-k", windows W.swapUp) + , ("M-S-h", windows W.swapMaster) + , ("M-S-l", windows W.swapDown) + + , ("M-r h", sendMessage Shrink) + , ("M-r l", sendMessage Expand) + + , ("M-,", sendMessage (IncMasterN 1)) + , ("M-.", sendMessage (IncMasterN (-1))) + + , ("M-s", sendMessage NextLayout) + , ("M-S-<Space>", withFocused toggleFloat) + , ("M-<Space>", windows W.focusMaster) + , ("M-f", withFocused (windows . W.sink) >> sendMessage NextLayout) + + , ("<Print>", spawn "flameshot full -p ~/Pictures") + + , ("<XF86AudioRaiseVolume>", spawn "pamixer --increase 5") + , ("<XF86AudioLowerVolume>", spawn "pamixer --decrease 5") + , ("<XF86AudioMute>", spawn "pamixer --toggle-mute") + + , ("<XF86MonBrightnessUp>", spawn "brightnessctl set +10%") + , ("<XF86MonBrightnessDown>", spawn "brightnessctl set 10%-") + ] + ++ + [ ("M-" ++ key, windows $ W.greedyView ws) + | (key, ws) <- zip (map show [1..9] ++ ["0"]) myWorkspaces + ] + ++ + [ ("M-S-" ++ key, windows $ W.shift ws) + | (key, ws) <- zip (map show [1..9] ++ ["0"]) myWorkspaces + ] + +toggleFloat :: Window -> X () +toggleFloat w = do + isFloat <- gets (M.member w . W.floating . windowset) + if isFloat + then windows $ W.sink w + else float w + +------------------------------------------------------------------------ +-- Polybar log hook +------------------------------------------------------------------------ + +myLogHook :: Handle -> X () +myLogHook fifo = dynamicLogWithPP $ def + { ppOutput = hPutStrLn fifo + , ppSep = " " + , ppTitleSanitize = xmobarStrip + , ppCurrent = wrap "%{B#285577}%{F#ffffff} " " %{F-}%{B-}" + , ppHidden = wrap "%{F#b0b0b0} " " %{F-}" + , ppHiddenNoWindows = wrap "%{F#555555} " " %{F-}" + , ppUrgent = wrap "%{B#cc4444}%{F#ffffff} " " %{F-}%{B-}" + , ppTitle = wrap "%{F#c0c0c0}" "%{F-}" . shorten 40 + , ppLayout = wrap "%{F#909090}[" "]%{F-}" . \l -> case l of + "Tall" -> "T" + "Mirror Tall" -> "M" + "Full" -> "F" + _ -> "?" + } + +------------------------------------------------------------------------ +-- Main +------------------------------------------------------------------------ + +main :: IO () +main = do + fifo <- spawnPipe "cat > /tmp/xmonad-log" + xmonad + . ewmhFullscreen + . ewmh + . docks + $ def + { modMask = myModMask + , terminal = myTerminal + , borderWidth = myBorderWidth + , normalBorderColor = myNormalBorderColor + , focusedBorderColor = myFocusedBorderColor + , focusFollowsMouse = myFocusFollowsMouse + , workspaces = myWorkspaces + , layoutHook = myLayout + , manageHook = myManageHook + , startupHook = myStartupHook + , logHook = myLogHook fifo + } + `additionalKeysP` myKeys
\ No newline at end of file |
