Command-Line – How to Maximize an Application with Known PID from CLI

command linemaximized

I need to maximize the window of an application when it's minimized using the command line only..

So how to do that knowing the process ID.

When working on the wmctrl command i got the following error:

X Error of failed request:  BadWindow (invalid Window parameter)
  Major opcode of failed request:  20 (X_GetProperty)
  Resource id in failed request:  0x6718
  Serial number of failed request:  11
  Current serial number in output stream:  11

Best Answer

This should work:

xdotool windowactivate `xdotool search --pid YOUR_PID_HERE | tail -1`

xdootool reports a quite a few window id-s when looking up by pid, so I "tailed" the output to only get the last window id from the output. For me it worked well with both Firefox and gnome-calculator. If xdotool only reports one window id for your pid then the tail pipe is of course unnecessary.

Related Question