Icons for specifying layouts in XMobar (XMonad)

I know that XMobar supports bitmap icons, and I was able to customize them. However, I also want to use the icons to display the current XMonad layout, but XMobar gets it on stdinfrom XMonad. And I could not figure out how to transmit bitmap icons instead of regular characters.

So, how can I pass icons instead of characters to indicate the layout of XMonad in XMobar?

My current part of the configuration regarding 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
+4
source share
2 answers

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) []
+2
source

XMonad .

      , ppLayout = xmobarColor solarizedCyan ""

      , ppLayout = xmobarColor solarizedCyan "" . myLayoutPrinter

:

myLayoutPrinter :: String -> String
myLayoutPrinter "Full" = "<icon=layout_full.xbm/>"
myLayoutPrinter "Tall" = "<icon=layout_tall.xbm/>"
myLayoutPrinter "Mirror Tall" = "<icon=layout_mirror_tall.xbm/>"
myLayoutPrinter x = x

, , .

, . ppLayout

      , ppLayout = myLayoutPrinter

myLayoutPrinter

myLayoutPrinter :: String -> String
myLayoutPrinter "Full" = xmobarColor "red" "" "<icon=layout_full.xbm/>"
myLayoutPrinter "Tall" = xmobarColor "green" "" "<icon=layout_tall.xbm/>"
myLayoutPrinter "Mirror Tall" = xmobarColor "blue" "" "<icon=layout_mirror_tall.xbm/>"
myLayoutPrinter x = xmobarColor "white" "" x
+2

Source: https://habr.com/ru/post/1545117/


All Articles