Advertisement
Guest User

Untitled

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