dotfiles

config files for my linux setup
git clone git://edryd.org/dotfiles
Log | Files | Refs | README

xmonad.hs (4280B)


      1 import XMonad
      2 
      3 import XMonad.Hooks.DynamicLog
      4 import XMonad.Hooks.StatusBar
      5 import XMonad.Hooks.StatusBar.PP
      6 import XMonad.Hooks.InsertPosition
      7 
      8 import XMonad.Util.Loggers
      9 import XMonad.Util.EZConfig (additionalKeys)
     10 import Graphics.X11.ExtraTypes.XF86
     11 
     12 import XMonad.Actions.CycleWS
     13 import XMonad.Actions.DwmPromote
     14 
     15 import XMonad.StackSet as W
     16 import XMonad.ManageHook
     17 import XMonad.Util.NamedScratchpad
     18 
     19 scratchpads = [
     20 -- run htop in xterm, find it by title, use default floating window placement
     21     NS "htop" "st -e htop" (title =? "htop") defaultFloating ,
     22     NS "term" "st -t terminal" (title =? "terminal") defaultFloating ,
     23 
     24 -- run stardict, find it by class name, place it in the floating window
     25 -- 1/6 of screen width from the left, 1/6 of screen height
     26 -- from the top, 2/3 of screen width by 2/3 of screen height
     27     NS "stardict" "stardict" (className =? "Stardict")
     28         (customFloating $ W.RationalRect (1/6) (1/6) (2/3) (2/3)) ,
     29 
     30 -- run gvim, find by role, don't float
     31     NS "notes" "gvim --role notes ~/notes.txt" (role =? "notes") nonFloating
     32   ] where role = stringProperty "WM_WINDOW_ROLE"
     33 
     34 myKeys conf@(XConfig {modMask = modKey}) =
     35   [ ((modKey,               xK_Return), spawn $ terminal conf)
     36   , ((modKey .|. shiftMask, xK_Return), dwmpromote)
     37   , ((modKey,               xK_Tab),    toggleWS)
     38   -- Volume Control
     39   , ((0, xF86XK_AudioMute),        spawn "pactl set-sink-mute @DEFAULT_SINK@ toggle")
     40   , ((0, xF86XK_AudioLowerVolume), spawn "pactl set-sink-volume @DEFAULT_SINK@ -10%")
     41   , ((0, xF86XK_AudioRaiseVolume), spawn "pactl set-sink-volume @DEFAULT_SINK@ +10%")
     42   , ((0, xF86XK_AudioMicMute),     spawn "pactl set-source-mute @DEFAULT_SOURCE@ toggle")
     43   -- Brightness Control
     44   , ((0, xF86XK_MonBrightnessUp),   spawn "brightnessctl set +2%")
     45   , ((0, xF86XK_MonBrightnessDown), spawn "brightnessctl set 2%-")
     46           -- , ("M-S-z", spawn "xscreensaver-command -lock")
     47   , ((modKey .|. controlMask .|. shiftMask, xK_t), namedScratchpadAction scratchpads "term")
     48   , ((modKey .|. controlMask .|. shiftMask, xK_h), namedScratchpadAction scratchpads "htop")
     49   -- , ((modKey .|. controlMask .|. shiftMask, xK_n), namedScratchpadAction scratchpads "notes")         -- , ("M-C-s", unGrab *> spawn "scrot -s"        )
     50   ] ++  
     51     [((m .|. mod4Mask, k), windows $ f i)
     52          | (i, k) <- zip ["1","2","3","4","5","6","7","8","9"] [xK_1 .. xK_9]
     53          , (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]]
     54 
     55 myManageHook :: ManageHook
     56 myManageHook = composeAll
     57     [ --className =? "Gimp" --> doFloat
     58      -- isDialog            --> doFloat
     59       insertPosition Below Newer
     60     , namedScratchpadManageHook scratchpads
     61     ]
     62 
     63 myConfig = def
     64          { terminal = "tabbed -ck st -w"
     65          , modMask = mod4Mask  -- Rebind Mod to the Super key
     66          , manageHook = myManageHook
     67          , focusedBorderColor = "#815BA4"
     68          , borderWidth = 2
     69          } 
     70 
     71 myXmobarPP :: PP
     72 myXmobarPP = def
     73     { ppSep             = magenta " • "
     74     , ppTitleSanitize   = xmobarStrip
     75     , ppCurrent         = medWhite . wrap " " "" . xmobarBorder "Top" "#06B6EF" 2
     76     , ppHidden          = white . wrap " " ""
     77     , ppHiddenNoWindows = lowWhite . wrap " " ""
     78     , ppUrgent          = red . wrap (yellow "!") (yellow "!")
     79     , ppOrder           = \[ws, l, _, wins] -> [ws, l, wins]
     80     , ppExtras          = [logTitles formatFocused formatUnfocused]
     81     }
     82   where
     83     formatFocused   = wrap (white    "[") (white    "]") . blue    . ppWindow
     84     formatUnfocused = wrap (lowWhite "[") (lowWhite "]") . magenta . ppWindow
     85 
     86     -- | Windows should have *some* title, which should not not exceed a sane length.
     87     ppWindow :: String -> String
     88     ppWindow = xmobarRaw . (\w -> if null w then "untitled" else w) . shorten 50
     89 
     90     blue, lowWhite, magenta, red, white, yellow :: String -> String
     91     magenta  = xmobarColor "#815BA4" ""
     92     blue     = xmobarColor "#06B6EF" ""
     93     white    = xmobarColor "#E7E9DB" ""
     94     yellow   = xmobarColor "#FEC418" ""
     95     red      = xmobarColor "#EF6155" ""
     96     lowWhite = xmobarColor "#A39E9B" ""
     97     medWhite = xmobarColor "#DDDDDD" ""
     98 
     99 main = xmonad 
    100      . withEasySB (statusBarProp "xmobar /home/ed/.xmonad/xmobarrc" (pure myXmobarPP)) defToggleStrutsKey 
    101      $ myConfig `additionalKeys` (myKeys myConfig)