You are not logged in.

#1 2011-07-28 00:32:02

clockworksavior
Member
Registered: 2011-07-28
Posts: 4

Xmonad: Xmobar Window List

Hello,

I'd like to get xmobar to display a window list, but I can't find any information on how to do so. Does anyone here know if it is possible; and if so, can direct me to an example or documentation on how to achive this?

Offline

#2 2011-07-28 03:26:45

mjdwitt
Member
From: Indiana University, USA
Registered: 2011-02-14
Posts: 27
Website

Re: Xmonad: Xmobar Window List

By window list, do you mean a list of all the open windows on a particular workspace similar to the gnome window list?  The closest thing I can think of will only get you a piece of that: the title of the currently focused window.  See the xmobar config section of John Goerzen's Configuration page at the XMonad wiki for some examples and screenshots. 

I am only a beginner with XMonad and I'm even greener with Haskell, so there almost definitely is a way which I do not know to do what you are asking about–although it probably won't be clickable; dzen is better suited for clickable bars.  A good place to start if you feel like really getting to know your way around XMonad is to experiment with some of the example configurations on their wiki and referencing the XMonad.Doc.Extending page when you are lost.

Good luck!

Offline

#3 2011-07-28 09:35:18

owain
Member
From: Manchester, UK
Registered: 2009-08-24
Posts: 260

Re: Xmonad: Xmobar Window List

I've no idea if xmobar can do it, but if you use XMonad.Hooks.EwmhDesktops, then you can choose from all open windows with

wmctrl -a "$(wmctrl -l | awk '{print $4}' | dmenu)"

This might be a way to put something into a clickable area in dzen.

Offline

#4 2011-07-29 00:45:11

clockworksavior
Member
Registered: 2011-07-28
Posts: 4

Re: Xmonad: Xmobar Window List

By window list, do you mean a list of all the open windows on a particular workspace similar to the gnome window list?

Yes, except I don't really need them clickable. If they were, that would be great. I know xmonad has a tabbed layout, but I can't figure out how to shrink the tab bar, so I can use another bar to put a clock on it.

wmctrl -a "$(wmctrl -l | awk '{print $4}' | dmenu)"

I will give something like this a whirl with dzen2. I'll have to use some string magic to format it properly tho, as it ends the line after each window name.

Offline

#5 2011-07-29 01:10:49

skottish
Forum Fellow
From: Here
Registered: 2006-06-16
Posts: 7,942

Re: Xmonad: Xmobar Window List

Welcome to the forums clockworksavior.

dzen2 will happily do what you need it to do. ppTitle is what you need for basic window lists. There's some good documentation that comes with xmonad-contrib, as well as two very long threads here that may be helpful:

https://bbs.archlinux.org/viewtopic.php?id=40636
https://bbs.archlinux.org/viewtopic.php?pid=304851

Last edited by skottish (2011-07-29 01:11:11)

Offline

#6 2011-07-29 01:46:34

clockworksavior
Member
Registered: 2011-07-28
Posts: 4

Re: Xmonad: Xmobar Window List

Thank you.

I looked at the documentation for xmonad-contrib, and ppTitle looks to be only for the current window. The examples in the two threads you posted look like reformatting colors and such for the current window title.

Offline

#7 2011-07-29 01:59:18

skottish
Forum Fellow
From: Here
Registered: 2006-06-16
Posts: 7,942

Re: Xmonad: Xmobar Window List

clockworksavior wrote:

Thank you.

I looked at the documentation for xmonad-contrib, and ppTitle looks to be only for the current window. The examples in the two threads you posted look like reformatting colors and such for the current window title.

Errr... whoops. Another +1, -1 post for me. Yes, wmctrl...

*** skottish walks away quietly hoping that no one is reading the forums right now ***

Offline

#8 2011-07-29 18:36:33

clockworksavior
Member
Registered: 2011-07-28
Posts: 4

Re: Xmonad: Xmobar Window List

Here is what I ended up with.

#!/bin/sh
while true
SCREEN_WIDTH=1024
DATE=`date "+%D %r"`
i=0
do
    # build the windowlist
    for window in $(wmctrl -l -x | awk '{print $3}' | sed -e s/^[^.]*.//)
    do
        windowlist="$windowlist $i: $window"
    i=$(($i + 1))
    done
    
    # chop some of the windowlist off so the date and clock are not covered
    windowlist=`echo "$windowlist" | cut -c -$(expr $SCREEN_WIDTH / 8 - 8)`
    
    # if the windowlist is too short, insert spaces to push the date and clock to the end
    if printf ${#windowlist} -le 1003; then
        for i in $(seq `expr $SCREEN_WIDTH / 8 - ${#windowlist} - 8`);do windowlist="$windowlist ";done
    fi

    # print the windowlist, padding, date, and clock
    echo -n "$windowlist $padding $DATE"

    # clear the windowlist
    windowlist=""

    echo
    sleep 1
done

Last edited by clockworksavior (2011-07-29 19:03:21)

Offline

#9 2012-05-10 22:48:43

paluh
Member
From: Poland
Registered: 2012-05-06
Posts: 2

Re: Xmonad: Xmobar Window List

Hi,

I've written custom logger which returns string with list of all window titles and allows you to format current window title:

(Caution - I'm newbie haskeller so for sure it can be written in less imperative manner :-P !)


import Control.Monad (liftM, sequence)


logTitles :: (String -> String) -> Logger
logTitles ppFocus =
        let
            windowTitles windowset = sequence (map (fmap showName . getName) (W.index windowset))
                where
                    fw = W.peek windowset
                    showName nw =
                        let
                            window = unName nw
                            name = show nw
                        in
                            if maybe False (== window) fw
                                then
                                    ppFocus name
                                else
                                    name
        in
            withWindowSet $ liftM (Just . (intercalate " | ")) . windowTitles

You can use it in your dynamicLog configuration (I think it's also better to drop window title from ppOrder):

main = do
        ...
        , logHook = dynamicLogWithPP $ xmobarPP {
              ...
              , ppExtras = [logTitles (xmobarColor "green" "")]
              , ppOrder = \(ws:l:t:e) -> [ws, l] ++ e
            }
        ...

Last edited by paluh (2012-05-11 10:38:29)

Offline

#10 2012-07-22 23:12:10

caolan
Member
Registered: 2007-10-16
Posts: 12
Website

Re: Xmonad: Xmobar Window List

Thanks paluh, I've just tried out your custom logger and it seems to work well. For the benefit of anyone else wanting to try it, I had to import some extra things to get it working:

import Control.Monad (liftM, sequence)
import XMonad.Util.NamedWindows (getName, unName)
import XMonad.Util.Loggers
import qualified XMonad.StackSet as W
import Data.List (intercalate)

Edit: I also added "shorten 50" to truncate long window names in the list, updated code below: (see the "name = shorten 50 (show nw)" line)

logTitles :: (String -> String) -> Logger
logTitles ppFocus =
        let
            windowTitles windowset = sequence (map (fmap showName . getName) (W.index windowset))
                where
                    fw = W.peek windowset
                    showName nw =
                        let
                            window = unName nw
                            name = shorten 50 (show nw)
                        in
                            if maybe False (== window) fw
                                then
                                    ppFocus name
                                else
                                    name
        in
            withWindowSet $ liftM (Just . (intercalate " | ")) . windowTitles

I've been doing Haskell for approximately an afternoon, so hopefully I've not made a complete fool of myself with that edit wink Don't blame me if it makes your monitor explode or something.

Last edited by caolan (2012-07-22 23:33:32)

Offline

#11 2012-07-24 20:17:02

paluh
Member
From: Poland
Registered: 2012-05-06
Posts: 2

Re: Xmonad: Xmobar Window List

caolan wrote:

For the benefit of anyone else wanting to try it, I had to import some extra things to get it working

Great!

caolan wrote:

I've been doing Haskell for approximately an afternoon, so hopefully I've not made a complete fool of myself with that edit wink Don't blame me if it makes your monitor explode or something.

It looks OK for me ;-)

Thanks

Offline

Board footer

Powered by FluxBB