Advertisement
Guest User

Untitled

a guest
May 5th, 2021
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.21 KB | None | 0 0
  1. import XMonad
  2. import System.Exit
  3. import qualified XMonad.StackSet as W
  4. import qualified Data.Map as M
  5.  
  6. import XMonad.Hooks.DynamicLog
  7. import XMonad.Hooks.ManageDocks
  8. import XMonad.Hooks.ManageHelpers (isFullscreen, doFullFloat, doCenterFloat, isDialog)
  9. import XMonad.Hooks.InsertPosition
  10. import XMonad.Hooks.EwmhDesktops
  11.  
  12. import XMonad.Layout.Spacing
  13. import XMonad.Layout.NoBorders (smartBorders)
  14.  
  15. import XMonad.Util.SpawnOnce
  16.  
  17. import XMonad.Util.Run (spawnPipe)
  18. import System.IO
  19.  
  20. myWorkspaces :: [String]
  21. myWorkspaces = clickable
  22. $ [" \xf120 ", " \xf07c ", " \xf269 ", " \xf121 ", " \xf9d2 ", " \xf1d7 ", " \xfc45 ", " \xf813 ", " \xf001 "]
  23. where
  24. clickable l = [ "<action=xdotool key super+" ++ show n ++ ">" ++ ws ++ "</action>" |
  25. (i,ws) <- zip [1..9] l,
  26. let n = i ]
  27.  
  28. myKeys conf@(XConfig {XMonad.modMask = modm}) = M.fromList $
  29.  
  30. -- KEY CODES FOR MULTIMEDIA BUTTONS
  31. -- nvim /usr/include/X11/XF86keysym.h
  32.  
  33. -- launch a terminal
  34. [ ((modm, xK_Return ), spawn $ XMonad.terminal conf)
  35.  
  36. -- launch librewolf
  37. , ((0, 0x1008FF18 ), spawn "librewolf")
  38.  
  39. -- launch Kodi
  40. , ((0, 0x1008FF32 ), spawn "kodi")
  41.  
  42. -- launch Buku
  43. , ((0, 0x1008FF2F ), spawn "buku-rofi")
  44.  
  45. -- up volume
  46. , ((0, 0x1008FF13 ), spawn "pulseaudio-change-volume-up.sh")
  47.  
  48. -- down volume
  49. , ((0, 0x1008FF11 ), spawn "pulseaudio-change-volume-down.sh")
  50.  
  51. -- launch rofi
  52. , ((modm, xK_F2 ), spawn "rofi -modi drun -show drun -show-icons")
  53.  
  54. -- Screenshots
  55. , ((0, xK_Print ), spawn "TakeScreenshot-Full.sh")
  56. , ((modm, xK_Print ), spawn "TakeScreenshot-Grab.sh")
  57.  
  58. -- close focused window
  59. , ((modm, xK_q ), kill)
  60.  
  61. -- Rotate through the available layout algorithms
  62. , ((modm, xK_space ), sendMessage NextLayout)
  63.  
  64. -- Reset the layouts on the current workspace to default
  65. , ((modm .|. shiftMask, xK_space ), setLayout $ XMonad.layoutHook conf)
  66.  
  67. -- Resize viewed windows to the correct size
  68. , ((modm, xK_n ), refresh)
  69.  
  70. -- Move focus to the next window
  71. , ((modm, xK_Tab ), windows W.focusDown)
  72.  
  73. -- Move focus to the next window
  74. , ((modm, xK_j ), windows W.focusDown)
  75.  
  76. -- Move focus to the previous window
  77. , ((modm, xK_k ), windows W.focusUp )
  78.  
  79. -- Move focus to the master window
  80. , ((modm, xK_m ), windows W.focusMaster )
  81.  
  82. -- Swap the focused window and the master window
  83. , ((modm .|. shiftMask, xK_s ), windows W.swapMaster)
  84.  
  85. -- Swap the focused window with the next window
  86. , ((modm .|. shiftMask, xK_j ), windows W.swapDown )
  87.  
  88. -- Swap the focused window with the previous window
  89. , ((modm .|. shiftMask, xK_k ), windows W.swapUp )
  90.  
  91. -- Shrink the master area
  92. , ((modm, xK_h ), sendMessage Shrink)
  93.  
  94. -- Expand the master area
  95. , ((modm, xK_l ), sendMessage Expand)
  96.  
  97. -- Push window back into tiling
  98. , ((modm, xK_t ), withFocused $ windows . W.sink)
  99.  
  100. -- Increment the number of windows in the master area
  101. , ((modm , xK_comma ), sendMessage (IncMasterN 1))
  102.  
  103. -- Deincrement the number of windows in the master area
  104. , ((modm , xK_period), sendMessage (IncMasterN (-1)))
  105.  
  106. -- Quit xmonad
  107. , ((modm .|. controlMask .|. shiftMask, xK_q ), io (exitWith ExitSuccess))
  108.  
  109. -- Reboot
  110. , ((modm .|. controlMask .|. shiftMask, xK_r ), spawn "loginctl reboot")
  111.  
  112. -- Shutdown
  113. , ((modm .|. controlMask .|. shiftMask, xK_p ), spawn "loginctl poweroff")
  114.  
  115. -- Restart xmonad
  116. , ((modm .|. controlMask .|. shiftMask, xK_F5 ), spawn "killall -9 xmobar; killall -9 trayer-srg; xmonad --recompile; xmonad --restart")
  117. ]
  118. ++
  119.  
  120. --
  121. -- mod-[1..9], Switch to workspace N
  122. -- mod-shift-[1..9], Move client to workspace N
  123. --
  124. [((m .|. modm, k), windows $ f i)
  125. | (i, k) <- zip (XMonad.workspaces conf) [xK_1 .. xK_9]
  126. , (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]]
  127.  
  128. ------------------------------------------------------------------------
  129. -- Mouse bindings: default actions bound to mouse events
  130. --
  131. myMouseBindings (XConfig {XMonad.modMask = modm}) = M.fromList $
  132.  
  133. -- mod-button1, Set the window to floating mode and move by dragging
  134. [ ((modm, button1), (\w -> focus w >> mouseMoveWindow w
  135. >> windows W.shiftMaster))
  136.  
  137. -- mod-button2, Raise the window to the top of the stack
  138. , ((modm, button2), (\w -> focus w >> windows W.shiftMaster))
  139.  
  140. -- mod-button3, Set the window to floating mode and resize by dragging
  141. , ((modm, button3), (\w -> focus w >> mouseResizeWindow w
  142. >> windows W.shiftMaster))
  143.  
  144. -- you may also bind events to the mouse scroll wheel (button4 and button5)
  145. ]
  146.  
  147. myLayout = tiled ||| Mirror tiled
  148. where
  149. tiled = Tall nmaster delta ratio
  150. nmaster = 1 -- Default number of windows in the master pane
  151. ratio = 1/2 -- Default proportion of screen occupied by master pane
  152. delta = 3/100 -- Percent of screen to increment by when resizing panes
  153.  
  154. myLayoutHook = avoidStruts
  155. $ smartBorders
  156. $ spacingRaw False (Border 4 4 4 4) True (Border 4 4 4 4) True
  157. myLayout
  158.  
  159. myManageHook = composeAll
  160. [ isFullscreen --> doFullFloat
  161. , insertPosition End Newer
  162. , className =? "mpv" --> doCenterFloat
  163. , className =? "feh" --> doCenterFloat
  164. , className =? "Sxiv" --> doCenterFloat
  165. , className =? "KeePassXC" --> doCenterFloat
  166. , className =? "Galculator" --> doCenterFloat
  167. , className =? "Gcolor2" --> doCenterFloat
  168. , className =? "LibreWolf" --> doShift ( myWorkspaces !! 2 )
  169. , className =? "Steam" --> doShift ( myWorkspaces !! 4 )
  170. , className =? "QtCreator" --> doShift ( myWorkspaces !! 3 )
  171. , className =? "Kodi" --> doShift ( myWorkspaces !! 7 )
  172. , isDialog --> doCenterFloat
  173. ]
  174.  
  175. myStartupHook = do
  176. spawnOnce "/home/themainman/.xmonad/autostart.sh"
  177. spawn "xmobar -x 0 /home/themainman/.config/xmobar/xmobarrc-bottom"
  178. spawn "trayer-srg --edge bottom --align right --SetDockType true --SetPartialStrut True --expand true --height 25 --width 5 --transparent true --alpha 0 --tint 0x282c34 &"
  179.  
  180. -- main :: IO ()
  181. -- main = xmonad
  182. -- . docks
  183. -- . ewmhFullscreen
  184. -- . ewmh
  185. -- =<< statusBar "xmobar -x 0 ~/.config/xmobar/xmobarrc-top" myXmobarPP def myConfig
  186.  
  187. main = do
  188. xmproc0 <- spawnPipe "xmobar -x 0 ~/.config/xmobar/xmobarrc-top"
  189. xmonad $ docks $ ewmhFullscreen $ ewmh def
  190. --myConfig = def
  191. { modMask = mod4Mask
  192. , layoutHook = myLayoutHook
  193. , manageHook = myManageHook
  194. --, handleEventHook = handleEventHook def <+> XMonad.Hooks.EwmhDesktops.fullscreenEventHook
  195. , startupHook = myStartupHook
  196. , logHook = dynamicLogWithPP $ myXmobarPP { ppOutput = \x -> hPutStrLn xmproc0 x }
  197. , terminal = "st"
  198. , focusFollowsMouse = True
  199. , clickJustFocuses = False
  200. , borderWidth = 2
  201. , workspaces = myWorkspaces
  202. , normalBorderColor = "#282c34"
  203. , focusedBorderColor = "#46d9ff"
  204. , keys = myKeys
  205. , mouseBindings = myMouseBindings
  206. }
  207.  
  208. myXmobarPP :: PP
  209. myXmobarPP = def
  210. { ppSep = magenta " • "
  211. , ppTitle = wrap (white "[") (white "]") . magenta . shorten 80
  212. , ppTitleSanitize = xmobarStrip
  213. , ppCurrent = wrap (blue "[") (blue "]")
  214. , ppHidden = yellow . wrap " " ""
  215. , ppHiddenNoWindows = lowWhite . wrap " " ""
  216. , ppUrgent = red . wrap (yellow "!") (yellow "!")
  217. }
  218. where
  219. blue, lowWhite, magenta, red, white, yellow :: String -> String
  220. magenta = xmobarColor "#ff79c6" ""
  221. blue = xmobarColor "#bd93f9" ""
  222. white = xmobarColor "#f8f8f2" ""
  223. yellow = xmobarColor "#f1fa8c" ""
  224. red = xmobarColor "#ff5555" ""
  225. lowWhite = xmobarColor "#696969" ""
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement