Xmonad Workspace, Layout, & Window Info in Xmobar

- Clean-up imports
- Update xmonad logHook to pass info to xmobar
- Move defaults structure to main function so xmproc is in scope
- Update xmobar config to remove weather and add xmonad input
This commit is contained in:
Sravan Balaji
2021-05-08 17:56:28 -04:00
parent 93cca1d4f2
commit 1ffdbe2350
3 changed files with 49 additions and 55 deletions

View File

@@ -18,19 +18,21 @@
#+begin_src haskell #+begin_src haskell
import XMonad import XMonad
import Data.Monoid
import System.Exit
import qualified XMonad.StackSet as W import qualified XMonad.StackSet as W
import qualified Data.Map as M import qualified Data.Map as M
-- needed for `spawnPipe` import Data.Monoid
import XMonad.Util.Run
-- needed for managing dock type programs like xmobar
import XMonad.Hooks.ManageDocks
import XMonad.Util.Run -- spawnPipe
import XMonad.Util.SpawnOnce import XMonad.Util.SpawnOnce
import XMonad.Util.EZConfig
import XMonad.Hooks.ManageDocks -- manage dock type programs like xmobar
import XMonad.Hooks.DynamicLog
import System.IO
import System.Exit
#+end_src #+end_src
* Terminal * Terminal
@@ -301,10 +303,10 @@ which denotes layout choice.
* Status Bars & Logging * Status Bars & Logging
Perform an arbitrary action on each internal state change or X event. Perform an arbitrary action on each internal state change or X event.
See the 'XMonad.Hooks.DynamicLog' extension for examples. See the ~XMonad.Hooks.DynamicLog~ extension for examples.
#+begin_src haskell #+begin_src haskell
myLogHook = return () -- myLogHook = return ()
#+end_src #+end_src
* Startup * Startup
@@ -332,7 +334,7 @@ See the 'XMonad.Hooks.DynamicLog' extension for examples.
spawnOnce "picom &" spawnOnce "picom &"
#+end_src #+end_src
** Run ** Main
Now run xmonad with all the defaults we set up. Now run xmonad with all the defaults we set up.
@@ -343,20 +345,8 @@ Run xmonad with the settings you specify. No need to modify this.
-- `xmobar -x 0` launches the bar on monitor 0 -- `xmobar -x 0` launches the bar on monitor 0
xmproc <- spawnPipe "xmobar -x 0 /home/sravan/.xmonad/xmobar.config" xmproc <- spawnPipe "xmobar -x 0 /home/sravan/.xmonad/xmobar.config"
-- launches xmobar as a dock -- launches xmobar as a dock
xmonad $ docks defaults xmonad $ docks defaultConfig
#+end_src { -- simple stuff
** Configuration Settings
A structure containing your configuration settings, overriding
fields in the default config. Any you don't override, will
use the defaults defined in xmonad/XMonad/Config.hs
No need to modify this.
#+begin_src haskell
defaults = def {
-- simple stuff
terminal = myTerminal, terminal = myTerminal,
focusFollowsMouse = myFocusFollowsMouse, focusFollowsMouse = myFocusFollowsMouse,
clickJustFocuses = myClickJustFocuses, clickJustFocuses = myClickJustFocuses,
@@ -374,10 +364,13 @@ No need to modify this.
layoutHook = myLayout, layoutHook = myLayout,
manageHook = myManageHook, manageHook = myManageHook,
handleEventHook = myEventHook, handleEventHook = myEventHook,
logHook = myLogHook, logHook = dynamicLogWithPP xmobarPP
{ ppOutput = hPutStrLn xmproc
, ppTitle = xmobarColor "green" "" . shorten 50
},
startupHook = myStartupHook startupHook = myStartupHook
} }
#+end_src #+end_src
** Default Keybindings Reference ** Default Keybindings Reference
@@ -442,22 +435,21 @@ Finally, a copy of the default bindings in simple textual tabular format.
, bgColor = "black" , bgColor = "black"
, fgColor = "white" , fgColor = "white"
, position = Top , position = Top
-- , lowerOnStart = True , lowerOnStart = True
-- , hideOnStart = False , hideOnStart = False
-- , allDesktop = True , allDesktops = True
-- , persistent = True , persistent = True
, commands = [ Run Weather "KARB" ["-t","<station>: <tempF>F","-L","18","-H","25","--normal","green","--high","red","--low","lightblue"] 36000 , commands = [ Run Weather "K7D2" ["-t","<station>: <tempF>F","-L","18","-H","25","--normal","green","--high","red","--low","lightblue"] 36000
, Run Network "eth0" ["-L","0","-H","32","--normal","green","--high","red"] 10
, Run Network "eth1" ["-L","0","-H","32","--normal","green","--high","red"] 10
, Run Network "wlp0s20f3" ["-L","0","-H","32","--normal","green","--high","red"] 10 , Run Network "wlp0s20f3" ["-L","0","-H","32","--normal","green","--high","red"] 10
, Run Cpu ["-L","3","-H","50","--normal","green","--high","red"] 10 , Run Cpu ["-L","3","-H","50","--normal","green","--high","red"] 10
, Run Memory ["-t","Mem: <usedratio>%"] 10 , Run Memory ["-t","Mem: <usedratio>%"] 10
, Run Swap [] 10 , Run Swap [] 10
, Run Com "uname" ["-s","-r"] "" 36000 , Run Com "uname" ["-s","-r"] "" 36000
, Run Date "%a %b %_d %Y %H:%M:%S" "date" 10 , Run Date "%a %b %_d %Y %H:%M:%S" "date" 10
, Run StdinReader
] ]
, sepChar = "%" , sepChar = "%"
, alignSep = "}{" , alignSep = "}{"
, template = "%cpu% | %memory% * %swap% | %wlp0s20f3% }{ <fc=#ee9a00>%date%</fc>| %KARB% | %uname%" , template = "%StdinReader% }{ %cpu% | %memory% * %swap% | %wlp0s20f3% | <fc=#ee9a00>%date%</fc>| %uname%"
} }
#+end_src #+end_src

View File

@@ -2,21 +2,20 @@ Config { font = "xft:FiraCode Nerd Font Mono:weight=bold:pixelsize=12:antialias=
, bgColor = "black" , bgColor = "black"
, fgColor = "white" , fgColor = "white"
, position = Top , position = Top
-- , lowerOnStart = True , lowerOnStart = True
-- , hideOnStart = False , hideOnStart = False
-- , allDesktop = True , allDesktops = True
-- , persistent = True , persistent = True
, commands = [ Run Weather "KARB" ["-t","<station>: <tempF>F","-L","18","-H","25","--normal","green","--high","red","--low","lightblue"] 36000 , commands = [ Run Weather "K7D2" ["-t","<station>: <tempF>F","-L","18","-H","25","--normal","green","--high","red","--low","lightblue"] 36000
, Run Network "eth0" ["-L","0","-H","32","--normal","green","--high","red"] 10
, Run Network "eth1" ["-L","0","-H","32","--normal","green","--high","red"] 10
, Run Network "wlp0s20f3" ["-L","0","-H","32","--normal","green","--high","red"] 10 , Run Network "wlp0s20f3" ["-L","0","-H","32","--normal","green","--high","red"] 10
, Run Cpu ["-L","3","-H","50","--normal","green","--high","red"] 10 , Run Cpu ["-L","3","-H","50","--normal","green","--high","red"] 10
, Run Memory ["-t","Mem: <usedratio>%"] 10 , Run Memory ["-t","Mem: <usedratio>%"] 10
, Run Swap [] 10 , Run Swap [] 10
, Run Com "uname" ["-s","-r"] "" 36000 , Run Com "uname" ["-s","-r"] "" 36000
, Run Date "%a %b %_d %Y %H:%M:%S" "date" 10 , Run Date "%a %b %_d %Y %H:%M:%S" "date" 10
, Run StdinReader
] ]
, sepChar = "%" , sepChar = "%"
, alignSep = "}{" , alignSep = "}{"
, template = "%cpu% | %memory% * %swap% | %wlp0s20f3% }{ <fc=#ee9a00>%date%</fc>| %KARB% | %uname%" , template = "%StdinReader% }{ %cpu% | %memory% * %swap% | %wlp0s20f3% | <fc=#ee9a00>%date%</fc>| %uname%"
} }

View File

@@ -1,17 +1,19 @@
import XMonad import XMonad
import Data.Monoid
import System.Exit
import qualified XMonad.StackSet as W import qualified XMonad.StackSet as W
import qualified Data.Map as M import qualified Data.Map as M
-- needed for `spawnPipe` import Data.Monoid
import XMonad.Util.Run
-- needed for managing dock type programs like xmobar
import XMonad.Hooks.ManageDocks
import XMonad.Util.Run -- spawnPipe
import XMonad.Util.SpawnOnce import XMonad.Util.SpawnOnce
import XMonad.Util.EZConfig
import XMonad.Hooks.ManageDocks -- manage dock type programs like xmobar
import XMonad.Hooks.DynamicLog
import System.IO
import System.Exit
myTerminal = "kitty" myTerminal = "kitty"
@@ -156,7 +158,7 @@ myManageHook = composeAll
myEventHook = mempty myEventHook = mempty
myLogHook = return () -- myLogHook = return ()
myStartupHook = do myStartupHook = do
spawnOnce "nitrogen --restore &" spawnOnce "nitrogen --restore &"
@@ -166,10 +168,8 @@ main = do
-- `xmobar -x 0` launches the bar on monitor 0 -- `xmobar -x 0` launches the bar on monitor 0
xmproc <- spawnPipe "xmobar -x 0 /home/sravan/.xmonad/xmobar.config" xmproc <- spawnPipe "xmobar -x 0 /home/sravan/.xmonad/xmobar.config"
-- launches xmobar as a dock -- launches xmobar as a dock
xmonad $ docks defaults xmonad $ docks defaultConfig
{ -- simple stuff
defaults = def {
-- simple stuff
terminal = myTerminal, terminal = myTerminal,
focusFollowsMouse = myFocusFollowsMouse, focusFollowsMouse = myFocusFollowsMouse,
clickJustFocuses = myClickJustFocuses, clickJustFocuses = myClickJustFocuses,
@@ -187,7 +187,10 @@ defaults = def {
layoutHook = myLayout, layoutHook = myLayout,
manageHook = myManageHook, manageHook = myManageHook,
handleEventHook = myEventHook, handleEventHook = myEventHook,
logHook = myLogHook, logHook = dynamicLogWithPP xmobarPP
{ ppOutput = hPutStrLn xmproc
, ppTitle = xmobarColor "green" "" . shorten 50
},
startupHook = myStartupHook startupHook = myStartupHook
} }