You are not logged in.

#1 2021-08-15 12:56:24

desperado
Member
Registered: 2018-10-12
Posts: 59

[Solved] Start an application and keep the window hidden by default

I like to toggle certain application windows using the command-

# show
xdotool search --class <process-name> windowmap %@ windowraise %@

# hide
xdotool search --onlyvisible --class <process-name> windowunmap %@

But how do you start applications hidden by default?

Best I can do is to start the application, wait for 1-2 seconds (to make sure it has finished starting up and is running, xdotool doesn't work otherwise), then hide it. But then the application shows up briefly before moving into the hidden state.

Last edited by desperado (2021-08-15 17:40:40)

Offline

#2 2021-08-15 13:07:07

seth
Member
Registered: 2012-09-03
Posts: 61,647

Re: [Solved] Start an application and keep the window hidden by default

If %application% doesn't support that, your best chance is a window manager rule (which will depend on the %windowmanger% at use)

Offline

#3 2021-08-15 13:13:47

desperado
Member
Registered: 2018-10-12
Posts: 59

Re: [Solved] Start an application and keep the window hidden by default

I'm using bspwm.

Offline

#4 2021-08-15 13:19:29

seth
Member
Registered: 2012-09-03
Posts: 61,647

Re: [Solved] Start an application and keep the window hidden by default

Offline

#5 2021-08-15 14:14:27

desperado
Member
Registered: 2018-10-12
Posts: 59

Re: [Solved] Start an application and keep the window hidden by default

I prefer a wm independent solution if there is one. Thanks anyway.

Offline

#6 2021-08-15 14:24:13

seth
Member
Registered: 2012-09-03
Posts: 61,647

Re: [Solved] Start an application and keep the window hidden by default

I prefer if we don't play this down in 20 questions…
What are you *actually* trying to achieve? What exact application do you want to start hidden and why?

You'll not be able to keep a certain window from being mapped unless either the client or the WM support that.
You've to either make the client not issue a map request or the WM not honor it.
That's it.

You can make xdotool wait smarter if you can isolate the client eg. by class (see "man xdotool" for the --sync example), but you'll still have to wait for the window to unmap it after it was mapped.

Offline

#7 2021-08-15 16:46:45

desperado
Member
Registered: 2018-10-12
Posts: 59

Re: [Solved] Start an application and keep the window hidden by default

I asked for a wm independent solution because I sometimes switch WMs just to experiment on a few things. I omitted some of the details for the sake of brevity and to keep it general (guess that backfired).

From what I understand, --sync makes xdotool wait until the map/unmap was finished instead of returning immediately. I doubt this is what I need.

The applcation in question is lxqt-panel (yes, I use it in conjunction with bspwm because polybar isn't as simple). But lxqt-panel doesn't have the option to start unmapped the way some other bars do.

I'll just put the exact script I'm using right now.

lxqt-panel &
sleep 2
xdotool search --onlyvisible --class lxqt-panel windowunmap %@

lxqt-panel blocks as long as it runs, which is why it needs to be pushed to the background. If xdotool is run immediately after sending it to the background, xdotool might finish before lxqt-panel is even mapped in which case xdotool totally ignores lxqt-panel and exits.

Edit: I didn't know search had a sync option too. Maybe this will do

Edit2: This is the script I tried.

lxqt-panel &
xdotool search --sync --class lxqt-panel windowunmap --sync %@

The panel still shows for a moment sad

Last edited by desperado (2021-08-15 17:05:05)

Offline

#8 2021-08-15 17:03:54

seth
Member
Registered: 2012-09-03
Posts: 61,647

Re: [Solved] Start an application and keep the window hidden by default

Yup, will.

QApplication doesn't support such feature, nor does LxQtApplication or the panel (afaics, briefly looked at the code), so if you don't handle this through the WM, the --sync search to windowunmap is the best it will get.
(Depending on WM and compositor you'll still briefly see the window, but at least not rely on a random timeout)

Offline

Board footer

Powered by FluxBB