Command Line – How to Minimize an Application Window from Command Line

command linewindow-managementwindow-managerwmctrl

I have a startup application that has no option to "start minimized" or "close to system tray" etc. and therefore would like to use a startup script that will first start the application and then minimize its window.

Actually, I already have a startup script that closes the window of an application which luckily has a sort of "close to system tray" option:

wmctrl -ic $(wmctrl -l | grep "AppWindowTitle" | cut -d ' ' -f 1)

I should ideally be able to minimize the window with a command like this:

wmctrl -ir $(wmctrl -l | grep "AppWindowTitle" | cut -d ' ' -f 1) -b toggle,minimized

But there is not such option available in wmctrl. Options for the first argument are: add, remove, toggle. And options for the second argument are: modal, sticky, shaded, skip_taskbar, skip_pager, hidden, fullscreen, above, below, maximized_vert, maximized_horz

These seem to work and I would expect the argument hidden could be the one I need but it's not hiding the window.

I wonder if there's some other way of achieving this…

Best Answer

You can use xdotool like that:

xdotool search  "Mozilla Firefox" windowminimize
Related Question