xmonad-bepo.hs 18 KB

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