geommer / yabar

A modern and lightweight status bar for X window managers.
MIT License
680 stars 49 forks source link

Workspace Internal Block Feature Enhancement Request #52

Open 15bitgames opened 8 years ago

15bitgames commented 8 years ago

If I am correct the current interal workspaces block only displays the current visible workspace. Is it do-able to add an option to display all existing workspaces as well?

geommer commented 8 years ago

Like in i3? that is exactly what I wanted to do! The problem is all info I can get from EWMH are: the current desktop, the number of desktops and the list of all windows. There is no direct way to know the non-empty desktops/workspaces. I've been thinking (if possible) to track windows after their creation and bind that to the current desktop in order to implement this feature.

TLDR; I am interested in your request but there is no direct way to implement it. But I will try to find a way.

15bitgames commented 8 years ago

I guess maybe add a string option or boolean (however you want to do it) for different types of WM's. Seems like a lot of work. But maybe support like the top 5. But still there should be a more universal way.

Regards, Dean

Regards, Dean


.: Dean Thomson :. .: CCA Software Support :. .: PH: 03 9894 0055 :. .: MOB: 0414 960 644 :.

On 14/04/16 at 06:01pm, George Badawi wrote:

Like in i3? that is exactly what I wanted to do! The problem is all info I can get from EWMH is the current desktop, the number of desktops and the list of all windows. There is no direct way to know the non-empty desktops/workspaces. I've been thinking (if possible) to track windows after their creation and bind that to the current window in order to implement this feature.

TLDR; I am interested in your request but there is no direct way to implement it. But I will try to find a way.


You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub: https://github.com/geommer/yabar/issues/52#issuecomment-210230459

NBonaparte commented 8 years ago

After taking a brief look at xcb_ewmh.h, it seems like xcb_ewmh_get_desktop_names could give the names of the desktops. I haven't tested it out, however.

geommer commented 8 years ago

Guys I am now confused, am I missing something here? I thought @z1lt0id asked for a i3-like workspaces block (i.e. shows only all non-empty workspaces). The name of workspaces is not a problem, the original names can be obtained as @NBonaparte said but internal-option1 skips that and uses its list of names. The real problem, if I understood the initial request correctly, is how to deduce the non-empty workspaces. I don't think EWMH offers a direct solution to that.

15bitgames commented 8 years ago

Exactly, too makes things a little more annoying bspwm has changed the way it does workspaces :( Shows ID numbers now.

astr0n8t commented 8 years ago

I'm not familiar with i3's code, but it seems like i3 creates desktops only if they are occupied, or if they open on a monitor or when you press a key combination, so wouldn't the ids of the workspaces refer to only the open ones?

hg8 commented 8 years ago

Any news about this ?

Lesik commented 8 years ago

There hasn't been much work since August, however while @geommer is working on this a simple script using your favourite scripting language could parse output like bspc subscribe and then use Pango to stylize that output depending on what's selected. :)

I agree that an internal solution using EWMH is better, just proposing a workaround until it's ready.

NBonaparte commented 7 years ago

I've created an experimental module on the dev_workspaces branch (see 6cb6f48), please check if it works for i3 (so far on bspwm it works fine). Use the option exec: "YABAR_WORKSPACES"; and internal-option1: "e o f u"; where e = empty, o = occupied, f = focused, u = urgent (replace letters with symbols or whatever you want).

gh67uyyghj commented 7 years ago

@NBonaparte not working for me (bspwm stable, archlinux)

` ya_ws: { exec: "YABAR_WORKSPACES"; align: "left"; fixed-size: 80;

variable-size: true;

    internal-option1: "e o f u";
}

The program segfaults as soon as started [1] + 16382 segmentation fault (core dumped) yabar`

NBonaparte commented 7 years ago

Could you compile with -g flag, run with gdb and paste the output here?

gh67uyyghj commented 7 years ago

I am not sure I understood what you mean but I changed the line in Makefile from $(CC) $(CFLAGS) -c -o $@ $< to $(CC) $(CFLAGS) -g -o $@ $<, no additional info, the program just exits with a segfault on the moment I start it

NBonaparte commented 7 years ago

Add -g to CFLAGS, compile, then run gdb ./yabar in the build directory, and in the gdb shell do run (run -c ... if you use a different config location). When you run it in gdb and it segfaults it should show line numbers.

gh67uyyghj commented 7 years ago

yeah, that's what I got in gdb

Program received signal SIGSEGV, Segmentation fault. 0x00007ffff757c6ba in xcb_ewmh_get_atoms_from_reply () from /usr/lib/libxcb-ewmh.so.2

NBonaparte commented 7 years ago

Put the -g in CFLAGS instead of where you originally put it.

gh67uyyghj commented 7 years ago

Same message, I put -g in CFLAGS and restored the -c flag in that line $(CC) $(CFLAGS) -c -o $@ $<

gh67uyyghj commented 7 years ago

Are you using Archlinux? maybe it has nothing to do with yabar itself, maybe it's in libxcb-ewmh

NBonaparte commented 7 years ago

Yeah, I'm using Arch. Try doing where and see if the line numbers show there.

gh67uyyghj commented 7 years ago

` (gdb) where

0 0x00007ffff757c6ba in xcb_ewmh_get_atoms_from_reply ()

at /usr/lib/libxcb-ewmh.so.2

1 0x00007ffff757c712 in xcb_ewmh_get_atoms_reply () at /usr/lib/libxcb-ewmh.so.2

2 0x0000000000405dc7 in ya_exec_intern_ewmh_blk (blk=0x622f00) at src/ya_exec.c:131

3 0x0000000000406298 in ya_execute () at src/ya_exec.c:522

4 0x0000000000404234 in main (argc=, argv=)

at src/ya_main.c:17

`

NBonaparte commented 7 years ago

I've gotten that once quite a while ago. Not sure if it's me or xcb-ewmh.

If you comment the whole urgent part out does it work? (lines 130-142)

gh67uyyghj commented 7 years ago

what part? the YABAR_WORKSPACES in the config file?

NBonaparte commented 7 years ago

Sorry for being unclear. lines 130-142 in ya_exec.c

gh67uyyghj commented 7 years ago

yeah it works now

NBonaparte commented 7 years ago

I'll try to reimplement the urgency part.

gh67uyyghj commented 7 years ago

Why not make it to look just like i3bar? only busy desktops are shown and everything else shouldn't be on the bar

NBonaparte commented 7 years ago

i3 functions differently than bspwm; i3 only makes desktops when they are filled or active. I guess I could make an option for that...

gh67uyyghj commented 7 years ago

You just made the hard part, you can merge that with the internal-options1 from @geommer's work so only the icons corresponding to the busy workspaces are shown instead of this not very helpful string of eooefeooofff, you can add some other option to highlight the the current workspace.

NBonaparte commented 7 years ago

Have you tried changing the letters in internal-options1? You can set them to any symbol.

gh67uyyghj commented 7 years ago

I know I can change them, I just mean that the character should correspond to the workspace icon not the state itself, just like i3 and awesomewm

NBonaparte commented 7 years ago

Just checking (this is very much a wip), does 3dea0c5 work for you? Set internal-option2: "name";.

soyuka commented 7 years ago

Hi! The patch does work great. Few questions though, would there be a way to have two different styling (through the focused flag or urgent)?

For example:

       workspaces: {
               exec: "YABAR_WORKSPACES";
               underline-color-rgb: 0xde935f;
               focused: {    
                   background-color-rgb: 0xBF674A;
                   underline-color-rgb: 0xde935f;
               }
               urgent: {}
               align: "left";
               internal-option2: "name";
               variable-size: true;
       }

What is the use of internal-option1 here?

Pango markup is working fine when editing the code.

Thanks for the great library!

NBonaparte commented 7 years ago

internal-option1 sets the block to display string indicators (like font icons, for example) instead of the desktop name for the states empty occupied focused urgent, if internal-option2 is not "name".

For now I'll probably implement foreground colors because it is the easiest, since background and underline currently draw over the entire block.

soyuka commented 7 years ago

👍
foreground colors are already working via pango markup :)

vale981 commented 6 years ago

I have a little prototype of an i3 internal block. It is very experimental, but I'd continue working on it if there's interest...

Ingvix commented 4 years ago

In case someone's after a simple solution for bspwm, I created this small shell script to show workspaces with windows in them and highlight the focused one. I don't think there's any dependencies that you wouldn't find at least in a linux system with bspwm installed on it.

It uses the workspace names assigned to them in bspwmrc. There's no mouse support but it woudn't be too hard to implement especially if one uses a single-character names and determine with the internal variables where the click happened. Also there's no indicator for urgent window in a workspace. It uses pywal-generated colors by default but one can easily remove the line where it reads them and set their own colors in the script. Also it has a bit overly simplified

I'm changing to dzen so I probably won't be developing the script further at least for yabar-usecases but thought that I should throw it out there if someone's interested.

#!/bin/sh

. ~/.cache/wal/colors.sh

refresh_workspaces() {
    occupied_wss="$(bspc query -D -d .occupied)"
    output="<span fgcolor=\"$foreground\">"

    for workspace in $occupied_wss; do
    ws_name="$(bspc query -D --names -d "$workspace")"
    if [ "$workspace" = "$focused_ws" ]; then
        output="$output <span bgcolor=\"$color2\"> $ws_name </span>"
    else
        output="$output  $ws_name "
    fi
    done

    output="${output}</span>"

    echo "$output"
}

focused_ws="$(bspc query -D -d)"

refresh_workspaces

bspc subscribe desktop | while read -r line; do
    focused_ws="$(echo "$line" | cut -d" " -f3)"
    refresh_workspaces
done

EDIT: Some optimization after realizing the further capabilities of bspc.

lukelex commented 4 years ago

Does anyone have a step by step on getting this patch applied on i3?