xmonadxmobar

Icons for indicating layouts in XMobar (XMonad)


I know XMobar supports bitmap icons and I was able to configure those. However I also want to use icons for indicating current XMonad layout, but XMobar gets it on stdin from XMonad. And I couldn't figure out a way to pass bitmap icons instead of regular symbols.

So how one would pass icons instead of symbols for indicating XMonad layout in XMobar?

My current part of config relative to layouts:

defaultLayouts = smartBorders(avoidStruts(
  renamed [Replace "R"] (ResizableTall 1 (3/100) (1/2) [])
  ||| renamed [Replace "R!"] (Mirror (ResizableTall 1 (3/100) (1/2) []))
  ||| renamed [Replace "F"] (noBorders Full)
  ||| renamed [Replace "#"] (Grid)
  ||| renamed [Replace "3C"] (ThreeColMid 1 (3/100) (3/4))
  ||| renamed [Replace "O"] (Circle)))

chatLayout = renamed [Replace "Chat"] 
  $ avoidStruts $ withIM (0.2) isPidgin 
  $ reflectHoriz $ withIM (0.2) isSkype (Grid) 
  where 
    isSkype = (Title "zoresvit - Skype™")
    isPidgin = (Title "Buddy List")

fullLayout = renamed [Replace "F"] $ avoidStruts $ noBorders $ (Full)
myLayouts = onWorkspace "η" chatLayout $ defaultLayouts

main = do
  xmproc <- spawnPipe "xmobar ~/.xmobarrc"
  xmonad $ withUrgencyHook NoUrgencyHook $ defaultConfig {
        borderWidth = myBorderWidth
      , focusedBorderColor = myFocusedBorderColor
      , handleEventHook = fullscreenEventHook
      , layoutHook = myLayouts
      , manageHook = manageHook defaultConfig
          <+> composeAll myManagementHooks
          <+> manageDocks
      , modMask = myModMask
      , normalBorderColor = myNormalBorderColor
      , startupHook = do
          spawn "~/.xmonad/startup_hook.sh"
      , terminal = myTerminal
      , workspaces = myWorkspaces
      , logHook = dynamicLogWithPP $ xmobarPP {
            ppOutput = hPutStrLn xmproc
          , ppCurrent = xmobarColor solarizedGreen "" . wrap myCurrentWSLeft myCurrentWSRight
          , ppHidden = xmobarColor solarizedBase0 ""
          , ppHiddenNoWindows = xmobarColor solarizedBase02 ""
          , ppLayout = xmobarColor solarizedCyan ""
          , ppTitle = xmobarColor solarizedBase1 "" . shorten myTitleLength
          , ppUrgent = xmobarColor solarizedRed "" . wrap myUrgentWSLeft myUrgentWSRight
          , ppVisible = xmobarColor solarizedBase01 "" . wrap myVisibleWSLeft myVisibleWSRight
          }
      } `additionalKeys` myKeyBindings

Solution

  • Just add this to your xmonad.hs:

    import XMonad.Layout.Named
    myLayout = named "<icon=/home/foo/bar/icon.xpm/>" $ ResizableTall 1 (3/100) (1/2) []