QTile set position for window

862 views Asked by At

My problem is that I want to have a specific wm_class spawn at a specific X and Y position on my screen every time it opens (Floating window).

I read the documentation, but couldn't figure out a way. I was trying to use the method:

set_position_floating()
2

There are 2 answers

0
Nikmosi On

Set position:

@subscribe.client_new 
def new_clinet(client):
    if "pavucontrol" in client.get_wm_class():
        client.set_position_floating(200,200)

prevent reposition to center by no_reposition_rules:

floating_layout = layout.Floating(
    float_rules=[
        *layout.Floating.default_float_rules,
    ],
    no_reposition_rules=[
        Match(wm_class="pavucontrol"),
    ],
)

if u add match for pavucontrol in float_rules then qtile will resize the window when it appears

0
robabo On

I managed to do this in qtile the same way I did it in dwm. I placed ncmpcpp where I wanted on the screen by doing the following. Ncmpcpp runs in the terminal and my terminal is 'st'. So, I put this key binding in my config to spawn ncmpcpp:

Key([mod], "n", lazy.spawn("st -c float-term -g 100x25+550+300 ncmpcpp")),

I believe the 'c' flag allows you to choose a name for a new wm_class. I chose 'float-term' as the class name. The 'g' flag allows you to set the geometry that you want. Then, I added the new wm_class name to the float_rules list in my config.py:

floating_layout = layout.Floating(float_rules=[
    # Run the utility of `xprop` to see the wm class and name of an X client.
    *layout.Floating.default_float_rules,
    Match(wm_class='confirmreset'),  # gitk
    Match(wm_class='makebranch'),  # gitk
    Match(wm_class='maketag'),  # gitk
    Match(wm_class='ssh-askpass'),  # ssh-askpass
    Match(title='branchdialog'),  # gitk
    Match(title='pinentry'),  # GPG key password entry
    Match(wm_class='bomi'), #bomi player
    Match(wm_class='brave-browser-beta'), #brave browser
    Match(wm_class='gsimplecal'), #gsimplecal
    Match(wm_class='float-term'), #ncmpcpp

This method allowed me to spawn st any place on the screen. I have not tried this with any program other than st running ncmpcpp yet, but I'm pretty sure it would work.