Advertisement
Guest User

Untitled

a guest
Oct 18th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.22 KB | None | 0 0
  1. -- Osiris's XMonad config
  2.  
  3. import System.Exit
  4. import Data.Maybe (Maybe, isNothing, fromJust)
  5. import qualified Data.List as L
  6. import qualified Data.Map as M
  7. import GHC.IO.Handle
  8. import Graphics.X11.ExtraTypes.XF86
  9.  
  10. -- Xmonad Core
  11. import XMonad
  12. import qualified XMonad.StackSet as W
  13. import XMonad.Config.Desktop
  14.  
  15. -- Layouts
  16. import XMonad.Layout.LayoutModifier
  17. import XMonad.Layout.Gaps
  18. import XMonad.Layout.Spacing
  19. import XMonad.Layout.MultiToggle
  20. import XMonad.Layout.NoBorders
  21. import XMonad.Layout.MultiToggle.Instances
  22. import XMonad.Layout.ResizableTile
  23. import XMonad.Layout.BinarySpacePartition
  24. import XMonad.Layout.SimpleFloat
  25. import XMonad.Layout.PerWorkspace (onWorkspace)
  26. import XMonad.Layout.Minimize
  27. import XMonad.Layout.Fullscreen
  28. import XMonad.Layout.Named
  29. import XMonad.Layout.Tabbed
  30. import XMonad.Layout.ThreeColumns
  31. import XMonad.Layout.MultiToggle.Instances
  32. import XMonad.Layout.NoFrillsDecoration
  33. import XMonad.Layout.Renamed
  34. import XMonad.Layout.Simplest
  35. import XMonad.Layout.SubLayouts
  36. import XMonad.Layout.WindowNavigation
  37. import XMonad.Layout.ZoomRow
  38.  
  39. -- Actions
  40. import XMonad.Actions.Navigation2D
  41. import XMonad.Actions.GridSelect
  42. import XMonad.Actions.UpdatePointer
  43. import XMonad.Actions.SpawnOn
  44. import XMonad.Actions.CycleWS
  45.  
  46. -- Hooks
  47. import XMonad.Hooks.DynamicLog
  48. import XMonad.Hooks.ManageHelpers
  49. import XMonad.Hooks.SetWMName
  50. import XMonad.Hooks.EwmhDesktops
  51. import XMonad.Hooks.ManageDocks
  52.  
  53. -- Utils
  54. import XMonad.Util.NamedScratchpad
  55. import XMonad.Util.WorkspaceCompare
  56. import XMonad.Util.Run
  57. import XMonad.Util.EZConfig
  58.  
  59.  
  60. ----------------------------mupdf--------------------------------------------
  61. -- Terminal
  62. -- The preferred terminal program, which is used in a binding below and by
  63. -- certain contrib modules.
  64. --
  65. myTerminal = "urxvt"
  66.  
  67. -- The command to lock the screen or show the screensaver.
  68. myScreensaver = "xscreensaver-command -lock"
  69.  
  70. -- The command to use as a launcher, to launch commands that don't have
  71. -- preset keybindings.
  72. myLauncher = "rofi -show run"
  73.  
  74. -- The command to use as a window manage
  75. myWindowManager = "rofi -show window"
  76.  
  77. ------------------------------------------------------------------------
  78. -- Workspaces
  79. -- The default number of workspaces (virtual screens) and their names.
  80. --
  81. myWorkspaces = ["1:web","2:term","3:code","4:vm","5:media", "6:chat"] ++ map show [7..8] ++ ["NSP"]
  82.  
  83.  
  84. ------------------------------------------------------------------------
  85. -- Window rules
  86. -- Execute arbitrary actions and WindowSet manipulations when managing
  87. -- a new window. You can use this to, for example, always float a
  88. -- particular program, or have a client always appear on a particular
  89. -- workspace.
  90. --
  91. -- To find the property name associated with a program, use
  92. -- > xprop | grep WM_CLASS
  93. -- and click on the client you're interested in.
  94. --
  95. -- To match on the WM_NAME, you can use 'title' in the same way that
  96. -- 'className' and 'resource' are used below.
  97. --
  98. myManageHook = composeAll
  99. [
  100. className =? "Google-chrome" --> doShift "2:web"
  101. , resource =? "desktop_window" --> doIgnore
  102. , className =? "Steam" --> doCenterFloat
  103. , className =? "Telegram" --> (customFloating $ W.RationalRect (1/6) (1/6) (2/3) (2/3))
  104. , className =? "VirtualBox" --> doShift "4:vm"
  105. , className =? "Spotify" --> doShift "5:media"
  106. , className =? "stalonetray" --> doIgnore
  107. , isFullscreen --> doFullFloat
  108. -- , isFullscreen --> (doF W.focusDown <+> doFullFloat)
  109. ]
  110.  
  111. -- Function that prevents cycling to workspaces available on other screens
  112. hiddenNotNSP :: X (WindowSpace -> Bool)
  113. hiddenNotNSP = do
  114. hs <- gets $ map W.tag . W.hidden . windowset
  115. return (\w -> (W.tag w) /= "NSP" && (W.tag w) `elem` hs)
  116.  
  117. ------------------------------------------------------------------------
  118. -- Layouts
  119. -- You can specify and transform your layouts by modifying these values.
  120. -- If you change layout bindings be sure to use 'mod-shift-space' after
  121. -- restarting (with 'mod-q') to reset your layout state to the new
  122. -- defaults, as xmonad preserves your old layout settings by default.
  123. --
  124. -- The available layouts. Note that each layout is separated by |||,
  125. -- which denotes layout choice.
  126.  
  127. outerGaps = 0
  128. myGaps = gaps [(U, outerGaps), (R, outerGaps), (L, outerGaps), (D, outerGaps)]
  129. addSpace = renamed [CutWordsLeft 2] . spacing gap
  130. tab = avoidStruts
  131. $ addTopBar
  132. $ myGaps
  133. $ renamed [Replace "Tabbed"]
  134. $ tabbed shrinkText myTabTheme
  135.  
  136. layouts = avoidStruts (
  137. (
  138. addTopBar
  139. $ windowNavigation
  140. $ renamed [CutWordsLeft 1]
  141. $ addTabs shrinkText myTabTheme
  142. $ subLayout [] Simplest
  143. $ myGaps
  144. $ addSpace (emptyBSP ||| ThreeColMid 1 (3/100) (1/2) ||| zoomRow)
  145. )
  146. ||| tab
  147. )
  148.  
  149. myLayout = smartBorders
  150. $ minimize
  151. $ mkToggle (NOBORDERS ?? FULL ?? EOT)
  152. $ layouts
  153.  
  154. myNav2DConf = def
  155. { defaultTiledNavigation = centerNavigation
  156. , floatNavigation = centerNavigation
  157. , screenNavigation = lineNavigation
  158. , layoutNavigation = [("Full", centerNavigation)
  159. -- line/center same results ,("Tabs", lineNavigation)
  160. -- ,("Tabs", centerNavigation)
  161. ]
  162. , unmappedWindowRect = [("Full", singleWindowRect)
  163. -- works but breaks tab deco ,("Tabs", singleWindowRect)
  164. -- doesn't work but deco ok ,("Tabs", fullScreenRect)
  165. ]
  166. }
  167.  
  168.  
  169. ------------------------------------------------------------------------
  170. -- Colors and borders
  171.  
  172. -- Color of current window title in xmobar.
  173. xmobarTitleColor = "#FFB6B0"
  174.  
  175. -- Color of current workspace in xmobar.
  176. xmobarCurrentWorkspaceColor = "#CEFFAC"
  177.  
  178. -- Width of the window border in pixels.
  179. myBorderWidth = 0
  180.  
  181. myNormalBorderColor = "#000000"
  182. myFocusedBorderColor = active
  183.  
  184. base03 = "#002b36"
  185. base02 = "#073642"
  186. base01 = "#586e75"
  187. base00 = "#657b83"
  188. base0 = "#839496"
  189. base1 = "#93a1a1"
  190. base2 = "#eee8d5"
  191. base3 = "#fdf6e3"
  192. yellow = "#b58900"
  193. orange = "#cb4b16"
  194. red = "#dc322f"
  195. magenta = "#d33682"
  196. violet = "#6c71c4"
  197. blue = "#268bd2"
  198. cyan = "#2aa198"
  199. green = "#859900"
  200.  
  201. -- sizes
  202. gap = 0
  203. topbar = 10
  204. border = 0
  205. prompt = 20
  206. status = 20
  207.  
  208. active = cyan
  209. activeWarn = red
  210. inactive = base02
  211. focusColor = cyan
  212. unfocusColor = base02
  213.  
  214. -- myFont = "-*-terminus-medium-*-*-*-*-160-*-*-*-*-*-*"
  215. -- myBigFont = "-*-terminus-medium-*-*-*-*-240-*-*-*-*-*-*"
  216. myFont = "-*-SourceCodePro Nerd Font-medium-*-*-*-*-160-*-*-*-*-*-*"
  217. myBigFont = "-*-SourceCodePro Nerd Fon-medium-*-*-*-*-240-*-*-*-*-*-*"
  218. myWideFont = "xft:Eurostar Black Extended:"
  219. ++ "style=Regular:pixelsize=180:hinting=true"
  220.  
  221. -- this is a "fake title" used as a highlight bar in lieu of full borders
  222. -- (I find this a cleaner and less visually intrusive solution)
  223. topBarTheme = def
  224. {
  225. fontName = myFont
  226. , inactiveBorderColor = base03
  227. , inactiveColor = base03
  228. , inactiveTextColor = base03
  229. , activeBorderColor = active
  230. , activeColor = active
  231. , activeTextColor = active
  232. , urgentBorderColor = red
  233. , urgentTextColor = yellow
  234. , decoHeight = topbar
  235. }
  236.  
  237. addTopBar = renamed [CutWordsLeft 1] . noFrillsDeco shrinkText topBarTheme
  238.  
  239. myTabTheme = def
  240. { fontName = myFont
  241. , activeColor = active
  242. , inactiveColor = base02
  243. , activeBorderColor = active
  244. , inactiveBorderColor = base02
  245. , activeTextColor = base03
  246. , inactiveTextColor = base00
  247. }
  248.  
  249.  
  250. ------------------------------------------------------------------------
  251. -- Key bindings
  252. --
  253. -- modMask lets you specify which modkey you want to use. The default
  254. -- is mod1Mask ("left alt"). You may also consider using mod3Mask
  255. -- ("right alt"), which does not conflict with emacs keybindings. The
  256. -- "windows key" is usually mod4Mask.
  257. --
  258. myModMask = mod4Mask
  259. altMask = mod1Mask
  260.  
  261. -- Key bindings. Add, modify or remove key bindings here.
  262. myKeys conf@(XConfig {XMonad.modMask = modm}) = M.fromList $
  263.  
  264. -- launch a terminal
  265. [ ((modm .|. shiftMask, xK_Return), spawn $ XMonad.terminal conf)
  266.  
  267. -- launch file manager
  268. , ((modm .|. shiftMask, xK_f ), spawn "thunar")
  269.  
  270. -- launch roficlip
  271. , ((modm, xK_c ), spawn "roficlip")
  272. , ((modm, xK_backslash ), spawn "roficlip")
  273.  
  274. -- launch rofi
  275. , ((modm, xK_r ), spawn myLauncher)
  276. , ((modm .|. shiftMask, xK_w ), spawn myWindowManager)
  277.  
  278. -- launch telegram
  279. , ((modm, xK_F10 ), namedScratchpadAction "telegram-desktop")
  280.  
  281. -- Mute volume.
  282. , ((0, xF86XK_AudioMute), spawn "amixer -q set Master toggle")
  283. -- Decrease volume.
  284. , ((0, xF86XK_AudioLowerVolume), spawn "amixer -q set Master 5%-")
  285. -- Increase volume.
  286. , ((0, xF86XK_AudioRaiseVolume), spawn "amixer -q set Master 5%+")
  287.  
  288. -- close focused window
  289. , ((modm .|. shiftMask, xK_c ), kill)
  290.  
  291. -- Rotate through the available layout algorithms
  292. , ((modm, xK_space ), sendMessage NextLayout)
  293.  
  294. -- Reset the layouts on the current workspace to default
  295. , ((modm .|. shiftMask, xK_space ), setLayout $ XMonad.layoutHook conf)
  296.  
  297. -- Resize viewed windows to the correct size
  298. , ((modm .|. shiftMask, xK_r ), refresh)
  299.  
  300. -- Move focus to the next window
  301. , ((modm, xK_Tab ), windows W.focusDown)
  302.  
  303. -- Move to previous workspace
  304. , ((modm, xK_grave ), toggleWS' ["NSP"])
  305.  
  306. -- Move focus to the next window
  307. , ((modm .|. controlMask .|. shiftMask, xK_j ), windows W.focusDown)
  308.  
  309. -- Move focus to the previous window
  310. , ((modm .|. controlMask .|. shiftMask, xK_k ), windows W.focusUp)
  311.  
  312. -- Minimize selected window
  313. , ((modm, xK_m ), withFocused minimizeWindow)
  314.  
  315. -- Restore one minimized window
  316. , ((modm .|. shiftMask, xK_m ), sendMessage RestoreNextMinimizedWin)
  317.  
  318. -- Maximize selected window
  319. , ((modm, xK_f ), (sendMessage $ Toggle FULL))
  320.  
  321. -- Swap the focused window and the master window
  322. , ((modm .|. controlMask, xK_Return), windows W.swapMaster)
  323.  
  324. -- Move focus to the master window
  325. , ((modm, xK_Return ), windows W.focusMaster )
  326.  
  327. -- Swap the focused window with the next window
  328. , ((modm .|. controlMask .|. shiftMask, xK_j ), windows W.swapDown )
  329.  
  330. -- Swap the focused window with the previous window
  331. , ((modm .|. controlMask .|. shiftMask, xK_k ), windows W.swapUp )
  332.  
  333. -- Shrink the master area
  334. , ((modm .|. controlMask, xK_h ), sendMessage Shrink)
  335. , ((modm .|. controlMask, xK_j ), sendMessage MirrorShrink)
  336.  
  337. -- Expand the master area
  338. , ((modm .|. controlMask, xK_l ), sendMessage Expand)
  339. , ((modm .|. controlMask, xK_k ), sendMessage MirrorExpand)
  340.  
  341. -- Toggle Brightness
  342. , ((modm, xK_minus ), spawn "xbacklight -dec 5")
  343. , ((modm, xK_equal ), spawn "xbacklight -inc 5")
  344.  
  345. -- Push window back into tiling
  346. , ((modm, xK_t ), withFocused $ windows . W.sink)
  347.  
  348. -- Increment the number of windows in the master area
  349. , ((modm , xK_comma ), sendMessage (IncMasterN 1))
  350.  
  351. -- Decrement the number of windows in the master area
  352. , ((modm , xK_period), sendMessage (IncMasterN (-1)))
  353.  
  354.  
  355. , ((modm , xK_BackSpace), swapNextScreen)
  356.  
  357. -- Switch workspaces and screens
  358. , ((modm, xK_Right), moveTo Next (WSIs hiddenNotNSP))
  359. , ((modm, xK_Left), moveTo Prev (WSIs hiddenNotNSP))
  360. , ((modm .|. shiftMask, xK_Right), shiftTo Next (WSIs hiddenNotNSP))
  361. , ((modm .|. shiftMask, xK_Left), shiftTo Prev (WSIs hiddenNotNSP))
  362. , ((modm, xK_Down), nextScreen)
  363. , ((modm, xK_Up), prevScreen)
  364. , ((modm .|. shiftMask, xK_Down), shiftNextScreen)
  365. , ((modm .|. shiftMask, xK_Up), shiftPrevScreen)
  366.  
  367. -- Binary Space Partition Functions
  368. , ((modm .|. altMask, xK_l ), sendMessage $ ExpandTowards R)
  369. , ((modm .|. altMask, xK_h ), sendMessage $ ExpandTowards L)
  370. , ((modm .|. altMask, xK_j ), sendMessage $ ExpandTowards D)
  371. , ((modm .|. altMask, xK_k ), sendMessage $ ExpandTowards U)
  372. , ((modm .|. altMask .|. shiftMask, xK_l ), sendMessage $ ShrinkFrom R)
  373. , ((modm .|. altMask .|. shiftMask, xK_h ), sendMessage $ ShrinkFrom L)
  374. , ((modm .|. altMask .|. shiftMask, xK_j ), sendMessage $ ShrinkFrom D)
  375. , ((modm .|. altMask .|. shiftMask, xK_k ), sendMessage $ ShrinkFrom U)
  376. , ((modm, xK_d ), sendMessage Rotate)
  377. , ((modm, xK_s ), sendMessage Swap)
  378. , ((modm, xK_n ), sendMessage FocusParent)
  379. , ((modm .|. controlMask, xK_n ), sendMessage SelectNode)
  380. , ((modm .|. shiftMask, xK_n ), sendMessage MoveNode)
  381.  
  382. -- Directional Navigation & Moving of Windows
  383. , ((modm, xK_l), windowGo R False)
  384. , ((modm, xK_h), windowGo L False)
  385. , ((modm, xK_k), windowGo U False)
  386. , ((modm, xK_j), windowGo D False)
  387. , ((modm .|. shiftMask, xK_l), windowSwap R False)
  388. , ((modm .|. shiftMask, xK_h), windowSwap L False)
  389. , ((modm .|. shiftMask, xK_k), windowSwap U False)
  390. , ((modm .|. shiftMask, xK_j), windowSwap D False)
  391.  
  392. -- Toggle the status bar gap
  393. , ((modm , xK_b ), sendMessage ToggleStruts)
  394.  
  395. -- Quit xmonad
  396. , ((modm .|. shiftMask, xK_q ), io (exitWith ExitSuccess))
  397.  
  398. -- Restart xmonad
  399. , ((modm , xK_q ), spawn "xmonad --recompile; xmonad --restart")
  400. ]
  401. ++
  402.  
  403. -- mod-[1..9], Switch to workspace N
  404. -- mod-shift-[1..9], Move client to workspace N
  405. [((m .|. modm, k), windows $ f i)
  406. | (i, k) <- zip (XMonad.workspaces conf) [xK_1 .. xK_9]
  407. , (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]]
  408. ++
  409.  
  410. -- mod-{w,e,r}, Switch to physical/Xinerama screens 1, 2, or 3
  411. -- mod-shift-{w,e,r}, Move client to screen 1, 2, or 3
  412. [((m .|. modm, key), screenWorkspace sc >>= flip whenJust (windows . f))
  413. | (key, sc) <- zip [xK_w, xK_e, xK_r] [0..]
  414. , (f, m) <- [(W.view, 0), (W.shift, shiftMask)]]
  415.  
  416.  
  417. ------------------------------------------------------------------------
  418. -- Mouse bindings
  419. --
  420. -- Focus rules
  421. -- True if your focus should follow your mouse cursor.
  422. myFocusFollowsMouse :: Bool
  423. myFocusFollowsMouse = True
  424.  
  425. myMouseBindings (XConfig {XMonad.modMask = modMask}) = M.fromList $
  426. [
  427. -- mod-button1, Set the window to floating mode and move by dragging
  428. ((modMask, button1),
  429. (\w -> focus w >> mouseMoveWindow w))
  430.  
  431. -- mod-button2, Raise the window to the top of the stack
  432. , ((modMask, button2),
  433. (\w -> focus w >> windows W.swapMaster))
  434.  
  435. -- mod-button3, Set the window to floating mode and resize by dragging
  436. , ((modMask, button3),
  437. (\w -> focus w >> mouseResizeWindow w))
  438.  
  439. -- you may also bind events to the mouse scroll wheel (button4 and button5)
  440. ]
  441.  
  442.  
  443. ------------------------------------------------------------------------
  444. -- Startup hook
  445. -- Perform an arbitrary action each time xmonad starts or is restarted
  446. -- with mod-q. Used by, e.g., XMonad.Layout.PerWorkspace to initialize
  447. -- per-workspace layout choices.
  448. --
  449. -- By default, do nothing.
  450. myStartupHook = return ()
  451.  
  452. ------------------------------------------------------------------------
  453. -- Run xmonad with all the defaults we set up.
  454. --
  455. main = do
  456. xmproc <- spawnPipe "xmobar ~/.xmonad/xmobarrc.hs"
  457. xmonad $ docks
  458. $ withNavigation2DConfig myNav2DConf
  459. $ additionalNav2DKeys (xK_Up, xK_Left, xK_Down, xK_Right)
  460. [
  461. (mod4Mask, windowGo )
  462. , (mod4Mask .|. shiftMask, windowSwap)
  463. ]
  464. False
  465. $ defaults {
  466. logHook = dynamicLogWithPP $ xmobarPP {
  467. ppOutput = hPutStrLn xmproc
  468. , ppTitle = xmobarColor xmobarTitleColor "" . shorten 100
  469. , ppCurrent = xmobarColor xmobarCurrentWorkspaceColor ""
  470. , ppSep = " "
  471. }
  472. }
  473.  
  474.  
  475. ------------------------------------------------------------------------
  476. -- Combine it all together
  477. -- A structure containing your configuration settings, overriding
  478. -- fields in the default config. Any you don't override, will
  479. -- use the defaults defined in xmonad/XMonad/Config.hs
  480. --
  481. -- No need to modify this.
  482. --
  483. defaults = defaultConfig {
  484. -- simple stuff
  485. terminal = myTerminal,
  486. focusFollowsMouse = myFocusFollowsMouse,
  487. borderWidth = myBorderWidth,
  488. modMask = myModMask,
  489. workspaces = myWorkspaces,
  490. normalBorderColor = myNormalBorderColor,
  491. focusedBorderColor = myFocusedBorderColor,
  492.  
  493. -- key bindings
  494. keys = myKeys,
  495. mouseBindings = myMouseBindings,
  496.  
  497. -- hooks, layouts
  498. layoutHook = myLayout,
  499. -- handleEventHook = E.fullscreenEventHook,
  500. handleEventHook = fullscreenEventHook,
  501. manageHook = manageDocks <+> myManageHook,
  502. startupHook = myStartupHook
  503. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement