Guest User

Untitled

a guest
Jun 24th, 2018
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.22 KB | None | 0 0
  1. import XMonad
  2. import XMonad.Actions.CycleWS
  3. import XMonad.Actions.FloatKeys
  4. import XMonad.Config.Gnome
  5. import XMonad.Hooks.DynamicHooks
  6. import XMonad.Hooks.DynamicLog
  7. import XMonad.Hooks.FadeInactive
  8. import XMonad.Hooks.ManageDocks
  9. import XMonad.Hooks.UrgencyHook
  10. import XMonad.Layout.NoBorders
  11. import XMonad.Layout.LayoutHints
  12. import XMonad.Layout.PerWorkspace
  13. import XMonad.Layout.ResizableTile
  14. import XMonad.ManageHook
  15. import XMonad.Prompt
  16. import XMonad.Prompt.Shell
  17. import XMonad.Util.Run
  18. import Graphics.X11
  19. import System.Exit
  20. import System.IO
  21. import Data.Ratio ((%))
  22. import qualified Data.Map as M
  23. import qualified XMonad.Actions.FlexibleResize as Flex
  24. import qualified XMonad.StackSet as W
  25.  
  26. main = do
  27. dzen <- spawnPipe myStatusBar
  28. dynHooksRef <- initDynamicHooks
  29. xmonad $ myUrgencyHook $ gnomeConfig
  30. { terminal = "xfce4-terminal"
  31. , modMask = mod1Mask
  32. , borderWidth = 4
  33. , focusFollowsMouse = True
  34. , normalBorderColor = "#333333"
  35. , focusedBorderColor = "#1166ff"
  36. , layoutHook = myLayout
  37. , logHook = dynamicLogDzen
  38. -- , logHook = dynamicLogWithPP (myDzenPP dzen) >> fadeInactiveLogHook 0x99999999
  39. , manageHook = myManageHook <+> manageDocks <+> dynamicMasterHook dynHooksRef
  40. , workspaces = ["1:irc", "2:www", "3:music", "4:nicotine", "5:misc"]
  41. }
  42.  
  43. -- Color, font and iconpath definitions:
  44. myIconDir = "/home/carson/.dzen"
  45. myDzenFGColor = "#555555"
  46. myDzenBGColor = ""
  47. myNormalFGColor = "#ffffff"
  48. myNormalBGColor = "#0f0f0f"
  49. myFocusedFGColor = "#f0f0f0"
  50. myFocusedBGColor = "#333333"
  51. myUrgentFGColor = "#0099ff"
  52. myUrgentBGColor = "#0077ff"
  53. myIconFGColor = "#777777"
  54. myIconBGColor = ""
  55. mySeperatorColor = "#555555"
  56.  
  57. -- Statusbar options:
  58. -- myStatusBar = "dzen2 -x '0' -y '0' -h '16' -w '1300' -ta 'l' -fg '" ++ myNormalFGColor ++ "' -bg '" ++ myNormalBGColor
  59. myStatusBar = "dzen2"
  60.  
  61. -- Urgency hint options:
  62. myUrgencyHook = withUrgencyHook dzenUrgencyHook
  63. { args = ["-x", "0", "-y", "1184", "-h", "16", "-w", "1920", "-ta", "r", "-expand", "l", "-fg", "" ++ myUrgentFGColor ++ "", "-bg", "" ++ myNormalBGColor ++ ""] }
  64.  
  65. -- Layout options:
  66. myLayout = avoidStruts (smartBorders (tiled ||| Mirror tiled ||| Full))
  67. where
  68. tiled = Tall nmaster delta ratio
  69. nmaster = 1 -- The default number of windows in the master pane
  70. ratio = 7%11 -- Default proportion of screen occupied by master pane
  71. delta = 5%100 -- Percent of screen to increment by when resizing panes
  72.  
  73. -- myLayout = avoidStruts $ layoutHints $ onWorkspace "1:irc" (resizableTile ||| Mirror resizableTile) $ smartBorders (Full ||| resizableTile ||| Mirror resizableTile)
  74. -- where
  75. -- resizableTile = ResizableTall nmaster delta ratio []
  76. -- nmaster = 1
  77. -- ratio = toRational (2/(1+sqrt(5)::Double))
  78. -- delta = 3/100
  79.  
  80. -- -- Key bindings:
  81. -- myKeys dynHooksRef conf@(XConfig {XMonad.modMask = modMask}) = M.fromList $
  82. -- [ ((mod4Mask, xK_q), spawn "urxvt -e ssh and1@domain.net")
  83. -- , ((mod4Mask, xK_w), spawn "nitrogen --no-recurse --sort=alpha /home/and1/wallpapers/")
  84. -- , ((mod4Mask, xK_e), spawn "iceweasel")
  85. -- , ((mod4Mask, xK_r), oneShotHook dynHooksRef (className =? "URxvt") (doF $ (W.swapDown . W.shiftMaster)) >> spawn "urxvt")
  86. -- , ((mod4Mask .|. shiftMask, xK_r), oneShotHook dynHooksRef (className =? "URxvt") (doF $ (W.swapUp . W.shiftMaster)) >> spawn "urxvt")
  87. -- , ((mod4Mask, xK_o), spawn "openoffice")
  88. -- , ((mod4Mask, xK_p), shellPrompt myXPConfig)
  89. -- , ((mod4Mask, xK_d), spawn "date +'%Y-%m-%d %H:%M' | osd_cat -p bottom -A center -s 2 -c '#a10a30' -f '-xos4-terminus-medium-r-normal-*-140-*-*-*-c-*-iso10646-1'")
  90. -- , ((mod4Mask .|. shiftMask, xK_d), spawn "date +'%H:%M' | osd_cat -p middle -A center -s 2 -c '#a10a30' -f '-xos4-terminus-medium-r-normal-*-140-*-*-*-c-*-iso10646-1'")
  91. -- , ((mod4Mask, xK_f), oneShotHook dynHooksRef (className =? "URxvt") doFloat >> spawn "urxvt -g 120x40+930+40")
  92. -- , ((mod4Mask .|. shiftMask, xK_f), oneShotHook dynHooksRef (className =? "URxvt") doFloat >> spawn "urxvt -g 180x10+20+1020")
  93. -- , ((mod4Mask, xK_g), spawn "gimp")
  94. -- , ((mod4Mask, xK_k), spawn "k3b")
  95. -- , ((mod4Mask, xK_l), spawn "slock")
  96. -- , ((mod4Mask, xK_x), spawn "schroot -p gmpc")
  97. -- , ((mod4Mask, xK_v), spawn "virtualbox")
  98. -- , ((mod4Mask, xK_n), spawn "nicotine")
  99. -- , ((mod4Mask, xK_Print), spawn "scrot screen_%Y-%m-%d.png -d 1") -- take screenshot
  100. -- , ((modMask .|. controlMask, xK_Home), spawn "mpc toggle") -- play/pause song
  101. -- , ((modMask .|. controlMask, xK_End), spawn "mpc stop") -- stop playback
  102. -- , ((modMask .|. controlMask, xK_Prior), spawn "mpc prev") -- previous song
  103. -- , ((modMask .|. controlMask, xK_Next), spawn "mpc next") -- next song
  104. -- , ((modMask, xK_Tab), windows W.focusDown) -- move focus to the next window
  105. -- , ((modMask, xK_j), windows W.focusUp) -- move focus to the previous window
  106. -- , ((modMask, xK_k), windows W.focusDown) -- move focus to the next window
  107. -- , ((modMask, xK_n), refresh) -- resize viewed windows to the correct size
  108. -- , ((modMask, xK_m), windows W.swapMaster) -- swap the focused window and the master window
  109. -- , ((modMask, xK_comma), sendMessage (IncMasterN 1)) -- increment the number of windows in the master area
  110. -- , ((modMask, xK_period), sendMessage (IncMasterN (-1))) -- deincrement the number of windows in the master area
  111. -- , ((modMask, xK_Return), windows W.focusMaster) -- move focus to the master window
  112. -- , ((modMask, xK_f), sendMessage NextLayout) -- rotate through the available layout algorithms
  113. -- , ((modMask .|. shiftMask, xK_Tab), windows W.focusUp) -- move focus to the previous window
  114. -- , ((modMask .|. shiftMask, xK_h), sendMessage Shrink) -- shrink the master area
  115. -- , ((modMask .|. shiftMask, xK_j), windows W.swapUp) -- swap the focused window with the previous window
  116. -- , ((modMask .|. shiftMask, xK_k), windows W.swapDown) -- swap the focused window with the next window
  117. -- , ((modMask .|. shiftMask, xK_l), sendMessage Expand) -- expand the master area
  118. -- , ((modMask .|. shiftMask, xK_Return), focusUrgent) -- move focus to urgent window
  119. -- , ((modMask .|. shiftMask, xK_Left), withFocused (keysResizeWindow (-30,0) (0,0))) -- shrink floated window horizontally by 50 pixels
  120. -- , ((modMask .|. shiftMask, xK_Right), withFocused (keysResizeWindow (30,0) (0,0))) -- expand floated window horizontally by 50 pixels
  121. -- , ((modMask .|. shiftMask, xK_Up), withFocused (keysResizeWindow (-30,-30) (0,0))) -- shrink floated window by 50 pixels
  122. -- , ((modMask .|. shiftMask, xK_Down), withFocused (keysResizeWindow (30,30) (0,0))) -- expand floated window by 50 pixels
  123. -- , ((modMask .|. controlMask, xK_q), io (exitWith ExitSuccess)) -- quit xmonad
  124. -- , ((modMask .|. controlMask, xK_r), spawn "killall conky dzen2 && sleep 0.5" >> restart "xmonad" True) -- restart xmonad
  125. -- , ((modMask .|. controlMask, xK_d), withFocused $ windows . W.sink) -- push window back into tiling
  126. -- , ((modMask .|. controlMask, xK_f), setLayout $ XMonad.layoutHook conf) -- reset the layouts on the current workspace to default
  127. -- , ((modMask .|. controlMask, xK_h), sendMessage MirrorExpand) -- expand the height/wide
  128. -- , ((modMask .|. controlMask, xK_j), windows W.swapUp) -- swap the focused window with the previous window
  129. -- , ((modMask .|. controlMask, xK_k), windows W.swapDown) -- swap the focused window with the next window
  130. -- , ((modMask .|. controlMask, xK_l), sendMessage MirrorShrink) -- shrink the height/wide
  131. -- , ((modMask .|. controlMask, xK_x), kill) -- close focused window
  132. -- , ((modMask .|. controlMask, xK_Left), withFocused (keysMoveWindow (-30,0))) -- move floated window 10 pixels left
  133. -- , ((modMask .|. controlMask, xK_Right), withFocused (keysMoveWindow (30,0))) -- move floated window 10 pixels right
  134. -- , ((modMask .|. controlMask, xK_Up), withFocused (keysMoveWindow (0,-30))) -- move floated window 10 pixels up
  135. -- , ((modMask .|. controlMask, xK_Down), withFocused (keysMoveWindow (0,30))) -- move floated window 10 pixels down
  136. -- ]
  137. -- ++
  138. -- [ ((m .|. modMask, k), windows $ f i)
  139. -- | (i, k) <- zip (XMonad.workspaces conf) [xK_F1 .. xK_F9] -- mod-[F1..F9], switch to workspace n
  140. -- , (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)] -- mod-shift-[F1..F9], move window to workspace n
  141. -- ]
  142. -- ++
  143. -- [ ((m .|. modMask, key), screenWorkspace sc >>= flip whenJust (windows . f))
  144. -- | (key, sc) <- zip [xK_F10, xK_F11, xK_F12] [0..] -- mod-{F10,F11,F12}, switch to physical/Xinerama screens 1, 2, or 3
  145. -- , (f, m) <- [(W.view, 0), (W.shift, shiftMask)] -- mod-shift-{F10,F11,F12}, move window to screen 1, 2, or 3
  146. -- ]
  147. --
  148.  
  149. -- Window rules:
  150. myManageHook = composeAll . concat $
  151. [ [className =? c --> doFloat | c <- myCFloats]
  152. , [title =? t --> doFloat | t <- myTFloats]
  153. , [resource =? r --> doFloat | r <- myRFloats]
  154. , [className =? "Iceweasel" --> doShift "2:www"]
  155. , [className =? "Gmpc" --> doShift "3:music"]
  156. , [className =? "Nicotine" --> doShift "4:nicotine"]
  157. , [className =? "Gimp" --> doShift "5:misc"]
  158. , [className =? "K3b" --> doShift "5:misc"]
  159. , [className =? "tmw" --> doShift "5:misc"]
  160. , [className =? "VirtualBox" --> doShift "5:misc"]
  161. , [className =? "Wine" --> doShift "5:misc"]
  162. , [title =? "MusicBrainz Picard" --> doShift "5:misc"]
  163. ]
  164. where
  165. myCFloats = ["Ekiga", "Gimp", "MPlayer", "Nitrogen", "Nvidia-settings", "XCalc", "XFontSel", "Xmessage", "xmms"]
  166. myTFloats = ["Downloads", "Iceweasel Preferences", "Save As..."]
  167. myRFloats = []
  168.  
  169. -- dynamicLog pretty printer for dzen:
  170. myDzenPP h = defaultPP
  171. { ppCurrent = wrap ("^fg(" ++ myUrgentFGColor ++ ")^bg(" ++ myFocusedBGColor ++ ")^p()^i(" ++ myIconDir ++ "/corner.xbm)^fg(" ++ myNormalFGColor ++ ")") "^fg()^bg()^p()" . \wsId -> if (':' `elem` wsId) then drop 2 wsId else wsId
  172. , ppVisible = wrap ("^fg(" ++ myNormalFGColor ++ ")^bg(" ++ myFocusedBGColor ++ ")^p()^i(" ++ myIconDir ++ "/corner.xbm)^fg(" ++ myNormalFGColor ++ ")") "^fg()^bg()^p()" . \wsId -> if (':' `elem` wsId) then drop 2 wsId else wsId
  173. , ppHidden = wrap ("^i(" ++ myIconDir ++ "/corner.xbm)") "^fg()^bg()^p()" . \wsId -> if (':' `elem` wsId) then drop 2 wsId else wsId -- don't use ^fg() here!!
  174. , ppHiddenNoWindows = wrap ("^fg(" ++ myDzenFGColor ++ ")^bg()^p()^i(" ++ myIconDir ++ "/corner.xbm)") "^fg()^bg()^p()" . \wsId -> if (':' `elem` wsId) then drop 2 wsId else wsId
  175. , ppUrgent = wrap ("^fg(" ++ myUrgentFGColor ++ ")^bg()^p()") "^fg()^bg()^p()" . \wsId -> if (':' `elem` wsId) then drop 2 wsId else wsId
  176. , ppSep = " "
  177. , ppWsSep = " "
  178. , ppTitle = dzenColor ("" ++ myNormalFGColor ++ "") "" . wrap "< " " >"
  179. , ppLayout = dzenColor ("" ++ myNormalFGColor ++ "") "" .
  180. (\x -> case x of
  181. "Hinted Full" -> "^fg(" ++ myIconFGColor ++ ")^i(" ++ myIconDir ++ "/layout-full.xbm)"
  182. "Hinted ResizableTall" -> "^fg(" ++ myIconFGColor ++ ")^i(" ++ myIconDir ++ "/layout-tall-right.xbm)"
  183. "Hinted Mirror ResizableTall" -> "^fg(" ++ myIconFGColor ++ ")^i(" ++ myIconDir ++ "/layout-mirror-bottom.xbm)"
  184. _ -> x
  185. )
  186. , ppOutput = hPutStrLn h
  187. }
Add Comment
Please, Sign In to add comment