Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {-# OPTIONS_GHC -Wno-missing-signatures #-}
- import qualified Data.Map as M
- import System.Exit (exitSuccess)
- import XMonad
- ( button1,
- button2,
- button3,
- controlMask,
- mod4Mask,
- shiftMask,
- xK_1,
- xK_9,
- xK_KP_Begin,
- xK_KP_Down,
- xK_KP_End,
- xK_KP_Home,
- xK_KP_Insert,
- xK_KP_Left,
- xK_KP_Page_Down,
- xK_KP_Page_Up,
- xK_KP_Right,
- xK_KP_Up,
- xK_Return,
- xK_Tab,
- xK_b,
- xK_c,
- xK_comma,
- xK_e,
- xK_h,
- xK_j,
- xK_k,
- xK_l,
- xK_m,
- xK_n,
- xK_p,
- xK_period,
- xK_q,
- xK_r,
- xK_slash,
- xK_space,
- xK_t,
- xK_w,
- xK_x,
- xK_z,
- io,
- spawn,
- whenJust,
- (|||),
- xmonad,
- (<+>),
- (=?),
- className,
- doFloat,
- doF,
- doIgnore,
- title,
- focus,
- kill,
- mouseMoveWindow,
- mouseResizeWindow,
- refresh,
- screenWorkspace,
- sendMessage,
- setLayout,
- windows,
- withFocused,
- (.|.),
- Default(def),
- XConfig(XConfig, terminal, focusFollowsMouse, clickJustFocuses,
- borderWidth, modMask, workspaces, normalBorderColor,
- focusedBorderColor, keys, mouseBindings, layoutHook, manageHook,
- handleEventHook, logHook, startupHook),
- ChangeLayout(NextLayout),
- Full(Full),
- IncMasterN(IncMasterN),
- Mirror(Mirror),
- Resize(Expand, Shrink),
- Tall(Tall) )
- import XMonad.Actions.WorkspaceNames
- ( renameWorkspace, workspaceNamesPP )
- import XMonad.Hooks.DynamicLog
- ( PP
- ( ppLayout,
- ppSort,
- ppTitle,
- ppTitleSanitize,
- ppVisible,
- ppOutput
- ),
- xmobarPP,
- dynamicLogWithPP
- )
- import XMonad.Hooks.EwmhDesktops (ewmh, ewmhFullscreen)
- import XMonad.Hooks.ManageDocks
- ( ToggleStruts (..),
- avoidStruts,
- manageDocks,
- docks, AvoidStruts
- )
- import XMonad.Hooks.ManageHelpers
- ( composeOne,{-# LANGUAGE ScopedTypeVariables #-}{-# LANGUAGE ScopedTypeVariables #-}{-# LANGUAGE ScopedTypeVariables #-}
- isDialog,
- transience,
- (-?>),
- )
- import XMonad.Layout.SimpleFloat
- import XMonad.Layout.MultiColumns (multiCol, MultiCol)
- import XMonad.Layout.Tabbed (simpleTabbed, TabbedDecoration)
- import XMonad.Layout.ThreeColumns (ThreeCol (ThreeCol, ThreeColMid))
- import XMonad.Prompt
- ( XPPosition (Bottom),
- alwaysHighlight,
- bgColor,
- font,
- height,
- position,
- promptBorderWidth, XPConfig,
- )
- import XMonad.Prompt.ConfirmPrompt (confirmPrompt)
- import XMonad.Prompt.Shell (shellPrompt)
- import qualified XMonad.StackSet as W
- import XMonad.Util.Run ( hPutStrLn, spawnPipe )
- import XMonad.Util.WorkspaceCompare ()
- import qualified XMonad as Graphics.X11.Types
- import qualified XMonad.Layout.Decoration
- import qualified XMonad.Layout.Simplest
- import XMonad.Layout.PerWorkspace (modWorkspace, onWorkspace)
- import qualified GHC.IO.Handle.Types
- myFocusFollowsMouse :: Bool
- myClickJustFocuses :: Bool
- myModMask :: Graphics.X11.Types.KeyMask
- myWorkspaces :: [String]
- myNormalBorderColor :: String
- myFocusedBorderColor :: String
- myBorderWidth :: Graphics.X11.Types.Dimension
- myTerminal :: String
- myKeys :: XConfig Graphics.X11.Types.Layout -> M.Map
- (Graphics.X11.Types.KeyMask, Graphics.X11.Types.KeySym)
- (Graphics.X11.Types.X ())
- myXPConfig :: XMonad.Prompt.XPConfig
- numPadKeys :: [Graphics.X11.Types.KeySym]
- myMouseBindings :: XConfig l -> M.Map
- (Graphics.X11.Types.KeyMask, Graphics.X11.Types.Button)
- (Graphics.X11.Types.Window -> Graphics.X11.Types.X ())
- myManageHook :: Graphics.X11.Types.ManageHook
- myStartupHook :: Graphics.X11.Types.X ()
- main :: IO ()
- myLogHook :: GHC.IO.Handle.Types.Handle -> Graphics.X11.Types.X ()
- myFocusFollowsMouse = True
- myClickJustFocuses = False
- myModMask = mod4Mask
- myWorkspaces = ["1", "2", "3", "4", "5", "6", "7", "8", "9"]
- myNormalBorderColor = "#be2596"
- myFocusedBorderColor = "#2596be"
- myBorderWidth = 2
- myTerminal = "urxvt"
- myXPConfig =
- def
- { position = Bottom,
- alwaysHighlight = True,
- promptBorderWidth = 1,
- font = "-addy-rissole-*-*-*-*-24-*-*-*-*-*-*-*",
- height = 35,
- bgColor = "#8d32ca"
- }
- myKeys conf@(XConfig {XMonad.modMask = modm}) =
- M.fromList $
- [ ((modm .|. shiftMask, xK_Return), spawn $ XMonad.terminal conf),
- ((modm, xK_z), spawn "emacsclient -c"),
- ((modm, xK_x), spawn "vscodium"),
- ((modm .|. shiftMask, xK_p), spawn "gmrun"),
- ((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, xK_t), withFocused $ windows . W.sink),
- ((modm, xK_comma), sendMessage (IncMasterN 1)),
- ((modm, xK_period), sendMessage (IncMasterN (-1))),
- ((modm, xK_b), sendMessage ToggleStruts),
- ((modm, xK_q), spawn "xmonad --recompile; xmonad --restart"),
- ((modm .|. shiftMask, xK_slash), spawn ("echo \"" ++ help ++ "\" | xmessage -file -")),
- ((modm .|. shiftMask, xK_q), confirmPrompt myXPConfig "exit" (io exitSuccess)),
- ((modm .|. shiftMask, xK_l), spawn "xscreensaver-command -lock"),
- ((modm .|. controlMask, xK_l), spawn "xscreensaver-command -lock; sleep 1; xset dpms force off"),
- ((modm, xK_p), shellPrompt myXPConfig)
- ]
- ++
- --
- -- 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)]
- ]
- ++
- -- Numpad moving and switching
- [ ((m .|. modm, k), windows $ f i)
- | (i, k) <- zip (XMonad.workspaces conf) numPadKeys,
- (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]
- ]
- ++
- --
- -- mod-{w,e,r}, Switch to physical/Xinerama screens 1, 2, or 3
- -- mod-shift-{w,e,r}, Move client to screen 1, 2, or 3
- --
- [ ((m .|. modm, key), screenWorkspace sc >>= flip whenJust (windows . f))
- | -- This is normal
- (key, sc) <- zip [xK_e, xK_r, xK_w] [0 ..],
- -- Swapped w and e because of confusion between nVidia settings for primary and what xmonad sees from xinerama/xrandr
- -- \| (key, sc) <- zip [xK_e, xK_w, xK_r] [0..]
- (f, m) <- [(W.view, 0), (W.shift, shiftMask)]
- ]
- ++
- [((modm .|. shiftMask, xK_r), renameWorkspace def)]
- numPadKeys =
- [ xK_KP_End,
- xK_KP_Down,
- xK_KP_Page_Down, -- 1, 2, 3
- xK_KP_Left,
- xK_KP_Begin,
- xK_KP_Right, -- 4, 5, 6
- xK_KP_Home,
- xK_KP_Up,
- xK_KP_Page_Up, -- 7, 8, 9
- xK_KP_Insert -- 0
- ]
- myMouseBindings (XConfig {XMonad.modMask = modm}) =
- M.fromList
- [ ( (modm, button1),
- \w ->
- focus w
- >> mouseMoveWindow w
- >> windows W.shiftMaster
- ),
- ( (modm, button3),
- \w ->
- focus w
- >> mouseResizeWindow w
- >> windows W.shiftMaster
- )
- ]
- myLayout =
- avoidStruts $
- onWorkspace "2" Full $
- onWorkspace "7" simpleTabbed $
- onWorkspace "8" Full $
- onWorkspace "9" simpleTabbed $
- tiled
- ||| Mirror tiled
- ||| Full
- ||| multiCol [1] 1 0.01 (-0.5)
- ||| ThreeCol nmaster delta (1 / 3) -- Many equal columns!
- ||| ThreeColMid nmaster delta ratio -- Three equal columns with resizing
- ||| simpleTabbed
- ||| simpleFloat
- where
- tiled = Tall nmaster delta ratio
- nmaster = 1
- ratio = 1 / 4
- delta = 3 / 100
- myManageHook =
- manageDocks
- <+> composeOne
- [ className =? "Godot" -?> doFloat,
- title =? "PSUBLIM" -?> doIgnore,
- isDialog -?> doFloat,
- -- Move transient windows to their parent:
- transience,
- className =? "discord" -?> doF (W.shift (myWorkspaces !! 5)),
- className =? "Slack" -?> doF (W.shift (myWorkspaces !! 5)),
- className =? "ripcord" -?> doF (W.shift (myWorkspaces !! 5)),
- className =? "libreoffice-startcenter" -?> doF (W.shift (myWorkspaces !! 6)),
- className =? "Spotify" -?> doF (W.shift (myWorkspaces !! 7)),
- className =? "FileZilla" -?> doF (W.shift (myWorkspaces !! 8))
- ]
- myEventHook = handleEventHook def
- myStartupHook = do
- spawn ""
- main = do
- pipe <- spawnPipe "xmobar"
- xmonad $ ewmhFullscreen . ewmh $ docks (defaults pipe)
- myLogHook pipe =
- workspaceNamesPP XMonad.Hooks.DynamicLog.xmobarPP {
- ppOutput = hPutStrLn pipe
- }
- >>= XMonad.Hooks.DynamicLog.dynamicLogWithPP
- defaults pipe =
- def
- {
- terminal = myTerminal,
- focusFollowsMouse = myFocusFollowsMouse,
- clickJustFocuses = myClickJustFocuses,
- borderWidth = myBorderWidth,
- modMask = myModMask,
- workspaces = myWorkspaces,
- normalBorderColor = myNormalBorderColor,
- focusedBorderColor = myFocusedBorderColor,
- -- key bindings
- keys = myKeys,
- mouseBindings = myMouseBindings,
- -- hooks, layouts
- layoutHook = myLayout,
- manageHook = myManageHook,
- handleEventHook = myEventHook,
- logHook = myLogHook pipe,
- startupHook = myStartupHook
- }
- help :: String
- help =
- unlines
- [ "XMonad keybindings help",
- "",
- "The modifier key is 'super'. Keybindings:",
- "",
- "-- launching and killing programs",
- "mod-Shift-Enter Launch " ++ myTerminal,
- "mod-p Launch shell prompt",
- "mod-Shift-p Launch gmrun",
- "mod-Shift-c Close/kill the focused window",
- "mod-Space Rotate through the available layout algorithms",
- "mod-Shift-Space Reset the layouts on the current workSpace to default",
- "mod-n Resize/refresh viewed windows to the correct size",
- "mod-Shift-l Lock workstation with xscreensaver",
- "",
- "-- move focus up or down the window stack",
- "mod-Tab Move focus to the next window",
- "mod-Shift-Tab Move focus to the previous window",
- "mod-j Move focus to the next window",
- "mod-k Move focus to the previous window",
- "mod-m Move focus to the master window",
- "",
- "-- modifying the window order",
- "mod-Return Swap the focused window and the master window",
- "mod-Shift-j Swap the focused window with the next window",
- "mod-Shift-k Swap the focused window with the previous window",
- "",
- "-- resizing the master/slave ratio",
- "mod-h Shrink the master area",
- "mod-l Expand the master area",
- "",
- "-- floating layer support",
- "mod-t Push window back into tiling; unfloat and re-tile it",
- "",
- "-- increase or decrease number of windows in the master area",
- "mod-comma (mod-,) Increment the number of windows in the master area",
- "mod-period (mod-.) Deincrement the number of windows in the master area",
- "",
- "-- quit, or restart",
- "mod-Shift-q Quit xmonad",
- "mod-q Restart xmonad",
- "",
- "-- Workspaces & screens",
- "mod-[1..9] Switch to workSpace N",
- "mod-Shift-[1..9] Move client to workspace N",
- "mod-{w,e,r} Switch to physical/Xinerama screens 1, 2, or 3",
- "mod-Shift-{w,e,r} Move client to screen 1, 2, or 3",
- "",
- "-- Mouse bindings: default actions bound to mouse events",
- "mod-button1 Set the window to floating mode and move by dragging",
- "mod-button2 Raise the window to the top of the stack",
- "mod-button3 Set the window to floating mode and resize by dragging",
- "",
- "-- Miscellaneous bindings",
- "mod-b Toggle the status bar gap",
- "mod-Shift-/ (mod-?) Show this help dialog"
- ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement