Guest User

Untitled

a guest
Dec 12th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.71 KB | None | 0 0
  1. -- ~/.xmonad/xmonad.hs
  2. {-# LANGUAGE NoMonomorphismRestriction #-}
  3. -- Imports {
  4. import XMonad
  5. -- Prompt
  6. import XMonad.Prompt
  7. import XMonad.Prompt.RunOrRaise (runOrRaisePrompt)
  8. import XMonad.Prompt.AppendFile (appendFilePrompt)
  9. -- Hooks
  10. import XMonad.Operations
  11.  
  12. import System.IO
  13. import System.Exit
  14.  
  15. import XMonad.Util.Run
  16. import XMonad.Util.SpawnOnce
  17.  
  18. import XMonad.Util.EZConfig
  19.  
  20. import XMonad.Actions.CycleWS
  21.  
  22. import XMonad.Hooks.ManageDocks
  23. import XMonad.Hooks.ManageHelpers
  24. import XMonad.Hooks.SetWMName
  25. import XMonad.Hooks.DynamicLog
  26. import XMonad.Hooks.UrgencyHook
  27. import XMonad.Hooks.FadeInactive
  28. import XMonad.Hooks.EwmhDesktops
  29. import XMonad.Hooks.SetWMName
  30.  
  31. import XMonad.Layout.NoBorders (smartBorders, noBorders)
  32. import XMonad.Layout.PerWorkspace (onWorkspace, onWorkspaces)
  33. import XMonad.Layout.Reflect (reflectHoriz)
  34. import XMonad.Layout.IM
  35. import XMonad.Layout.SimpleFloat
  36. import XMonad.Layout.Spacing
  37. import XMonad.Layout.ResizableTile
  38. import XMonad.Layout.NoBorders
  39. -- import XMonad.Layout.Gaps
  40. import XMonad.Layout.LayoutHints
  41. import XMonad.Layout.LayoutModifier
  42. import XMonad.Layout.Reflect
  43. import XMonad.Layout.Grid
  44.  
  45. import Data.Ratio ((%))
  46. import Data.List (isInfixOf)
  47.  
  48. import qualified XMonad.StackSet as W
  49. import qualified Data.Map as M
  50. --}
  51.  
  52. -- Configuration
  53. -- Define Terminal
  54. myTerminal = "terminal"
  55. -- Define modMask
  56. modMask' :: KeyMask
  57. modMask' = mod4Mask
  58. -- Define workspaces
  59. myWorkspaces = ["1:main","2:random","3:media","4:chat","5:web","6:doc","7:matlab","8:windows"]
  60. -- Dzen config
  61. myStatusBar = "dzen2 -x '0' -y '0' -h '24' -ta 'l' -fg '#FFFFFF' -bg '#3c3c3c' -fn '-*-bitstream vera sans-medium-r-normal-*-11-*-*-*-*-*-*-*' -e ''"
  62. myBtmStatusBar = "conky -c /home/yami/.conky/conkyrc | dzen2 -e '' -x '0' -h '24' -ta 'c' -bg '#3c3c3c' -fg '#FFFFFF' -fn '-*-bitstream vera sans-medium-r-normal-*-11-*-*-*-*-*-*-*' -y '1176' & stalonetray &"
  63. myBitmapsDir = "/home/yami/.xmonad/dzen"
  64.  
  65. -- Main {
  66. main = do
  67. dzenTopBar <- spawnPipe myStatusBar
  68. dzenBtmBar <- spawnPipe myBtmStatusBar
  69. xmonad $ defaultConfig
  70. { terminal = myTerminal
  71. , workspaces = myWorkspaces
  72. , keys = keys'
  73. , modMask = modMask'
  74. , startupHook = ewmhDesktopsStartup >> setWMName "LG3D" >> spawnOnce "sh /home/yami/.xmonad/autostart.sh"
  75. , layoutHook = layoutHook'
  76. , manageHook = manageHook'
  77. , logHook = myLogHook dzenTopBar >> fadeInactiveLogHook 0xdddddddd >> setWMName "LG3D"
  78. , normalBorderColor = colorNormalBorder
  79. , focusedBorderColor = colorFocusedBorder
  80. , borderWidth = 2
  81. }
  82.  
  83. -- Bar
  84. myLogHook :: Handle -> X ()
  85. myLogHook h = dynamicLogWithPP $ defaultPP
  86. {
  87. ppCurrent = dzenColor "#00CCFF" "#3c3c3c" . pad
  88. , ppVisible = dzenColor "white" "#3c3c3c" . pad
  89. , ppHidden = dzenColor "white" "#3c3c3c" . pad
  90. , ppHiddenNoWindows = dzenColor "#7b7b7b" "#3c3c3c" . pad
  91. , ppUrgent = dzenColor "red" "#3c3c3c" . pad
  92. , ppWsSep = " "
  93. , ppSep = " | "
  94. , ppLayout = dzenColor "#00CCFF" "#3c3c3c" .
  95. (\x -> case x of
  96. "ResizableTall" -> "^i(" ++ myBitmapsDir ++ "/tall.xbm)"
  97. "Mirror ResizableTall" -> "^i(" ++ myBitmapsDir ++ "/mtall.xbm)"
  98. "Full" -> "^i(" ++ myBitmapsDir ++ "/full.xbm)"
  99. "Simple Float" -> "~"
  100. _ -> x
  101. )
  102. , ppTitle = (" " ++) . dzenColor "white" "#3c3c3c" . dzenEscape
  103. , ppOutput = hPutStrLn h
  104. }
  105.  
  106. -- Hooks
  107. -- ManageHook
  108. manageHook' :: ManageHook
  109. manageHook' = (composeAll . concat $
  110. [[isFullscreen --> doFullFloat
  111. -- Ignores
  112. , className =? "stalonetray" --> doIgnore
  113. -- Floats
  114. , className =? "Xmessage" --> doCenterFloat
  115. , name =? "File Operation Progress" --> doCenterFloat
  116. , name =? "Wicd Connection Info" --> doCenterFloat
  117. -- Fullscreen floats
  118. --, className =? "VirtualBox" --> doFullFloat
  119. -- 1:main
  120. , className =? "Terminal" --> doShift "1:main"
  121. -- 2:random
  122. , className =? "Xchat" --> doShift "2:random"
  123. -- 3:media
  124. , className =? "xbmc" --> doShift "3:media"
  125. , className =? "vlc" --> doShift "3:media"
  126. , className =? "Sonata" --> doShift "3:media"
  127. -- 4:chat
  128. , className =? "Pidgin" --> doShift "4:chat"
  129. , className =? "Skype" --> doShift "4:chat"
  130. -- 5:web
  131. , className =? "Firefox" --> doShift "5:web"
  132. , className =? "Download" --> doShift "5:web"
  133. , name =? "Downloads" --> doShift "5:web"
  134. -- 6:doc
  135. , className =? "Texmaker" --> doShift "6:doc"
  136. , className =? "Epdfview" --> doShift "6:doc"
  137. , name=? "OpenOffice.org" --> doShift "6:doc"
  138. , fmap ("libreoffice" `isInfixOf`) className--> doShift "6:doc"
  139. -- 7:matlab
  140. , className =? "MATLAB" --> doShift "7:matlab"
  141. , name =? "MATLAB 7.12.0 (R2011a)" --> doShift "7:matlab"
  142. -- 8:windows
  143. , className =? "VirtualBox" --> doShift "8:windows"
  144. ]])
  145. where
  146. name = stringProperty "WM_NAME"
  147.  
  148. -- a trick for fullscreen but stil allow focusing of other WSs
  149. myDoFullFloat :: ManageHook
  150. myDoFullFloat = doF W.focusDown <+> doFullFloat
  151.  
  152. -- layoutHook' = customLayout
  153. layoutHook' = avoidStruts $ onWorkspaces ["5:web","6:doc","7:matlab"] myLayout2 $ onWorkspaces ["4:chat"] imLayout $ myLayout1
  154.  
  155. -- Layouts
  156. myLayout1 = smartBorders tiled ||| Grid ||| noBorders Full
  157. where
  158. tm = ResizableTall 1 (2/100) (1/2) []
  159. tiled = spacing pxl $ tm
  160. pxl = 3
  161.  
  162. myLayout2 = smartBorders tiled ||| noBorders Full
  163. where
  164. tm = ResizableTall 1 (2/100) (1/2) []
  165. tiled = spacing pxl $ tm
  166. pxl = 3
  167.  
  168. imLayout = withIM (1%5) (And (ClassName "Pidgin") (Role "buddy_list")) Grid
  169.  
  170. --gimpLayout = avoidStruts $ withIM (0.11) (Role "gimp-toolbox") $
  171. --reflectHoriz $
  172. -- withIM (0.15) (Role "gimp-dock") Full
  173.  
  174. -- Theming
  175. -- Color names
  176. colorCyan = "#00CCFF"
  177. colorOrange = "#FD971F"
  178. colorDarkGray = "#3c3c3c"
  179. colorPink = "#F92672"
  180. colorGreen = "#A6E22E"
  181. colorBlue = "#66D9EF"
  182. colorYellow = "#E6DB74"
  183. colorWhite = "#CCCCC6"
  184.  
  185. -- Border colors
  186. colorNormalBorder = "#CCCCC6"
  187. colorFocusedBorder = "#00CCFF"
  188.  
  189.  
  190. barFont = "terminus"
  191. barXFont = "inconsolata:size=14"
  192. xftFont = "xft: inconsolata-14"
  193. --}}}
  194.  
  195. -- Prompt Config {{{
  196. mXPConfig :: XPConfig
  197. mXPConfig =
  198. defaultXPConfig { font = barFont
  199. , bgColor = colorDarkGray
  200. , fgColor = colorCyan
  201. , bgHLight = colorCyan
  202. , fgHLight = colorDarkGray
  203. , promptBorderWidth = 0
  204. , height = 14
  205. , historyFilter = deleteConsecutive
  206. }
  207.  
  208. -- Run or Raise Menu
  209. largeXPConfig :: XPConfig
  210. largeXPConfig = mXPConfig
  211. { font = xftFont
  212. , height = 24
  213. }
  214. -- }}}
  215. -- Key mapping {{{
  216. keys' :: XConfig Layout -> M.Map (KeyMask, KeySym) (X ())
  217. keys' conf@(XConfig {XMonad.modMask = modMask}) = M.fromList $
  218. [ ((modMask, xK_p ), runOrRaisePrompt largeXPConfig)
  219. , ((modMask, xK_r ), spawn "gmrun")
  220. , ((modMask, xK_Return ), spawn $ XMonad.terminal conf) -- spawn terminal
  221. -- Programs
  222. , ((0, xK_Print ), spawn "scrot -e 'mv $f ~/Images/Screenshots/'")
  223. , ((modMask, xK_e ), spawn "thunar")
  224. , ((modMask, xK_z ), spawn "firefox")
  225. , ((modMask, xK_a ), spawn "pavucontrol")
  226. , ((modMask, xK_s ), spawn "sonata")
  227. , ((modMask, xK_m ), spawn "/usr/local/MATLAB/R2011a/bin/matlab -desktop")
  228. , ((modMask, xK_n ), spawn "texmaker")
  229. , ((modMask .|. shiftMask, xK_p ), spawn "pidgin")
  230. , ((modMask .|. shiftMask, xK_i ), spawn "xchat")
  231. , ((modMask .|. shiftMask, xK_s ), spawn "skype")
  232. , ((modMask .|. shiftMask, xK_w ), spawn "virtualbox")
  233. , ((modMask .|. shiftMask, xK_e ), spawn "scribes /home/yami/.xmonad/xmonad.hs")
  234. -- Media Keys
  235. , ((0, 0x1008ff12 ), spawn "amixer -q sset Master toggle") -- XF86AudioMute
  236. , ((0, 0x1008ff11 ), spawn "amixer -q sset Master 5%-") -- XF86AudioLowerVolume
  237. , ((0, 0x1008ff13 ), spawn "amixer -q sset Master 5%+ unmute") -- XF86AudioRaiseVolume
  238. , ((0, 0x1008ff14 ), spawn "sonata pp") -- XF86AudioPlay
  239. , ((0, 0x1008ff17 ), spawn "sonata next") -- XF86AudioNext
  240. , ((0, 0x1008ff16 ), spawn "sonata prev") -- XF86AudioPrevious
  241.  
  242. -- Switching screens
  243. , ((modMask .|. shiftMask, xK_z ), spawn "xrandr --output LVDS --mode 1600x900 --pos 0x0 --rotate normal --output CRT1 --off --output DFP2 --off --output DFP3 --off --output DFP1 --off && killall conky dzen2 stalonetray nitrogen && xmonad --restart && nitrogen --restore &")
  244. , ((modMask .|. shiftMask, xK_x ), spawn "xrandr --output LVDS --off --output CRT1 --off --output DFP2 --off --output DFP3 --off --output DFP1 --mode 1920x1080 --pos 0x0 --rotate normal && killall conky dzen2 stalonetray nitrogen && xmonad --restart && nitrogen --restore &")
  245.  
  246. -- layouts
  247. , ((modMask, xK_space ), sendMessage NextLayout)
  248. , ((modMask .|. shiftMask, xK_space ), setLayout $ XMonad.layoutHook conf) -- reset layout on current desktop to default
  249. , ((modMask, xK_b ), sendMessage ToggleStruts)
  250. , ((mod1Mask, xK_Tab ), windows W.focusDown) -- move focus to next window
  251. , ((modMask, xK_q ), kill) -- kill selected window
  252. , ((modMask .|. shiftMask, xK_j ), windows W.swapDown) -- swap the focused window with the next window
  253. , ((modMask .|. shiftMask, xK_k ), windows W.swapUp) -- swap the focused window with the previous window
  254. , ((modMask .|. shiftMask, xK_t ), withFocused $ windows . W.sink) -- Push window back into tiling
  255. , ((modMask, xK_u ), sendMessage Shrink) -- %! Shrink a master area
  256. , ((modMask, xK_i ), sendMessage Expand) -- %! Expand a master area
  257. , ((modMask, xK_j ), sendMessage MirrorShrink) -- %! Shrink a slave area
  258. , ((modMask, xK_k ), sendMessage MirrorExpand) -- %! Expand a slave area
  259.  
  260. -- increase or decrease number of windows in the master area
  261. , ((modMask , xK_comma ), sendMessage (IncMasterN 1))
  262. , ((modMask , xK_period ), sendMessage (IncMasterN (-1)))
  263.  
  264. -- workspaces
  265. , ((modMask, xK_Right ), nextWS)
  266. , ((modMask, xK_Left ), prevWS)
  267. , ((modMask .|. shiftMask, xK_Right ), shiftToNext) -- moves a window to the next workspace
  268. , ((modMask .|. shiftMask, xK_Left ), shiftToPrev) -- moves a windows to the previous workspace
  269.  
  270. -- quit, or restart
  271. , ((modMask .|. mod1Mask .|. shiftMask, xK_q ), io (exitWith ExitSuccess))
  272. , ((modMask .|. shiftMask, xK_r ), spawn "xmonad --recompile && killall stalonetray && xmonad --restart ")
  273. ]
  274. ++
  275. -- mod-[1..9] %! Switch to workspace N
  276. -- mod-shift-[1..9] %! Move client to workspace N
  277. [((m .|. modMask, k), windows $ f i)
  278. | (i, k) <- zip (XMonad.workspaces conf) [xK_1 .. xK_9]
  279. , (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]
  280. ]
  281. ++
  282. -- Switching workspace with the num pad keys
  283. [((m .|. modMask, k), windows $ f i)
  284. | (i, k) <- zip myWorkspaces numPadKeys
  285. , (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]
  286. ]
  287. where
  288. -- Non-numeric num pad keys, sorted by number
  289. numPadKeys = [ xK_KP_End, xK_KP_Down, xK_KP_Page_Down -- 1, 2, 3
  290. , xK_KP_Left, xK_KP_Begin, xK_KP_Right -- 4, 5, 6
  291. , xK_KP_Home, xK_KP_Up, xK_KP_Page_Up -- 7, 8, 9
  292. , xK_KP_Insert ] -- 0
  293.  
  294. --}}}
Add Comment
Please, Sign In to add comment