Personal tools

Xmonad/Config archive/Thayer Williams' xmonad.hs

From HaskellWiki

< Xmonad | Config archive(Difference between revisions)
Jump to: navigation, search
m (xmonad.hs:: comment handleEventHook so this *does* work with 0.9)
 
(5 intermediate revisions by one user not shown)
Line 1: Line 1:
This is a simple, mouse-friendly xmonad (0.9) config geared towards netbooks and other low-resolution devices. Dzen is used for statusbar rendering, with optional mouse integration provided by xdotool.
+
[[Category:XMonad configuration]]
  +
This is a simple, mouse-friendly xmonad (0.9) config, geared towards netbooks and other low-resolution devices. Dzen is used for statusbar rendering, with optional mouse integration provided by xdotool.
   
<div style="display:inline; width:220px; float:right;">
 
 
[[Image:Thayer-xmonad-20110511.png|center|200px]]
 
[[Image:Thayer-xmonad-20110511.png|center|200px]]
</div>
 
   
 
The latest revisions can always be found at github: http://github.com/thayerwilliams
 
The latest revisions can always be found at github: http://github.com/thayerwilliams
   
=== xmonad.hs ===
+
=== '''xmonad.hs:''' ===
 
<haskell>
 
<haskell>
 
--
 
--
Line 30: Line 28:
 
import XMonad.Actions.DwmPromote -- swap master like dwm
 
import XMonad.Actions.DwmPromote -- swap master like dwm
 
import XMonad.Hooks.DynamicLog -- statusbar
 
import XMonad.Hooks.DynamicLog -- statusbar
  +
import XMonad.Hooks.EwmhDesktops -- fullscreenEventHook fixes chrome fullscreen
 
import XMonad.Hooks.ManageDocks -- dock/tray mgmt
 
import XMonad.Hooks.ManageDocks -- dock/tray mgmt
  +
import XMonad.Hooks.UrgencyHook -- window alert bells
 
import XMonad.Layout.Named -- custom layout names
 
import XMonad.Layout.Named -- custom layout names
 
import XMonad.Layout.NoBorders -- smart borders on solo clients
 
import XMonad.Layout.NoBorders -- smart borders on solo clients
Line 42: Line 42:
 
status <- spawnPipe myDzenStatus -- xmonad status on the left
 
status <- spawnPipe myDzenStatus -- xmonad status on the left
 
conky <- spawnPipe myDzenConky -- conky stats on the right
 
conky <- spawnPipe myDzenConky -- conky stats on the right
xmonad $ defaultConfig
+
xmonad $ withUrgencyHook NoUrgencyHook $ defaultConfig
 
{ modMask = mod4Mask
 
{ modMask = mod4Mask
 
, terminal = "urxvtcd"
 
, terminal = "urxvtcd"
Line 48: Line 48:
 
, normalBorderColor = "#dddddd"
 
, normalBorderColor = "#dddddd"
 
, focusedBorderColor = "#0000ff"
 
, focusedBorderColor = "#0000ff"
  +
-- , handleEventHook = fullscreenEventHook -- Only in darcs xmonad-contrib
 
, workspaces = myWorkspaces
 
, workspaces = myWorkspaces
 
, layoutHook = myLayoutHook
 
, layoutHook = myLayoutHook
Line 81: Line 82:
 
, className =? "Gimp" --> doFloat
 
, className =? "Gimp" --> doFloat
 
, className =? "XCalc" --> doFloat
 
, className =? "XCalc" --> doFloat
, className =? "Chromium" --> doF (W.shift (myWorkspaces !! 1)) -- open on ws 2
+
, className =? "Chromium" --> doF (W.shift (myWorkspaces !! 1)) -- send to ws 2
, className =? "Nautilus" --> doF (W.shift (myWorkspaces !! 2)) -- open on ws 3
+
, className =? "Nautilus" --> doF (W.shift (myWorkspaces !! 2)) -- send to ws 3
, className =? "Gimp" --> doF (W.shift (myWorkspaces !! 3)) -- open on ws 4
+
, className =? "Gimp" --> doF (W.shift (myWorkspaces !! 3)) -- send to ws 4
  +
, className =? "stalonetray" --> doIgnore
 
]
 
]
   
Line 102: Line 103:
 
, ppLayout = dzenColor "#aaaaaa" "" . wrap "^ca(1,xdotool key super+space)· " " ·^ca()"
 
, ppLayout = dzenColor "#aaaaaa" "" . wrap "^ca(1,xdotool key super+space)· " " ·^ca()"
 
, ppTitle = dzenColor "#ffffff" ""
 
, ppTitle = dzenColor "#ffffff" ""
. wrap "^ca(1,xdotool key super+k)^ca(2,xdotool key super+shift+c)" " ^ca()^ca()"
+
. wrap "^ca(1,xdotool key super+k)^ca(2,xdotool key super+shift+c)"
. shorten 20
+
" ^ca()^ca()" . shorten 20 . dzenEscape
 
}
 
}
   
Line 132: Line 133:
 
</haskell>
 
</haskell>
   
=== conkrc ===
+
=== '''conkyrc:''' ===
 
My dzen-formatted conkyrc, as seen in the screenshot above:
 
My dzen-formatted conkyrc, as seen in the screenshot above:
 
<haskell>
 
<haskell>

Latest revision as of 03:53, 6 October 2011

This is a simple, mouse-friendly xmonad (0.9) config, geared towards netbooks and other low-resolution devices. Dzen is used for statusbar rendering, with optional mouse integration provided by xdotool.

Thayer-xmonad-20110511.png

The latest revisions can always be found at github: http://github.com/thayerwilliams

[edit] 1 xmonad.hs:

--
-- File     : ~/.xmonad/xmonad.hs (for Xmonad >= 0.9)
-- Author   : Thayer Williams
-- Website  : http://cinderwick.ca/
-- Desc     : A simple, mouse-friendly xmonad config geared towards
--            netbooks and other low-resolution devices.
--
--            dzen is used for statusbar rendering, with optional mouse
--            integration provided by xdotool:
--
--             * left-click workspace num to go to that ws
--             * left-click layout to cycle next layout
--             * left-click window title to cycle next window
--             * middle-click window title to kill focused window
--
 
import XMonad
import XMonad.Actions.CycleWindows -- classic alt-tab
import XMonad.Actions.CycleWS      -- cycle thru WS', toggle last WS
import XMonad.Actions.DwmPromote   -- swap master like dwm
import XMonad.Hooks.DynamicLog     -- statusbar 
import XMonad.Hooks.EwmhDesktops   -- fullscreenEventHook fixes chrome fullscreen
import XMonad.Hooks.ManageDocks    -- dock/tray mgmt
import XMonad.Hooks.UrgencyHook    -- window alert bells 
import XMonad.Layout.Named         -- custom layout names
import XMonad.Layout.NoBorders     -- smart borders on solo clients
import XMonad.Util.EZConfig        -- append key/mouse bindings
import XMonad.Util.Run(spawnPipe)  -- spawnPipe and hPutStrLn
import System.IO                   -- hPutStrLn scope
 
import qualified XMonad.StackSet as W   -- manageHook rules
 
main = do
        status <- spawnPipe myDzenStatus    -- xmonad status on the left
        conky  <- spawnPipe myDzenConky     -- conky stats on the right
        xmonad $ withUrgencyHook NoUrgencyHook $ defaultConfig 
            { modMask            = mod4Mask
            , terminal           = "urxvtcd"
            , borderWidth        = 2
            , normalBorderColor  = "#dddddd"
            , focusedBorderColor = "#0000ff"
--          , handleEventHook    = fullscreenEventHook -- Only in darcs xmonad-contrib
            , workspaces = myWorkspaces
            , layoutHook = myLayoutHook
            , manageHook = manageDocks <+> myManageHook
                            <+> manageHook defaultConfig
            , logHook    = myLogHook status
            } 
            `additionalKeysP` myKeys
 
-- Tags/Workspaces
-- clickable workspaces via dzen/xdotool
myWorkspaces            :: [String]
myWorkspaces            = clickable . (map dzenEscape) $ ["1","2","3","4","5"]
 
  where clickable l     = [ "^ca(1,xdotool key super+" ++ show (n) ++ ")" ++ ws ++ "^ca()" |
                            (i,ws) <- zip [1..] l,
                            let n = i ]
 
-- Layouts
-- the default layout is fullscreen with smartborders applied to all
myLayoutHook = avoidStruts $ smartBorders ( full ||| mtiled ||| tiled )
  where
    full    = named "X" $ Full
    mtiled  = named "M" $ Mirror tiled
    tiled   = named "T" $ Tall 1 (5/100) (2/(1+(toRational(sqrt(5)::Double))))
    -- sets default tile as: Tall nmaster (delta) (golden ratio)
 
-- Window management
--
myManageHook = composeAll
    [ className =? "MPlayer"        --> doFloat
    , className =? "Vlc"            --> doFloat
    , className =? "Gimp"           --> doFloat
    , className =? "XCalc"          --> doFloat
    , className =? "Chromium"       --> doF (W.shift (myWorkspaces !! 1)) -- send to ws 2
    , className =? "Nautilus"       --> doF (W.shift (myWorkspaces !! 2)) -- send to ws 3
    , className =? "Gimp"           --> doF (W.shift (myWorkspaces !! 3)) -- send to ws 4
    , className =? "stalonetray"    --> doIgnore
    ]
 
-- Statusbar 
--
myLogHook h = dynamicLogWithPP $ myDzenPP { ppOutput = hPutStrLn h }
 
myDzenStatus = "dzen2 -w '320' -ta 'l'" ++ myDzenStyle
myDzenConky  = "conky -c ~/.xmonad/conkyrc | dzen2 -x '320' -w '704' -ta 'r'" ++ myDzenStyle
myDzenStyle  = " -h '20' -fg '#777777' -bg '#222222' -fn 'arial:bold:size=11'"
 
myDzenPP  = dzenPP
    { ppCurrent = dzenColor "#3399ff" "" . wrap " " " "
    , ppHidden  = dzenColor "#dddddd" "" . wrap " " " "
    , ppHiddenNoWindows = dzenColor "#777777" "" . wrap " " " "
    , ppUrgent  = dzenColor "#ff0000" "" . wrap " " " "
    , ppSep     = "     "
    , ppLayout  = dzenColor "#aaaaaa" "" . wrap "^ca(1,xdotool key super+space)· " " ·^ca()"
    , ppTitle   = dzenColor "#ffffff" "" 
                    . wrap "^ca(1,xdotool key super+k)^ca(2,xdotool key super+shift+c)"
                           "                          ^ca()^ca()" . shorten 20 . dzenEscape
    }
 
-- Key bindings
--
myKeys = [ ("M-b"        , sendMessage ToggleStruts              ) -- toggle the status bar gap
         , ("M1-<Tab>"   , cycleRecentWindows [xK_Alt_L] xK_Tab xK_Tab ) -- classic alt-tab behaviour
         , ("M-<Return>" , dwmpromote                            ) -- swap the focused window and the master window
         , ("M-<Tab>"    , toggleWS                              ) -- toggle last workspace (super-tab)
         , ("M-<Right>"  , nextWS                                ) -- go to next workspace
         , ("M-<Left>"   , prevWS                                ) -- go to prev workspace
         , ("M-S-<Right>", shiftToNext                           ) -- move client to next workspace
         , ("M-S-<Left>" , shiftToPrev                           ) -- move client to prev workspace
         , ("M-c"        , spawn "xcalc"                         ) -- calc
         , ("M-p"        , spawn "gmrun"                         ) -- app launcher
         , ("M-n"        , spawn "wicd-client -n"                ) -- network manager
         , ("M-r"        , spawn "xmonad --restart"              ) -- restart xmonad w/o recompiling
         , ("M-w"        , spawn "chromium"                      ) -- launch browser
         , ("M-S-w"      , spawn "chromium --incognito"          ) -- launch private browser
         , ("M-e"        , spawn "nautilus"                      ) -- launch file manager
         , ("C-M1-l"     , spawn "gnome-screensaver-command --lock"              ) -- lock screen
         , ("M-s"        , spawn "urxvtcd -e bash -c 'screen -dRR -S $HOSTNAME'" ) -- launch screen session
         , ("C-M1-<Delete>" , spawn "sudo shutdown -r now"       ) -- reboot
         , ("C-M1-<Insert>" , spawn "sudo shutdown -h now"       ) -- poweroff
         ]
 
-- vim:sw=4 sts=4 ts=4 tw=0 et ai

[edit] 2 conkyrc:

My dzen-formatted conkyrc, as seen in the screenshot above:

# ~/.conkyrc
# Thayer Williams - http://cinderwick.ca
# vim:nu:ai:si:et:ts=4:sw=4:ft=conkyrc:
 
background no
out_to_x no
out_to_console yes
update_interval 3
total_run_times 0
use_spacer none
 
# temp, loadavg, cpu usage, cpu freq, battery, network (click launches wicd), date
 
TEXT
^fg(\#999999)${hwmon temp 1}°^fg()  \
^fg(\#666666)${loadavg 1}^fg()  \
^fg(\#888888)${cpu cpu1}%^fg()   ^fg(\#aaaaaa)${freq_g 1}GHz^fg()   \
^fg(\#666666)${mem}^fg()   \
^fg(\#91b8ff)${if_existing /sys/class/power_supply/BAT1/present}${battery_short BAT1} (${battery_time BAT1})${else}AC${endif}^fg()   \
^ca(1,wicd-client -n)${if_empty ${exec ifconfig wlan0 | grep 'inet addr:'}}^fg(\#bbbbbb)eth0^fg()  ^fg(\#d94c3d)${upspeedf eth0}k^fg()  ^fg(\#a4bc51)${downspeedf eth0}k^fg()${else}\
^fg(\#bbbbbb)${wireless_link_qual_perc wlan0}%  ${wireless_essid wlan0}^fg()  ^fg(\#d94c3d)${upspeedf wlan0}k^fg()  ^fg(\#a4bc51)${downspeedf wlan0}k^fg()${endif}^ca()   \
^fg(\#ffffff)${time %b %d %H:%M}^fg()