Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want Firefox window to be opened in a specific size, and location on screen using a shell command, for example:

firefox myfile.html size 800x600 location bottom-left

Is there such a command?

share|improve this question
I managed to do this (with the help of this forum), although if you find any other solution, please tell me as it will probably be more robust: unix.stackexchange.com/questions/40209/… – Emanuel Berg Jul 15 '12 at 23:08

As far as I know, this is not possible as Firefox does not accept commands to control the window. That's also (mostly) the responsibility of the window manager, so I doubt that there ever will be parameters to do that. However, you can control the window with wmctrl, but that's going to be a little bit difficult:


firefox -new-instance -new-window "http://www.reddit.org" &

# Process ID of the process we just launched

# Window ID of the process...pray that there's     
# only one window! Otherwise this might break.
# We also need to wait for the process to spawn
# a window.
while [ "$WID" == "" ]; do
        WID=$(wmctrl -lp | grep $PID | cut "-d " -f1)
# Set the size and location of the window
# See man wmctrl for more info
wmctrl -i -r $WID -e 0,50,50,250,250

There might be more clever ways to do it, and there are some interoperability issues with Firefox (e.g. that no other instance is running) but it should get you going.

share|improve this answer

I don't think this is possible by shell commands only, cause it has nothing to do with your windowmanager.
I heard of wmctrl and devilspie which can effect this. But I doubt there is a way to achieve that as simple as you wrote in your example.

share|improve this answer

In the past I have created an HTML document that would set the window size with Javascript then redirect to the page I wanted. It's a stupid hack but, hey, it works.

share|improve this answer
Looks like this doesn't work anymore. Apparently, window.resizeTo only has an effect if the window is a popup created via window.open. – hugomg Nov 18 '14 at 18:06

You can use the tool called, "xdotool" to control window size and location. Not only that, any script you write in bash, using xdotool, can be setup to work with fully maximized window and it can be scripted to set the window size any x:y coordinates by manipulating the mousemove and "click" commands.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.