I can easily start Nautilus on a particular directory from command line:
nautilus /home/nico/Documents
But I want that Nautilus window to be maximized.
How to write the command line?
nautilus
does not seem to recognize --maximized
nor --fullscreen
. I reluctantly tried --geometry 1500x1500
and it does seem to have any effect.
Best Answer
1. Start up nautilus with a maximized window
To start
nautilus
with a maximized window, you can use the script below:How to use
The script uses both
xdotool
andwmctrl
, the first one to list new windows of the targeted application, the last one because I prefer the wayxdotool
resizes windows.Then copy the script above into an empty file, save it as
start_maximized.py
Test- run the script by the command:
Now nautilus will start up with a new maximized window.
Add, if you like, the command as a quicklist (right- click) item to the
Files
(nautilus) launcher in the Unity Launcher.2. Generalized version; start up any application maximized
You can startup any GUI application (+ their arguments) in the generalized script below:
To use it
Do the setup exactly as above (including installing
wmctrl
andxdotool
, but additionally use the targeted application (+ possible arguments) as an argument to run the script.For example:
or:
Additionaly, add the option to a quicklist
You can easily add the option to the
nautilus
quicklist. Assuming you use the second (generalized) version:Copy the global
nautilus.desktop
file locally:which is on 14.04 and 14.10 : nautilus.desktop:
and on 15.04 and 15.10 : org.gnome.Nautilus.desktop
Open the file with (e.g.) gedit, look for the line:
Change it into:
Add to the very end of the file:
Save and close the file.
Now you have a quicklist option like in the image.
Conceptual explanation
To maximize an existing window is not very difficult. Both
wmctrl
andxdotool
offer options to do so.The issue is that if you want to maximize a newly created window, you don't know the window id yet when you give the command. Therefore the script practices the following procedure:
This way, we can "smartly" maximize the application's new window, that will work no matter the computer is slow (occupied with a heavy job for example) or fast.
Finally, the script has a built in safety time-limit, to prevent waiting for ever in case the application fails to start up for some reason. After appr. 15 seconds, the script gives up and exits an way.