[xmonad] Hide xmobar under windows

Jochen Keil jochen.keil at gmail.com
Sun Sep 2 22:31:06 CEST 2012


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

On 02.09.2012 22:07, Eric Velten de Melo wrote:
> On 2 September 2012 16:42, Jochen Keil <jochen.keil at gmail.com>
> wrote: Ahem..
> 
> On 02.09.2012 18:01, Eric Velten de Melo wrote:
>>>> Ok, I am pretty sure this should not be too complicated to
>>>> do, but I've been trying many ways to hide the xmobar under
>>>> the windows and so far haven't achieved anything. Interesting
>>>> thing is that many people report having this behavior as
>>>> something undesirable, but that's precisely what I want. I
>>>> don't want xmobar showing up on my workspace all the time,
>>>> and wanted somehow to toggle it on and off.
>>>> 
>>>> I have played with both toggleStruts in xmonad.hs and
>>>> lowerOnStart = True | False in .xmobarrc, but got nothing.
>>>> Maybe this is something very simple, but I'm not being able
>>>> to do it. So far my xmonad.hs and .xmobarrc look like this:
> I don't want to put myself into the spotlight here, but that's
> what I've implemented recently for xmobar. You can find that stuff
> in the latest git version (https://github.com/jaor/xmobar). There's
> also some documentation how to set up autohide for xmonad in the
> readme file.
> 
> Hope you like it!
> 
>> That sounds great! How one would toggle hide and unhide on
>> XMonad? I suppose it has something to do with the "Example for
>> using the DBus IPC interface with XMonad" but I can't quite
>> understand the example. Is it necessary to write all that?
The code is meant for toggling xmobar when a certain key is pressed.
You could mimic a similar behaviour by using xbindkeys and a shell script.

For using the code snippet provided in the readme it's probably the
best to put it in an own module in ~/.xmonad/lib (e.g. XmobarToggle.hs).
You'll need to import the Xmonad and DBus{,.Client} modules then as well.

import XMonad
import DBus
import DBus.Client
import qualified XMonad.Util.ExtensibleState as XS
..

Then go to your xmonad.hs and import XmobarToggle.hs

Add some lines like this:

myKeys = [ {- your current stuff -} ]
      ++ [ ((0, xK_Alt_L   ), return ()) ]

- -- 250 is the delay, 30 is tenth of seconds before disappearing
myHandleEventHook = mconcat $
   [ HEV.toggleDocksHook 250 30 xK_Alt_L
   , HEV.myDocksEventHook
   ]

xmonad $ ewmh myConfig {
    ..
    handleEventHook = myHandleEventHook,
    ..
    }



>> Would I get this feature installing xmobar from cabal or do I
>> have to use the git version?
The patches are quite recent, so you'll need the git version. But it's
pretty stable, I'm running it atm.

>> By the way, I also forgot to send reply to all, but Brandon's 
>> suggestion worked out great. It doesn't work using cairo-compmgr,
>> but compositing is always kind of buggy on X apparently.
> 
>> Eric
> 
> 
> Best Wishes,
> 
> Jochen
> 
> P.S.: Whoops, that was meant to got to Eric and to the list, sorry 
> Eric for the noise.
> 
> 
>>>> --------- xmonad.hs 
>>>> --------------------------------------------------------------
>>>>
>>>>
>>>> 
import XMonad import qualified Data.Map as M import
>>>> Data.Either.Utils import qualified Network.MPD as MPD import 
>>>> System.IO import XMonad.Actions.GridSelect import
>>>> XMonad.ManageHook import XMonad.Hooks.ManageHelpers import
>>>> XMonad.Layout.NoBorders import XMonad.Hooks.EwmhDesktops
>>>> import XMonad.Hooks.DynamicLog import
>>>> XMonad.Hooks.ManageDocks import XMonad.Actions.SpawnOn import
>>>> XMonad.Layout.PerWorkspace import XMonad.Util.Run(spawnPipe) 
>>>> import qualified XMonad.Util.EZConfig as EZ
>>>> 
>>>> myTerminal = "sakura"
>>>> 
>>>> _myKeys = [ ("M-t", goToSelected defaultGSConfig) ,("M-p", 
>>>> spawnHere "exe=`yeganesh -x` && eval \"exec $exe\"")
>>>> ,("M-s", sendMessage ToggleStruts) ,("<XF86Tools>", spawn
>>>> "mpd") ,("<XF86AudioPlay>", spawn "mpc --no-status toggle") 
>>>> ,("<XF86AudioStop>", io $ return . fromRight =<< MPD.withMPD 
>>>> MPD.stop) ,("<XF86AudioNext>", io $ return . fromRight =<< 
>>>> MPD.withMPD MPD.next) ,("<XF86AudioPrev>", io $ return .
>>>> fromRight =<< MPD.withMPD MPD.previous) ]
>>>> 
>>>> myLayouts = avoidStrutsOn [] $ smartBorders $ layoutHook 
>>>> defaultConfig
>>>> 
>>>> myManageHook :: ManageHook myManageHook = composeAll [ 
>>>> isFullscreen --> doFullFloat ]
>>>> 
>>>> myConfig = EZ.additionalKeysP defaultConfig _myKeys
>>>> 
>>>> main = do xmproc <- spawnPipe "xmobar" xmonad $ ewmh myConfig
>>>> { terminal = myTerminal, manageHook = myManageHook,
>>>> layoutHook = myLayouts, logHook = dynamicLogWithPP xmobarPP {
>>>> ppOutput = hPutStrLn xmproc , ppTitle = xmobarColor "green"
>>>> "" . shorten 50 } }
>>>> 
>>>> -----------------------------------------------------------------------------------------------------
>>>>
>>>>
>>>>
>
>>>> 
- ----------------- .xmobarrc
>>>> -------------------------------------------------------------------
>>>>
>>>>
>>>>
>
>>>> 
Config { font = "-*-Fixed-Bold-R-Normal-*-13-*-*-*-*-*-*-*" ,
>>>> bgColor = "black" , fgColor = "grey" , position = Top , 
>>>> lowerOnStart = False , commands = [ Run Weather "EGPF"
>>>> ["-t"," 
>>>> <tempC>C","-L","64","-H","77","--normal","green","--high","red","--low","lightblue"]
>>>>
>>>>
>
>>>> 
36000
>>>> 
>>>> 
> , Run Cpu ["-L","3","-H","50","--normal","green","--high","red"]
>>>> 10 , Run Memory ["-t","Mem: <usedratio>%"] 10 , Run Swap []
>>>> 10 , Run Date "%a %b %_d %l:%M" "date" 10 , Run StdinReader ]
>>>> , sepChar = "%" , alignSep = "}{" , template = "%StdinReader%
>>>> }{ %cpu% | %memory% * %swap% <fc=#ee9a00>%date%</fc> |
>>>> %EGPF%" }
>>>> 
>>>> -----------------------------------------------------------------------------------------------------
>>>>
>>>>
>>>>
>
>>>> 
Any help appreciated,
>>>> 
>>>> Eric
>>>> 
>>>> _______________________________________________ xmonad
>>>> mailing list xmonad at haskell.org
>>>> http://www.haskell.org/mailman/listinfo/xmonad
>>>> 
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.19 (GNU/Linux)

iEYEARECAAYFAlBDwgoACgkQtVwvsA+W4CCkxwCfVewpPH7SqJP8B26TuDiAw0KI
QnkAn1kq78Aw1APjN7ixK17CfnJh2D2E
=mHsY
-----END PGP SIGNATURE-----



More information about the xmonad mailing list