xmonad-qwerty.hs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459
  1. --
  2. -- xmonad example config file.
  3. --
  4. -- A template showing all available configuration hooks,
  5. -- and how to override the defaults in your own xmonad.hs conf file.
  6. --
  7. -- Normally, you'd only override those defaults you care about.
  8. --
  9. import XMonad
  10. import System.Exit
  11. import System.IO
  12. import XMonad.Util.Run
  13. import XMonad.Util.Scratchpad
  14. import XMonad.Util.Loggers
  15. import XMonad.Actions.WindowBringer
  16. import XMonad.Layout.WindowNavigation
  17. -- import XMonad.Config.Azerty
  18. import XMonad.Hooks.DynamicLog
  19. import XMonad.Hooks.ManageDocks
  20. --import XMonad.Util.EZConfig(additionalKeys)
  21. import Graphics.X11.ExtraTypes.XF86
  22. import XMonad.Hooks.EwmhDesktops
  23. import XMonad.Hooks.SetWMName
  24. import XMonad.Hooks.ManageHelpers
  25. import XMonad.Layout.MosaicAlt
  26. import XMonad.Layout.ResizableTile
  27. import XMonad.Layout.Tabbed
  28. import XMonad.Layout.NoBorders
  29. import XMonad.Layout.Grid
  30. --import XMonad.Layout.TwoPane
  31. import XMonad.Layout.Fullscreen
  32. import XMonad.Layout.Maximize
  33. -- fullscreen attempt:
  34. --import XMonad.Layout.Spacing
  35. --import XMonad.Layout.Gaps
  36. --import XMonad.Layout.ResizableTile
  37. -----import XMonad.Layout.NoBorders
  38. --import XMonad.Layout.Fullscreen (fullscreenFull)
  39. --import XMonad.Layout.Cross(simpleCross)
  40. --import XMonad.Layout.Spiral(spiral)
  41. --import XMonad.Layout.ThreeColumns
  42. --import XMonad.Layout.MultiToggle
  43. --import XMonad.Layout.MultiToggle.Instances
  44. --import XMonad.Layout.IndependentScreens
  45. -- import System.Cmd
  46. import System.Process
  47. import qualified XMonad.StackSet as W
  48. import qualified Data.Map as M
  49. -- The preferred terminal program, which is used in a binding below and by
  50. -- certain contrib modules.
  51. --
  52. myTerminal = "uxterm -bg \"grey10\" -fg grey +sb"
  53. myUrxvt = "urxvt -bg \"grey10\" -fg grey +sb"
  54. myBrowser = "firefox"
  55. myChat = "pidgin"
  56. myExecuteCommand = "gmrun"
  57. myPassCommand = "passmenu"
  58. myFileManager = "ranger"
  59. myMail = "uxterm -e mutt" -- -F ~/.muttrc.enstb"
  60. myLock = "xautolock -time 3 -locker 'i3lock -d -i ~/images/gentoo/gentoo-larry-bg-1280x800.png -t' & xautolock -locknow -locker 'i3lock -d -i ~/images/gentoo/gentoo-larry-bg-1280x800.png -t'"
  61. myImgurScreenshot = "imgur-screenshot.sh" -- && mplayer /usr/share/sounds/freedesktop/stereo/screen-capture.oga"
  62. myPointer = "find-cursor --size 150 --distance 40 --wait 400 --line-width 4 --color red"
  63. -- Width of the window border in pixels.
  64. --
  65. myBorderWidth = 1
  66. -- modMask lets you specify which modkey you want to use. The default
  67. -- is mod1Mask ("left alt"). You may also consider using mod3Mask
  68. -- ("right alt"), which does not conflict with emacs keybindings. The
  69. -- "windows key" is usually mod4Mask.
  70. --
  71. myModMask = mod1Mask
  72. myAltModMask = mod4Mask
  73. -- The mask for the numlock key. Numlock status is "masked" from the
  74. -- current modifier status, so the keybindings will work with numlock on or
  75. -- off. You may need to change this on some systems.
  76. --
  77. -- You can find the numlock modifier by running "xmodmap" and looking for a
  78. -- modifier with Num_Lock bound to it:
  79. --
  80. -- > $ xmodmap | grep Num
  81. -- > mod2 Num_Lock (0x4d)
  82. --
  83. -- Set numlockMask = 0 if you don't have a numlock key, or want to treat
  84. -- numlock status separately.
  85. --
  86. myNumlockMask = mod2Mask
  87. -- The default number of workspaces (virtual screens) and their names.
  88. -- By default we use numeric strings, but any string may be used as a
  89. -- workspace name. The number of workspaces is determined by the length
  90. -- of this list.
  91. --
  92. -- A tagging example:
  93. --
  94. -- > workspaces = ["web", "irc", "code" ] ++ map show [4..9]
  95. --
  96. --myWorkspaces = ["1","2","3","4","5","utils","web","mail","chat"]
  97. myWorkspaces = ["1","2","3","4","5","6","7","8","9"]
  98. --myWorkspaces = ["\61612","\61899","\61947","\61635","\61502","\61501","\61705","\61564","\62150","\61872"]
  99. -- Border colors for unfocused and focused windows, respectively.
  100. --
  101. myNormalBorderColor = "#006633" --"#0033cc" -- "#dddddd"
  102. myFocusedBorderColor = "#ff0000"
  103. ------------------------------------------------------------------------
  104. -- Key bindings. Add, modify or remove key bindings here.
  105. --
  106. myKeys conf@(XConfig {XMonad.modMask = modMask}) = M.fromList $
  107. -- launch a terminal
  108. [ ((modMask .|. shiftMask, xK_Return), spawn $ XMonad.terminal conf)
  109. , ((myAltModMask .|. shiftMask, xK_Return), spawn $ XMonad.terminal conf)
  110. -- my custom bindings
  111. , ((myAltModMask, xK_u), spawn $ XMonad.terminal conf)
  112. , ((myAltModMask, xK_a), spawn $ myUrxvt)
  113. , ((myAltModMask, xK_f), spawn $ myBrowser)
  114. -- , ((myAltModMask, xK_k), spawn $ myBrowser2)
  115. -- , ((myAltModMask, xK_c), spawn $ myBrowser3)
  116. , ((myAltModMask, xK_g), spawn $ myChat)
  117. , ((myAltModMask, xK_t), spawn $ myMail)
  118. -- , ((myAltModMask .|. shiftMask, xK_s), spawn $ mySSH)
  119. , ((myAltModMask, xK_x), spawn $ myExecuteCommand)
  120. , ((myAltModMask, xK_z), spawn $ myPassCommand )
  121. , ((myAltModMask, xK_m), spawn $ myFileManager)
  122. , ((myAltModMask, xK_l), spawn $ myLock)
  123. -- attempt to have something with fullscreen:
  124. -- , ((myAltModMask, xK_b), sendMessage ToggleGaps >> spawn "polybar-msg cmd toggle")
  125. , ((myAltModMask, xK_c), spawn $ myImgurScreenshot)
  126. , ((myAltModMask, xK_p), spawn $ myPointer)
  127. -- touche PrintScr keysym 0xff61, Print
  128. , ((0, 0xff61), spawn $ myPointer)
  129. -- https://superuser.com/questions/389737/how-do-you-make-volume-keys-and-mute-key-work-in-xmonad
  130. -- launch dmenu
  131. , ((modMask, xK_p ), spawn "exe=`dmenu_path | dmenu` && eval \"exec $exe\"")
  132. -- scratch pad
  133. , ((modMask, xK_backslash), scratchpadSpawnAction conf)
  134. , ((modMask, xK_0), scratchpadSpawnAction conf)
  135. , ((myAltModMask, xK_backslash), scratchpadSpawnAction conf)
  136. , ((myAltModMask, xK_0), scratchpadSpawnAction conf)
  137. --"zooming" (import Maximize
  138. , ((modMask, xK_b), withFocused ( sendMessage . maximizeRestore))
  139. , ((myAltModMask, xK_b), withFocused ( sendMessage . maximizeRestore))
  140. --test
  141. , ((myAltModMask, 0x69), scratchpadSpawnAction conf)
  142. --, ((myAltModMask, 0xffeb), scratchpadSpawnAction conf)
  143. , ((myAltModMask, 0xe0), scratchpadSpawnAction conf)
  144. , ((modMask, 0xe0), scratchpadSpawnAction conf)
  145. -- window navigation
  146. --, ((modMask, xK_Right), sendMessage $ Go R)
  147. --, ((modMask, xK_Left ), sendMessage $ Go L)
  148. --, ((modMask, xK_Up ), sendMessage $ Go U)
  149. --, ((modMask, xK_Down ), sendMessage $ Go D)
  150. --, ((modMask .|. controlMask, xK_Right), sendMessage $ Swap R)
  151. --, ((modMask .|. controlMask, xK_Left ), sendMessage $ Swap L)
  152. --, ((modMask .|. controlMask, xK_Up ), sendMessage $ Swap U)
  153. --, ((modMask .|. controlMask, xK_Down ), sendMessage $ Swap D)
  154. -- launch xlock
  155. , ((modMask .|. controlMask, xK_l ), spawn myLock)
  156. , ((myAltModMask .|. controlMask, xK_l ), spawn myLock)
  157. -- launch gmrun
  158. , ((modMask .|. shiftMask, xK_x ), spawn "gmrun")
  159. -- imgur-screenshot
  160. , ((modMask .|. shiftMask, xK_c ), spawn myImgurScreenshot)
  161. -- find-cursor
  162. , ((modMask .|. shiftMask, xK_p ), spawn myPointer)
  163. -- close focused window
  164. , ((modMask .|. shiftMask, xK_c ), kill)
  165. --, ((myAltModMask .|. shiftMask, xK_c ), kill)
  166. -- Rotate through the available layout algorithms
  167. , ((modMask, xK_space ), sendMessage NextLayout)
  168. --, ((myAltModMask, xK_space ), sendMessage NextLayout)
  169. -- Reset the layouts on the current workspace to default
  170. , ((modMask .|. shiftMask, xK_space ), setLayout $ XMonad.layoutHook conf)
  171. --, ((myAltModMask .|. shiftMask, xK_space ), setLayout $ XMonad.layoutHook conf)
  172. -- Resize viewed windows to the correct size
  173. , ((modMask, xK_n ), refresh)
  174. --, ((myAltModMask, xK_n ), refresh)
  175. -- Move focus to the next window
  176. , ((modMask, xK_Tab ), windows W.focusDown)
  177. --, ((myAltModMask, xK_Tab ), windows W.focusDown)
  178. -- Move focus to the next window
  179. , ((modMask, xK_j ), windows W.focusDown)
  180. --, ((myAltModMask, xK_j ), windows W.focusDown)
  181. -- Move focus to the previous window
  182. , ((modMask, xK_k ), windows W.focusUp )
  183. --, ((myAltModMask, xK_k ), windows W.focusUp )
  184. -- Move focus to the master window
  185. , ((modMask, xK_m ), windows W.focusMaster )
  186. --, ((myAltModMask, xK_m ), windows W.focusMaster )
  187. -- Swap the focused window and the master window
  188. , ((modMask, xK_Return), windows W.swapMaster)
  189. -- ((myAltModMask, xK_Return), windows W.swapMaster)
  190. -- Swap the focused window with the next window
  191. , ((modMask .|. shiftMask, xK_j ), windows W.swapDown )
  192. --, ((myAltModMask .|. shiftMask, xK_j ), windows W.swapDown )
  193. -- Swap the focused window with the previous window
  194. , ((modMask .|. shiftMask, xK_k ), windows W.swapUp )
  195. --, ((myAltModMask .|. shiftMask, xK_k ), windows W.swapUp )
  196. -- Shrink the master area
  197. , ((modMask, xK_h ), sendMessage Shrink)
  198. --, ((myAltModMask, xK_h ), sendMessage Shrink)
  199. -- Expand the master area
  200. , ((modMask, xK_l ), sendMessage Expand)
  201. --, ((myAltModMask, xK_l ), sendMessage Expand)
  202. -- Push window back into tiling
  203. , ((modMask, xK_t ), withFocused $ windows . W.sink)
  204. --, ((myAltModMask, xK_t ), withFocused $ windows . W.sink)
  205. -- Increment the number of windows in the master area
  206. , ((modMask , xK_comma ), sendMessage (IncMasterN 1))
  207. --, ((myAltModMask, xK_comma ), sendMessage (IncMasterN 1))
  208. -- Deincrement the number of windows in the master area
  209. , ((modMask , xK_period), sendMessage (IncMasterN (-1)))
  210. --, ((myAltModMask, xK_period), sendMessage (IncMasterN (-1)))
  211. -- toggle the status bar gap
  212. -- TODO, update this binding with avoidStruts , ((modMask , xK_b ),
  213. -- Quit xmonad
  214. , ((modMask .|. shiftMask, xK_q ), io (exitWith ExitSuccess))
  215. -- Restart xmonad
  216. , ((modMask , xK_q ), restart "xmonad" True)
  217. ]
  218. ++
  219. -- function keys
  220. [(( 0, xF86XK_AudioLowerVolume ), spawn "amixer set Master 2-")
  221. , ((0, xF86XK_AudioRaiseVolume ), spawn "amixer set Master 2+")
  222. , ((0, xF86XK_AudioMute ), spawn "amixer set Master toggle")
  223. --, ((0, xF86XK_AudioMicMute ), spawn "amixer set ")
  224. , ((0, xF86XK_MonBrightnessUp ), spawn "xbacklight -inc 5")
  225. , ((0, xF86XK_MonBrightnessDown), spawn "xbacklight -dec 5")
  226. ]
  227. ++
  228. --
  229. -- mod-[1..9], Switch to workspace N
  230. -- mod-shift-[1..9], Move client to workspace N
  231. --
  232. [((m .|. modMask, k), windows $ f i)
  233. | (i, k) <- zip (XMonad.workspaces conf) [xK_1 .. xK_9]
  234. , (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]]
  235. ++
  236. [((m .|. myAltModMask, k), windows $ f i)
  237. | (i, k) <- zip (XMonad.workspaces conf) [xK_1 .. xK_9]
  238. , (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]]
  239. ++
  240. --
  241. -- mod-{w,e,r}, Switch to physical/Xinerama screens 1, 2, or 3
  242. -- mod-shift-{w,e,r}, Move client to screen 1, 2, or 3
  243. --
  244. [((m .|. modMask, key), screenWorkspace sc >>= flip whenJust (windows . f))
  245. | (key, sc) <- zip [xK_w, xK_e, xK_r] [0..]
  246. , (f, m) <- [(W.view, 0), (W.shift, shiftMask)]]
  247. ++
  248. [((m .|. myAltModMask, key), screenWorkspace sc >>= flip whenJust (windows . f))
  249. | (key, sc) <- zip [xK_w, xK_e, xK_r] [0..]
  250. , (f, m) <- [(W.view, 0), (W.shift, shiftMask)]]
  251. ------------------------------------------------------------------------
  252. -- Mouse bindings: default actions bound to mouse events
  253. --
  254. myMouseBindings (XConfig {XMonad.modMask = modMask}) = M.fromList $
  255. -- mod-button1, Set the window to floating mode and move by dragging
  256. [ ((modMask, button1), (\w -> focus w >> mouseMoveWindow w))
  257. -- mod-button2, Raise the window to the top of the stack
  258. , ((modMask, button2), (\w -> focus w >> windows W.swapMaster))
  259. -- mod-button3, Set the window to floating mode and resize by dragging
  260. , ((modMask, button3), (\w -> focus w >> mouseResizeWindow w))
  261. -- you may also bind events to the mouse scroll wheel (button4 and button5)
  262. ]
  263. ------------------------------------------------------------------------
  264. -- Layouts:
  265. -- You can specify and transform your layouts by modifying these values.
  266. -- If you change layout bindings be sure to use 'mod-shift-space' after
  267. -- restarting (with 'mod-q') to reset your layout state to the new
  268. -- defaults, as xmonad preserves your old layout settings by default.
  269. --
  270. -- The available layouts. Note that each layout is separated by |||,
  271. -- which denotes layout choice.
  272. --
  273. myLayout = smartBorders $ maximize (tiled ||| Mirror tiled ||| simpleTabbed ||| Full) -- ||| Grid
  274. -- fullscreen attempt
  275. --myLayout = spacingRaw True (Border 0 5 5 5) True (Border 5 5 5 5) True $ mkToggle (NBFULL ?? NOBORDERS ?? EOT) $ tiled ||| Mirror tiled ||| spiral (6/7) ||| ThreeColMid 1 (3/100) (1/2) ||| Full
  276. --myLayout = avoidStruts (tiled ||| Mirror tiled ||| Full) ||| Full
  277. where
  278. -- default tiling algorithm partitions the screen into two panes
  279. tiled = Tall nmaster delta ratio
  280. -- The default number of windows in the master pane
  281. nmaster = 1
  282. -- Default proportion of screen occupied by master pane
  283. ratio = 1/2
  284. -- Percent of screen to increment by when resizing panes
  285. delta = 3/100
  286. ------------------------------------------------------------------------
  287. -- Window rules:
  288. -- Execute arbitrary actions and WindowSet manipulations when managing
  289. -- a new window. You can use this to, for example, always float a
  290. -- particular program, or have a client always appear on a particular
  291. -- workspace.
  292. --
  293. -- To find the property name associated with a program, use
  294. -- > xprop | grep WM_CLASS
  295. -- and click on the client you're interested in.
  296. --
  297. -- To match on the WM_NAME, you can use 'title' in the same way that
  298. -- 'className' and 'resource' are used below.
  299. --
  300. myManageHook = composeAll
  301. [ className =? "MPlayer" --> doFloat
  302. , className =? "Gimp" --> doFloat
  303. , className =? "Gmrun" --> doFloat
  304. , className =? "stalonetray" --> doIgnore
  305. , resource =? "desktop_window" --> doIgnore
  306. , resource =? "kdesktop" --> doIgnore ]
  307. -- Whether focus follows the mouse pointer.
  308. myFocusFollowsMouse :: Bool
  309. myFocusFollowsMouse = True
  310. ------------------------------------------------------------------------
  311. -- Status bars and logging
  312. -- Perform an arbitrary action on each internal state change or X event.
  313. -- See the 'DynamicLog' extension for examples.
  314. --
  315. -- To emulate dwm's status bar
  316. --
  317. -- > logHook = dynamicLogDzen
  318. myLogHook dest = do
  319. dynamicLogWithPP $ xmobarPP
  320. { ppOutput = hPutStrLn dest
  321. , ppTitle = xmobarColor "green" "" . shorten 100 --50
  322. , ppSort = fmap (. scratchpadFilterOutWorkspace) $ ppSort xmobarPP
  323. , ppVisible = \x -> ""
  324. , ppHidden = \x -> ""
  325. , ppLayout = \x -> ""
  326. }
  327. ------------------------------------------------------------------------
  328. -- Startup hook
  329. -- Perform an arbitrary action each time xmonad starts or is restarted
  330. -- with mod-q. Used by, e.g., XMonad.Layout.PerWorkspace to initialize
  331. -- per-workspace layout choices.
  332. --
  333. -- By default, do nothing.
  334. -- myStartupHook = return ()
  335. -- old way to lie to Java about what window manager is used. Warning: break
  336. -- recent version of gtk3, use _JAVA_AWT_WM_NONREPARENTING=1 variable instead
  337. -- myStartupHook = setWMName "LG3D"
  338. myStartupHook = do
  339. spawn "xsetroot -cursor_name right_ptr"
  340. spawn "feh --bg-tile /home/jcbach/.wallpapers/wallpaper.jpg"
  341. -- spawn "sh ~/.TouchScreen.sh stop"
  342. spawn "[[ -f ~/.Xresources ]] && xrdb -merge ~/.Xresources"
  343. spawn "xmodmap ~/.Xmodmap"
  344. spawn "$HOME/keyboards.sh"
  345. spawn "xhost +local:root"
  346. -- location = IMTA (Plouzane)
  347. spawn "ps cax | grep redshift &>1 ; if ! [ $? -eq 0 ]; then redshift -l 48.35865:-4.57096 -t 6500:3700; fi"
  348. spawn "ps cax | grep stalonetray ; if ! [ $? -eq 0 ]; then stalonetray; fi"
  349. spawn "xautolock -time 3 -locker 'i3lock -d -i ~/images/gentoo/gentoo-larry-bg-1280x800.png -t'"
  350. -- spawn "ps cax | grep ssh-agent &>1 ; if ! [ $? -eq 0 ]; then ssh-agent;fi"
  351. spawn "nm-applet"
  352. ------------------------------------------------------------------------
  353. -- Now run xmonad with all the defaults we set up.
  354. -- Run xmonad with the settings you specify. No need to modify this.
  355. --
  356. main = do
  357. xmproc <- spawnPipe "xmobar $XDG_CONFIG_HOME/xmobar/xmobarrc"
  358. xmonad $ fullscreenSupport $ def {
  359. -- simple stuff
  360. terminal = myTerminal,
  361. focusFollowsMouse = myFocusFollowsMouse,
  362. borderWidth = myBorderWidth,
  363. modMask = myModMask,
  364. --numlockMask = myNumlockMask,
  365. workspaces = myWorkspaces,
  366. normalBorderColor = myNormalBorderColor,
  367. focusedBorderColor = myFocusedBorderColor,
  368. -- key bindings
  369. keys = myKeys,
  370. mouseBindings = myMouseBindings,
  371. -- hooks, layouts
  372. manageHook = myManageHook,
  373. layoutHook = avoidStruts myLayout,
  374. --layoutHook = smartBorders . avoidStruts $ myLayout,
  375. handleEventHook = mconcat [ handleEventHook def ],
  376. logHook = myLogHook xmproc,
  377. --logHook = dynamicLogWithPP $ xmobarPP {
  378. startupHook = myStartupHook
  379. }
  380. -- A structure containing your configuration settings, overriding
  381. -- fields in the default config. Any you don't override, will
  382. -- use the defaults defined in xmonad/XMonad/Config.hs
  383. --
  384. -- No need to modify this.