eww icon indicating copy to clipboard operation
eww copied to clipboard

[FEATURE] Dynamic number and geometry of windows

Open ckp95 opened this issue 3 years ago • 9 comments

Description of the requested feature

I'm not sure if this is already possible, if it is please can you tell me how to do it?

I'd like to use eww to dynamically put labels or other thingies on top of open windows. This is so I can create e.g. a window switcher. I would press a hotkey, which would trigger a script to get the geometries of the open windows, calculate their centre points, then tell the eww daemon to bring up a bunch of boxes with letters inside at those coordinates. Then the script would listen for keypresses of those keys, switch focus to the appropriate window, and tell the eww daemon to remove the boxes.

This can already be done in a few window managers. For example, there is "revelation" in AwesomeWM. Screenshot of what I'm talking about here. But I want to be able to implement this in a WM-agnostic way.

To be clear, I'm not asking how to make eww find window geometries or switch focus or anything; I know that's totally beyond eww's scope and I can already do that with any number of other tools. I just want to be able to create little boxes where the number and placement and contents are only known at runtime, not at "compile time" (config time?)

Proposed configuration syntax

I don't really know :x

EDIT: wait, can I do this with the literal widget and passing in a bunch of XML with eww update?

ckp95 avatar Jun 04 '21 21:06 ckp95

Yes you can as for geometry other than anchor, width height will be calculated by eww dynamically iirc

undefinedDarkness avatar Jun 05 '21 08:06 undefinedDarkness

Yes you can as for geometry other than anchor, width height will be calculated by eww dynamically iirc

Can you explain how? I can't figure out how to use literal to create multiple windows.

ckp95 avatar Jun 05 '21 10:06 ckp95

Currently, given that literals are only widgets, not windows, they cannot be used to generate windows arbitrarily. While you can influence the position and geometry of windows dynamically, its currently not possible to generate a dynamic amount of windows.

This usecase is definitely something I'd want to support in the future! What I will probably do to fulfill this is add a eww create-window command like this:

eww create-window \
  --name="foo" \
  --geometry="200,400,50,50" \
  --widget="<box>foo</box>"

Which would allow creating windows completely dynamically.

I fear however that this will take a bit, as there are multiple larger changes in progress right now that have higher priority in my mind.

elkowar avatar Jun 05 '21 10:06 elkowar

While you can influence the position and geometry of windows dynamically, its currently not possible to generate a dynamic amount of windows.

I see. In that case I suppose I could workaround it by just hardcoding like a hundred windows (more than anyone would conceivably have open in normal operation) and then just dynamically alter the visibility and positions via script.

ckp95 avatar Jun 05 '21 10:06 ckp95

Yea, until I implement this feature, that is sadly gonna be the only real workaround

elkowar avatar Jun 05 '21 11:06 elkowar

While you can influence the position and geometry of windows dynamically

How do I do this? I can't get it to use the variable I defined.

I have this:

<eww>
    <definitions>    
        <def name="simple_box">
            <box>i'm a box!</box>
        </def>
    </definitions>

    <variables>
        <var name="x_pos">300px</var>
    </variables>

    <windows>    
        <window name="simple_box" screen="0" >
            <geometry x="500px" y="900px" width="200px" height="200px"/>
            <widget >
                <simple_box/>
            </widget>
        </window>
    </windows>
</eww>

This displays a box at the specified coordinates as it should. But if I do this:

<geometry x="{{x_pos}}" y="900px" width="200px" height="200px"/>

It doesn't work. When I use eww logs I get:

(eww:2128): Gtk-WARNING **: 15:25:35.294: Theme parsing error: <data>:9:15: Not using units is deprecated. Assuming 'px'.
 2021-06-05T14:25:35.294Z ERROR eww::server     > Failed to reload config: Failed to load eww config file /home/cameron/.config/eww/eww.xml

Caused by:
    0: Error parsing eww config file /home/cameron/.config/eww/eww.xml
    1: Error parsing window definition at /home/cameron/.config/eww/eww.xml:13:9
    2: Parsing the value of x="{{x_pos}}" in <geometry>
    3: could not parse '{{x_pos}}'

I've tried other ways of quoting it but none seem to work. How do I get the variable into the geometry tag?

ckp95 avatar Jun 05 '21 14:06 ckp95

ahh yea no, no variables in the window tag. What you can do is use the command line arguments for the eww open command, where you can specify window geometry and stuff for the window specifically the moment you open it. check the output of eww open --help

elkowar avatar Jun 05 '21 16:06 elkowar

Ah okay, yes that works.

eww open --pos=450x200 --size=100x100 simple_box

Btw you might want to add to the --help output how the position and size arguments are meant to be formatted; I had to figure it out from the error messages.

ckp95 avatar Jun 05 '21 16:06 ckp95

You could play around wtth making a giant window and then styling it to have a transparent background and an inner element with varying size with the background

godalming123 avatar Mar 11 '22 19:03 godalming123

Does this still work? And does it work on wayland?

ModProg avatar Feb 01 '23 12:02 ModProg

Does this still work? And does it work on wayland?

It should still work although I have not checked however the cursor events will be sent to the eww window which means that when it is open you would not be able to use other windows

godalming123 avatar May 18 '23 16:05 godalming123

Ah okay, yes that works.

eww open --pos=450x200 --size=100x100 simple_box

Btw you might want to add to the --help output how the position and size arguments are meant to be formatted; I had to figure it out from the error messages.

I can't get this to work at all. The window always opens up at the top left of my monitor no matter what values I input for "pos" and "anchor".

The --debug logs show that it's receiving the values correctly.

Also, oddly enough when I explicitly specify geometry within the .yuck file and launch with "eww open window", the ":stacking" variable has no effect and the window is always on top no matter what.

Only when I completely remove the :geometry variable does :stacking work correctly.

Eww: 0.4.0 Distro: ArchLinux DM: XFCE

Running in a VM.

Wallboy avatar Jun 26 '23 05:06 Wallboy