Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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
    
add comment

3 Answers

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:

#!/bin/sh

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

# Process ID of the process we just launched
PID=$!

# 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 sawm
# a window.
while [ "$WID" == "" ]; do
        WID=$(wmctrl -lp | grep $PID | cut "-d " -f1)
done
# 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 (f.e. implies that no other instance is running) but it should get you going.

share|improve this answer
add comment

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
add comment

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
add comment

Your Answer

 
discard

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.