2014-06-18 34 views
4

我知道XMobar支持位圖圖標,我可以配置這些圖標。不過,我也想使用圖標來表示當前的XMonad佈局,但XMobar從XMonad獲取stdin。而我無法找出傳遞位圖圖標而不是常規符號的方法。用於指示XMobar(XMobad)中佈局的圖標

那麼如何通過圖標而不是符號來指示XMobar中的XMonad佈局?

我相對的佈局配置的當前部分:

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 

回答

2

只需添加到您的xmonad.hs

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

至於其他建議,你可以改變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 
相關問題