Make clicking on a workspace in xmobar switch to it

master
Lars Vierbergen 8 years ago
parent a83d7f66b1
commit ed6f4c8ca1
  1. 4
      .xmobarrc
  2. 23
      xmonad.hs

@ -9,9 +9,9 @@ Config { font = "-*-Fixed-Normal-R-Normal-*-13-*-*-*-*-*-*-*"
, Run Battery ["-t", "<acstatus>", "-L", "10", "-H", "80", "-l", "red", "-h", "green", "--", "-O", "<fc=blue><left>%</fc>", "-i", "<fc=blue><left>%</fc>", "-o", "Bat: <left>% / <timeleft>"] 10 , Run Battery ["-t", "<acstatus>", "-L", "10", "-H", "80", "-l", "red", "-h", "green", "--", "-O", "<fc=blue><left>%</fc>", "-i", "<fc=blue><left>%</fc>", "-o", "Bat: <left>% / <timeleft>"] 10
, Run Locks , Run Locks
, Run PipeReader "/home/lars/.xmonad/actiondisplay" "action" , Run PipeReader "/home/lars/.xmonad/actiondisplay" "action"
, Run StdinReader , Run UnsafeStdinReader
] ]
, sepChar = "%" , sepChar = "%"
, alignSep = "}{" , alignSep = "}{"
, template = "%StdinReader% }{ %action% | %locks% | <action=`gnome-power-statistics`>%battery%</action> | <action=`gnome-system-monitor`>%cpu% | %memory% * %swap%</action> | <fc=#ee9a00>%date%</fc>" , template = "%UnsafeStdinReader% }{ %action% | %locks% | <action=`gnome-power-statistics`>%battery%</action> | <action=`gnome-system-monitor`>%cpu% | %memory% * %swap%</action> | <fc=#ee9a00>%date%</fc>"
} }

@ -53,18 +53,29 @@ workspaceManageHook = composeAll [
,className =? "Clementine" --> doShift "8:media" ,className =? "Clementine" --> doShift "8:media"
] ]
xmobarAction :: String -- action
-> String -- output string
-> String
xmobarAction action = wrap t "</action>"
where t = concat ["<action=`", action, "`>"]
xmobarSwitchWs :: String -> String
xmobarSwitchWs wsName = xmobarAction action wsName
where action = concat ["xdotool key ISO_Level3_Shift+F", workspace]
workspace = takeWhile (/=':') wsName -- Takes all chars until ':'
main = do main = do
xmobar_proc <- spawnPipe "xmobar" xmobar_proc <- spawnPipe "xmobar"
spawn "exec ~/.xmonad/action-manager/start.sh ~/.xmonad/actiondisplay ~/.xmonad/actioncontrol --state-file ~/.xmonad/actionstate --redshift-enabled --redshift-location 51:5 --redshift-temperature 6000:2000" spawn "exec ~/.xmonad/action-manager/start.sh ~/.xmonad/actiondisplay ~/.xmonad/actioncontrol --state-file ~/.xmonad/actionstate --redshift-enabled --redshift-location 51:5 --redshift-temperature 6000:2000"
xmonad $ baseConfig xmonad $ baseConfig
{ manageHook = (scratchpadManageHook $ W.RationalRect 0.0 0.0 1.0 0.5) <+> workspaceManageHook <+> fullscreenManageHook <+> manageDocks { manageHook = (scratchpadManageHook $ W.RationalRect 0.0 0.0 1.0 0.5) <+> workspaceManageHook <+> fullscreenManageHook <+> manageDocks
, logHook = dynamicLogWithPP xmobarPP , logHook = dynamicLogWithPP xmobarPP
{ ppOutput = hPutStrLn xmobar_proc { ppOutput = hPutStrLn xmobar_proc
, ppTitle = xmobarColor "green" "" . shorten 50 , ppHidden = xmobarSwitchWs
, ppSort = fmap(.scratchpadFilterOutWorkspace) (ppSort xmobarPP) , ppTitle = xmobarColor "green" "" . shorten 80
, ppOrder = \(ws:_:t:_) -> [ws, t] , ppSort = fmap(.scratchpadFilterOutWorkspace) (ppSort xmobarPP)
} , ppOrder = \(ws:_:t:_) -> [ ws, t]
}
} }
`additionalKeys` `additionalKeys`
[ ((modMask baseConfig .|. controlMask, xK_l), spawn "xscreensaver-command -lock") [ ((modMask baseConfig .|. controlMask, xK_l), spawn "xscreensaver-command -lock")

Loading…
Cancel
Save