Advertisement
Guest User

Untitled

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