xmonad.hs 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. import XMonad
  2. import XMonad.Config.Desktop
  3. import XMonad.Hooks.DynamicLog
  4. import XMonad.Hooks.ManageDocks
  5. import XMonad.Util.Run(spawnPipe, hPutStrLn, runProcessWithInput)
  6. import XMonad.Util.EZConfig(additionalKeys)
  7. -- For shutdown commands and keys
  8. import Data.Map(fromList)
  9. import XMonad.Prompt
  10. import XMonad.Prompt.XMonad
  11. import System.Exit(ExitCode(ExitSuccess), exitWith)
  12. -- Brightness and audio keys
  13. import Graphics.X11.ExtraTypes.XF86
  14. main = do
  15. xmproc <- spawnPipe "xmobar"
  16. xmonad $ docks defaultConfig
  17. { manageHook = manageDocks <+> manageHook defaultConfig
  18. , layoutHook = avoidStruts $ layoutHook defaultConfig
  19. , logHook = dynamicLogWithPP xmobarPP
  20. { ppOutput = hPutStrLn xmproc
  21. , ppTitle = xmobarColor "green" "" . shorten 50
  22. }
  23. , startupHook = startup
  24. , terminal = "gnome-terminal"
  25. , modMask = mod4Mask
  26. } `additionalKeys`
  27. [
  28. -- scrot
  29. ((controlMask, xK_Print), spawn "sleep 0.2; scrot -s")
  30. , ((0, xK_Print), spawn "scrot")
  31. -- rofi
  32. , ((mod4Mask, xK_p ), spawn "rofi -show run")
  33. -- shutdown
  34. , ((mod4Mask .|. shiftMask, xK_q),
  35. xmonadPrompt defaultXPConfig
  36. { promptKeymap = fromList
  37. [ ((0, xK_r), do
  38. spawn "emacsclient -e '(kill emacs)'"
  39. spawn "systemctl reboot")
  40. , ((0 , xK_s), do
  41. spawn "emacsclient -e '(kill emacs)'"
  42. spawn "sudo poweroff")
  43. , ((0, xK_e), do
  44. spawn "emacsclient -e '(kill emacs)'"
  45. io $ exitWith ExitSuccess)
  46. , ((0, xK_l), do
  47. spawn "xscreensaver-command -lock"
  48. quit)
  49. , ((0, xK_z), do
  50. spawn "xscreensaver-command -lock"
  51. spawn "systemctl suspend"
  52. quit)
  53. , ((0, xK_Escape), quit)
  54. ]
  55. , defaultText = "(r) Reboot, (s) Shutdown, (e) Exit, (l) Lock, (z) Sleep"
  56. })
  57. -- pulseaudio
  58. -- brightness
  59. , ((0, xF86XK_MonBrightnessUp),
  60. let
  61. returnValM = fmap init $ runProcessWithInput "xbacklight" [] ""
  62. in do
  63. currentBrightness <- returnValM
  64. if (read currentBrightness :: Double) == 0 then
  65. spawn "xbacklight -set 2"
  66. else
  67. spawn "xbacklight -inc 5")
  68. , ((0, xF86XK_MonBrightnessDown), spawn "xbacklight -dec 5")
  69. -- Another option for brightness configuration: never let it reach 0.
  70. {-|
  71. let
  72. returnValM = fmap init $ runProcessWithInput "xbacklight" [] ""
  73. in do
  74. currentBrightness <- returnValM
  75. if (read currentBrightness :: Double) - 5 >= 0 then
  76. spawn "xbacklight -dec 5"
  77. else return ())
  78. -}
  79. ]
  80. startup :: X ()
  81. startup = do
  82. spawn "feh --bg-scale ~/Owncloud/Backgrounds/Xmbindings.png"
  83. spawn "owncloud"
  84. spawn "trayer --transparent true --alpha 0 --tint 0x00000000 --SetDockType true --expand true --edge top --align right --width 15 --height 18"
  85. spawn "xfce4-clipman"
  86. spawn "xbacklight -set 12"