ezyang’s blog

the arc of software bends towards understanding

Transparent xmobar

Things I should be working on: graduate school personal statements.

What I actually spent the last five hours working on: transparent xmobar.

/img/transparent-xmobar.png

It uses the horrible “grab Pixmap from root X window” hack. You can grab the patch here but I haven’t put in enough effort to actually make this a configurable option; if you just compile that branch, you’ll get an xmobar that is at 100/255 transparency, tinted black. (The algorithm needs a bit of work to generalize over different tints properly; suggestions solicted!) Maybe someone else will cook up a more polished patch. (Someone should also drum up a more complete set of XRender bindings!)

This works rather nicely with trayer, which support near identical tint and transparency behavior. Trayer also is nice on Oneiric, because it sizes the new battery icon sensibly, whereas stalonetray doesn’t. If you’re wondering why the fonts look antialiased, that’s because I compiled with XFT support.

(And yes, apparently I have 101% battery capacity. Go me!)

Update. Feature has been prettified and made configurable. Adjust alpha in your config file: 0 is transparent, 255 is opaque. I’ve submitted a pull request.

15 Responses to “Transparent xmobar”

  1. refold says:

    Nice wallpaper!

  2. kfish says:

    What on earth is a “personal statement”? is “graduate school” something kind of dating site?

  3. kfish: Nah, that’s what I hear undergrad is for.

  4. Jake McArthur says:

    This is a timely patch for me, as I just decided I wanted to try a transparent background today. Just a little bug report. When I set XMobar’s position to something aside from Top, the background that XMobar uses is still taken starting from the top left instead of from its actual position.

    I tried looking at your patch to see if I could fix it myself, but X stuff is gibberish to me.

  5. Oh, that’s a fascinating bug. I’ll see if I can fix that.

  6. […] Stalonetray (which, unlike Trayer, works properly when you use xrandr to rotate), a transparent xmobar, and Solarized themes for rxvt-unicode, vim, ls, mc and Eclipse. […]

  7. Tux Hat says:

    I tried your git source and it failed to compiled just like what joar got on one of his comments on a github forum.. something about “missing xrendercolor” or something. It’s quite old xmobar 0.14 , i was wondering if this is at all possible with xmobar 0.17 ?

    I was just wondering if i can just hack the bloody thing , i don’t think its that hard to really get this sorted. Lack of people doing this or taking any or much interest with Xmobar i do not see any other topic besides what you are doing @ Edward , and i think you work is great, i want to get a tint just like your screenshot up above.

    it looks nice if i can somehow set it up to 100/255 < alpha doesn't work on .xmobarrc say something about unexpected 'a' and i don't know how to get this sorted :(

    any help at all or some info would be very nice :) Thank You!

    Tux Hat

  8. I haven’t tried to compile it for a while, it’ll take me time before a find a free moment to update things.

  9. I’ve updated it to work with the latest xmobar.

  10. Arash Rouhani says:

    Hi Edward. Do you happen to have any dotfiles repository online anywhere? I wonder how you got the graphical icons (battery, wireless) in the first place.

  11. Arash: You need some tray application. I use ‘trayer’, and just start it up in my Xsession.

  12. Arash Rouhani says:

    Ah, thank you very much. I also found taffybar (replacing xmobar), tough I can’t speak for which one is better.

  13. Anonymous says:

    Nothing seems to have come of that pull request. Three years on and still no alpha. I’m running V0.22.1 so I don’t want to be dropping your parser, xmobar and utils sources in willy nilly. Anything we can do to encourage an inclusion into the main branch?

  14. I just re-pushed my branch rebased for the latest xmobar. IIRC there was some refactoring that the maintainer wanted before it could be merged in. I haven’t done it because I’m lazy, but that probably is how we can get it mainlined.

  15. Anonymous says:

    Hope you can find the time to do that. It’d be a great feature to have as standard on the main branch.

Leave a Comment