Guest User

Untitled

a guest
Jun 25th, 2022
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Haskell 14.64 KB | None | 0 0
  1. -- xmonad.hs
  2. -- xmonad example config file.
  3.  
  4. -- A template showing all available configuration hooks,
  5. -- and how to override the defaults in your own xmonad.hs conf file.
  6.  
  7. -- Normally, you'd only override those defaults you care about.
  8.  
  9. -- SPECIAL
  10. -- import XMonad.Layout.DecorationMadness
  11. -- import XMonad.Actions.EasyMotion (selectWindow)
  12.  
  13. import Control.Applicative
  14. import Control.Monad
  15. import qualified Data.Map as M
  16. import Data.Maybe
  17. import Data.Monoid
  18. import Graphics.X11.ExtraTypes.XF86
  19. import System.Exit
  20. import XMonad
  21. import XMonad.Actions.CycleWS
  22. import XMonad.Actions.DwmPromote
  23. import XMonad.Actions.SwapPromote
  24. import XMonad.Hooks.DynamicLog
  25. import XMonad.Hooks.RefocusLast
  26. import XMonad.Hooks.RefocusLast as R
  27. import XMonad.Layout.NoBorders
  28. import XMonad.Layout.Reflect (reflectHoriz)
  29. import XMonad.ManageHook
  30. import qualified XMonad.StackSet as W
  31. import XMonad.Util.EZConfig (additionalKeys)
  32. import qualified XMonad.Util.Hacks as Hacks
  33. import XMonad.Util.NamedScratchpad
  34. import XMonad.Util.Stack
  35.  
  36. -- The preferred terminal program, which is used in a binding below and by
  37. -- certain contrib modules.
  38. --
  39. myTerminal = "alacritty"
  40.  
  41. -- Whether focus follows the mouse pointer.
  42. myFocusFollowsMouse :: Bool
  43. myFocusFollowsMouse = True
  44.  
  45. -- Whether clicking on a window to focus also passes the click to the window
  46. myClickJustFocuses :: Bool
  47. myClickJustFocuses = False
  48.  
  49. -- Width of the window border in pixels.
  50. --
  51. myBorderWidth = 3
  52.  
  53. -- modMask lets you specify which modkey you want to use. The default
  54. -- is mod1Mask ("left alt").  You may also consider using mod3Mask
  55. -- ("right alt"), which does not conflict with emacs keybindings. The
  56. -- "windows key" is usually mod4Mask.
  57. --
  58. myModMask = mod4Mask
  59.  
  60. rofi_launch = spawn "rofi -no-lazy-grab -show drun -modi run,drun,window -theme $HOME/.config/rofi/launcher/style -drun-icon-theme \'papirus\' "
  61.  
  62. -- The default number of workspaces (virtual screens) and their names.
  63. -- By default we use numeric strings, but any string may be used as a
  64. -- workspace name. The number of workspaces is determined by the length
  65. -- of this list.
  66. --
  67. -- A tagging example:
  68. --
  69. -- > workspaces = ["web", "irc", "code" ] ++ map show [4..9]
  70. --
  71. myWorkspaces = ["1", "2", "3", "4", "5", "6", "7", "8", "9"]
  72.  
  73. -- Border colors for unfocused and focused windows, respectively.
  74. --
  75. myNormalBorderColor = "#000000"
  76.  
  77. myFocusedBorderColor = "#00ffff"
  78.  
  79. ------------------------------------------------------------------------
  80.  
  81. scratchpads =
  82.   [ -- (className =? "htop")/(title =? "htop")
  83.     NS
  84.       "htop"
  85.       "alacritty -t htop -e htop"
  86.       (title =? "htop")
  87.       -- defaultFloating ,
  88.       (customFloating $ W.RationalRect (2 / 7) (1 / 9) (2 / 5) (2 / 4)),
  89.       --                                  x       y       l       h
  90.     NS
  91.       "qBittorrent"
  92.       "qbittorrent"
  93.       (className =? "qBittorrent")
  94.       -- defaultFloating ,
  95.       (customFloating $ W.RationalRect (2 / 7) (1 / 9) (2 / 5) (2 / 4)),
  96.       --                                  x       y       l       h
  97.     NS
  98.       "scratch"
  99.       "alacritty -t scratch -e lvim ~/.scratch.md ~/.todo.md ~/.ideas.md ~/.reference.md"
  100.       (title =? "scratch")
  101.       (customFloating $ W.RationalRect (2 / 6) (1 / 9) (2 / 5) (2 / 4)),
  102.       --                                  x       y       l       h
  103.     NS
  104.       "nmtui"
  105.       "alacritty -t nmtui -e nmtui"
  106.       (title =? "nmtui")
  107.       (customFloating $ W.RationalRect (2 / 6) (1 / 9) (1 / 6) (2 / 4)),
  108.       --                                  x       y       l       h
  109.     NS
  110.       "tags"
  111.       "alacritty -t tags -e tags"
  112.       (title =? "tags")
  113.       (customFloating $ W.RationalRect (2 / 5) (2 / 9) (2 / 9) (2 / 5)),
  114.       --                                  x       y       l       h
  115.     NS "notes" "gvim --role notes ~/notes.txt" (role =? "notes") nonFloating
  116.   ]
  117.   where
  118.     role = stringProperty "WM_WINDOW_ROLE"
  119.  
  120. -- myFocusMaster :: X ()
  121. -- myFocusMaster = withWindowSet $ \wset ->
  122. --   case W.index wset of
  123. --     [] -> pure ()
  124. --     (x : _) ->
  125. --       if Just x == W.peek wset
  126. --         then toggleFocus
  127. --         else windows W.focusMaster
  128.  
  129. ------------------------------------------------------------------------
  130. -- Key bindings. Add, modify or remove key bindings here.
  131. --
  132. myKeys conf@(XConfig {XMonad.modMask = modm}) =
  133.   M.fromList $
  134.     [ ((0, xF86XK_AudioMute), spawn "amixer set Master toggle"),
  135.       ((0, xF86XK_AudioLowerVolume), spawn "amixer set Master 3%-"),
  136.       ((0, xF86XK_AudioRaiseVolume), spawn "amixer set Master 3%+"),
  137.       ((0, xF86XK_MonBrightnessUp), spawn "brightnessctl set 3%+"),
  138.       ((0, xF86XK_MonBrightnessDown), spawn "brightnessctl set 3%-"),
  139.       ((modm, xK_w), spawn "brave"),
  140.       ((modm, xK_r), rofi_launch),
  141.       ((modm .|. shiftMask, xK_r), refresh),
  142.       ((modm, xK_BackSpace), kill),
  143.       ((modm, xK_space), sendMessage NextLayout),
  144.       -- ((modm .|. shiftMask, xK_space), setLayout $ XMonad.layoutHook conf),
  145.       ((modm .|. shiftMask, xK_space), withFocused toggleFloat),
  146.       ((modm, xK_n), spawn "lvim-gui"),
  147.       ((modm, xK_m), windows W.focusMaster),
  148.       -- ((modm, xK_m), myFocusMaster),
  149.       -- ((modm, xK_f), selectWindow def >>= (`whenJust` windows . W.focusWindow)),
  150.       ((modm, xK_Right), nextWS),
  151.       ((modm, xK_Left), prevWS),
  152.       ((modm, xK_Up), shiftToNext >> nextWS),
  153.       ((modm, xK_Down), shiftToPrev >> prevWS),
  154.       ((modm, xK_p), toggleWS),
  155.       ((modm, xK_o), namedScratchpadAction scratchpads "scratch"),
  156.       ((modm, xK_f), whenX (swapHybrid True) dwmpromote),
  157.       ((modm .|. shiftMask, xK_j), windows W.swapDown),
  158.       ((modm .|. shiftMask, xK_k), windows W.swapUp),
  159.       ((modm .|. shiftMask, xK_q), io (exitWith ExitSuccess)),
  160.       ((modm, xK_q), spawn "xmonad --recompile && xmonad --restart"),
  161.       ((modm, xK_t), withFocused $ windows . W.sink),
  162.       ((modm, xK_comma), sendMessage (IncMasterN 1)),
  163.       ((modm, xK_s), spawn $ XMonad.terminal conf),
  164.       ((modm, xK_period), sendMessage (IncMasterN (-1))),
  165.       ((modm, xK_h), sendMessage Expand),
  166.       ((modm, xK_j), windows W.focusDown),
  167.       ((modm, xK_k), windows W.focusUp),
  168.       ((modm, xK_l), sendMessage Shrink),
  169.       ((modm .|. shiftMask, xK_o), namedScratchpadAction scratchpads "tags"),
  170.       ((modm .|. controlMask, xK_o), namedScratchpadAction scratchpads "nmtui")
  171.     ]
  172.       ++
  173.       --
  174.       -- mod-[1..9], Switch to workspace N
  175.       -- mod-shift-[1..9], Move client to workspace N
  176.       --
  177.       [ ((m .|. modm, k), windows $ f i)
  178.         | (i, k) <- zip (XMonad.workspaces conf) [xK_1 .. xK_9],
  179.           (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]
  180.       ]
  181.       -- ++
  182.       --
  183.       -- mod-{w,e,r}, Switch to physical/Xinerama screens 1, 2, or 3
  184.       -- mod-shift-{w,e,r}, Move client to screen 1, 2, or 3
  185.       --
  186.       -- [ ((m .|. modm, key), screenWorkspace sc >>= flip whenJust (windows . f))
  187.       --   | (key, sc) <- zip [xK_w, xK_e, xK_r] [0 ..],
  188.       --     (f, m) <- [(W.view, 0), (W.shift, shiftMask)]
  189.       -- ]
  190.       ++ [ ((0, xK_Print), spawn "killall flameshot; flameshot full -p ~/screenshots_full -c"),
  191.            ((shiftMask, xK_Print), spawn "killall flameshot; flameshot gui -s -p ~/screenshots_cutout -c"),
  192.            ((controlMask, xK_Print), spawn "scrotactive"),
  193.            ((modm, xF86XK_PowerOff), spawn "systemctl poweroff"),
  194.            ((0, xF86XK_PowerOff), spawn "xset dpms force off && slock"),
  195.            ((0, xF86XK_TouchpadToggle), spawn "toggle_touchpad")
  196.          ]
  197.       where
  198.               toggleFloat w = windows (\s -> if M.member w (W.floating s)
  199.                               then W.sink w s
  200.                               else (W.float w (W.RationalRect (1/3) (1/4) (2/5) (3/5)) s))
  201.          
  202.  
  203. ------------------------------------------------------------------------
  204. -- Mouse bindings: default actions bound to mouse events
  205. --
  206. myMouseBindings (XConfig {XMonad.modMask = modm}) =
  207.   M.fromList $
  208.     -- mod-button1, Set the window to floating mode and move by dragging
  209.     [ ( (modm, button1),
  210.         ( \w ->
  211.             focus w >> mouseMoveWindow w
  212.               >> windows W.shiftMaster
  213.         )
  214.       ),
  215.       -- mod-button2, Raise the window to the top of the stack
  216.       ((modm, button2), (\w -> focus w >> windows W.shiftMaster)),
  217.       -- mod-button3, Set the window to floating mode and resize by dragging
  218.  
  219.       ( (modm, button3),
  220.         ( \w ->
  221.             focus w >> mouseResizeWindow w
  222.               >> windows W.shiftMaster
  223.         )
  224.       )
  225.       -- you may also bind events to the mouse scroll wheel (button4 and button5)
  226.     ]
  227.  
  228. ------------------------------------------------------------------------
  229. -- Layouts:
  230.  
  231. -- You can specify and transform your layouts by modifying these values.
  232. -- If you change layout bindings be sure to use 'mod-shift-space' after
  233. -- restarting (with 'mod-q') to reset your layout state to the new
  234. -- defaults, as xmonad preserves your old layout settings by default.
  235. --
  236. -- The available layouts.  Note that each layout is separated by |||,
  237. -- which denotes layout choice.
  238. --
  239.  
  240. myLayout = tiled ||| noBorders Full
  241.   where
  242.     -- tiled   = Tall nmaster delta ratio
  243.     tiled = reflectHoriz $ Tall nmaster delta ratio
  244.  
  245.     -- The default number of windows in the master pane
  246.     nmaster = 1
  247.  
  248.     -- Default proportion of screen occupied by master pane
  249.     ratio = 1 / 2
  250.  
  251.     -- Percent of screen to increment by when resizing panes
  252.     delta = 3 / 100
  253.  
  254. ------------------------------------------------------------------------
  255. -- Window rules:
  256.  
  257. -- Execute arbitrary actions and WindowSet manipulations when managing
  258. -- a new window. You can use this to, for example, always float a
  259. -- particular program, or have a client always appear on a particular
  260. -- workspace.
  261. --
  262. -- To find the property name associated with a program, use
  263. -- > xprop | grep WM_CLASS
  264. -- and click on the client you're interested in.
  265. --
  266. -- To match on the WM_NAME, you can use 'title' in the same way that
  267. -- 'className' and 'resource' are used below.
  268. --
  269. myManageHook =
  270.   composeAll
  271.     [ className =? "MPlayer" --> doFloat,
  272.       className =? "Gimp" --> doFloat,
  273.       resource =? "desktop_window" --> doIgnore,
  274.       resource =? "kdesktop" --> doIgnore
  275.     ]
  276.     <+> namedScratchpadManageHook scratchpads
  277.  
  278. ------------------------------------------------------------------------
  279. -- Event handling
  280.  
  281. -- * EwmhDesktops users should change this to ewmhDesktopsEventHook
  282.  
  283. --
  284. -- Defines a custom handler function for X Events. The function should
  285. -- return (All True) if the default handler is to be run afterwards. To
  286. -- combine event hooks use mappend or mconcat from Data.Monoid.
  287. --
  288. myEventHook = refocusLastWhen refocusingIsActive <+> Hacks.windowedFullscreenFixEventHook
  289.  
  290. ------------------------------------------------------------------------
  291. -- Status bars and logging
  292.  
  293. -- Perform an arbitrary action on each internal state change or X event.
  294. -- See the 'XMonad.Hooks.DynamicLog' extension for examples.
  295. --
  296. myLogHook = return ()
  297.  
  298. ------------------------------------------------------------------------
  299. -- Startup hook
  300.  
  301. -- Perform an arbitrary action each time xmonad starts or is restarted
  302. -- with mod-q.  Used by, e.g., XMonad.Layout.PerWorkspace to initialize
  303. -- per-workspace layout choices.
  304. --
  305. -- By default, do nothing.
  306. -- myStartupHook = do
  307. --   spawn "$HOME/dotfiles/.config/polybar/launch.sh"
  308. myStartupHook = return ()
  309.  
  310. ------------------------------------------------------------------------
  311. -- Command to launch the bar.
  312. myBar = "xmobar"
  313.  
  314. -- Custom PP, configure it as you like. It determines what is being written to the bar.
  315. myPP = xmobarPP {ppCurrent = xmobarColor "#00ffff" "" . wrap "<" ">"}
  316.  
  317. -- Key binding to toggle the gap for the bar.
  318. toggleStrutsKey XConfig {XMonad.modMask = modMask} = (modMask, xK_b)
  319.  
  320. ------------------------------------------------------------------------
  321. -- Now run xmonad with all the defaults we set up.
  322.  
  323. -- Run xmonad with the settings you specify. No need to modify this.
  324. --
  325. main = xmonad =<< statusBar myBar myPP toggleStrutsKey defaults
  326.  
  327. -- A structure containing your configuration settings, overriding
  328. -- fields in the default config. Any you don't override, will
  329. -- use the defaults defined in xmonad/XMonad/Config.hs
  330. --
  331. -- No need to modify this.
  332. --
  333. defaults =
  334.   def
  335.     { -- simple stuff
  336.       terminal = myTerminal,
  337.       focusFollowsMouse = myFocusFollowsMouse,
  338.       clickJustFocuses = myClickJustFocuses,
  339.       borderWidth = myBorderWidth,
  340.       modMask = myModMask,
  341.       workspaces = myWorkspaces,
  342.       normalBorderColor = myNormalBorderColor,
  343.       focusedBorderColor = myFocusedBorderColor,
  344.       -- key bindings
  345.       keys = refocusLastKeys <+> myKeys,
  346.       mouseBindings = myMouseBindings,
  347.       -- hooks, layouts
  348.       manageHook = myManageHook,
  349.       startupHook = myStartupHook,
  350.       handleEventHook = refocusLastWhen myPred <+> myEventHook,
  351.       logHook = refocusLastLogHook <+> myLogHook,
  352.       layoutHook = refocusLastLayoutHook $ myLayout
  353.     }
  354.   where
  355.     myPred = refocusingIsActive <||> isFloat
  356.     refocusLastKeys cnf =
  357.       M.fromList $
  358.         ((modMask cnf, xK_a), toggleFocus) :
  359.         ((modMask cnf .|. shiftMask, xK_a), swapWithLast) :
  360.         ((modMask cnf, xK_b), toggleRefocusing) :
  361.           [ ( (modMask cnf .|. shiftMask, n),
  362.               windows =<< shiftRLWhen myPred wksp
  363.             )
  364.             | (n, wksp) <- zip [xK_1 .. xK_9] (workspaces cnf)
  365.           ]
  366.  
  367. ------------------------ old stripped down content ----------------------
  368.  
  369. -- ( (modm, xK_u),
  370. --   submap . M.fromList $
  371. --     [ ((0, xK_w), spawn "brave"),
  372. --       ((0, xK_r), rofi_launch),
  373. --       ((0, xK_BackSpace), kill),
  374. --       ((0, xK_space), sendMessage NextLayout),
  375. --       ((0 .|. shiftMask, xK_space), setLayout $ XMonad.layoutHook conf),
  376. --       ((0, xK_n), refresh),
  377. --       ((0, xK_Tab), windows W.focusDown),
  378. --       ((0, xK_m), myFocusMaster),
  379. --       ((0, xK_o), namedScratchpadAction scratchpads "scratch"),
  380. --       ((0, xK_f), whenX (swapHybrid True) dwmpromote),
  381. --       ((shiftMask, xK_j), windows W.swapDown),
  382. --       ((shiftMask, xK_k), windows W.swapUp),
  383. --       ((shiftMask, xK_q), io (exitWith ExitSuccess)),
  384. --       ((0, xK_q), spawn "xmonad --recompile && xmonad --restart"),
  385. --       ((0, xK_t), withFocused $ windows . W.sink),
  386. --       ((0, xK_comma), sendMessage (IncMasterN 1)),
  387. --       ((0, xK_s), spawn $ XMonad.terminal conf),
  388. --       ((0, xK_period), sendMessage (IncMasterN (-1)))
  389. --       -- , ((modm              , xK_b     ), sendMessage ToggleStruts)
  390. --       -- , ((modm .|. shiftMask, xK_slash ), spawn ("echo \"" ++ help ++ "\" | xmessage -file -"))
  391. --     ]
  392. -- ),
  393.  
Add Comment
Please, Sign In to add comment