تلاش سپورٹ

Avoid support scams. We will never ask you to call or text a phone number or share personal information. Please report suspicious activity using the “Report Abuse” option.

مزید سیکھیں

Open windows of different sizes from command line

  • 5 جواب دیں
  • 1 میں یہ مسئلہ ہے
  • 1 دیکھیں
  • آخری جواب بذریعہ markohrastovec

more options

Hi,

I am running Firefox with -width and -height command line options. The problem I have is that these parameters are ignored if some Firefox window is already open. In that case all following windows are opened with the size of the first (original) window. It does not matter what I type for width and height. These parameters are used only for the first window, when Firefox is actually started.

I mitigated this trouble before with javascript used in web pages to resize the window on document load event. Now I have to upgrade to newer version and resizeTo does not work on windows which are not opened via window.open.

What options do I have to open more Firefox windows with different sizes? They all have to use the same profile.

We are using a very specific, closed and controlled environment with one web-server and no internet access. There was no need to upgrade from Firefox 4. Now we would like to upgrade, but this change in functionality is preventing us from upgrading. Since our client computers are on CentOS 5, we would upgrade to Firefox 17 which is a part of standard CentOS 5 distribution.

Hi, I am running Firefox with -width and -height command line options. The problem I have is that these parameters are ignored if some Firefox window is already open. In that case all following windows are opened with the size of the first (original) window. It does not matter what I type for width and height. These parameters are used only for the first window, when Firefox is actually started. I mitigated this trouble before with javascript used in web pages to resize the window on document load event. Now I have to upgrade to newer version and resizeTo does not work on windows which are not opened via window.open. What options do I have to open more Firefox windows with different sizes? They all have to use the same profile. We are using a very specific, closed and controlled environment with one web-server and no internet access. There was no need to upgrade from Firefox 4. Now we would like to upgrade, but this change in functionality is preventing us from upgrading. Since our client computers are on CentOS 5, we would upgrade to Firefox 17 which is a part of standard CentOS 5 distribution.

منتخب شدہ حل

I have written a bash script that makes a list of windows, starts firefox and makes a list again. Then it finds the differences in lists from before and after opening firefox. At the end the script uses wmctrl to change window's size that was found as newly opened. There is a small chance that some other window might pop up while opening firefox and it will get resized too. However in our case that probability is very small and it is not worth the effort.

Here's the script which takes 3 parameters: width, height, URL.

#!/bin/bash

diff(){
  awk 'BEGIN{RS=ORS=" "}
       {NR==FNR?a[$0]++:a[$0]--}
       END{for(k in a)if(a[k])print k}' <(echo -n "${!1}") <(echo -n "${!2}")
}

window_count=$(wmctrl -l | wc -l)

windows=()

wmctrl -l > output

exec 0<output 


while read id type machine name

do

  windows=("${windows[@]}" "$id")

done

# width and height in this call are ignored if some other firefox window is already open

/usr/bin/firefox -P profile -width $1 -height $2 -new-window $3 &


new_window_count=$window_count

while [ "$window_count" -eq "$new_window_count" ]

do

  #echo waiting...

  sleep 1

  new_window_count=$(wmctrl -l | wc -l)

done


new_windows=()

wmctrl -l > output

exec 0<output while="" read="" id="" type="" machine="" name="" do="" new_windows='("${new_windows[@]}"' "$id")="" done="" differences="($(diff" windows[@]="" new_windows[@]))="" for="" i="" in="" "${differences[@]}"="" wmctrl="" -i="" -r="" $i="" -e="" 0,-1,-1,$1,$2="" <="" pre="">

done


I had to do some tweaking in the script to fool the HTML editor. Some formatting of text is performed, that is not source friendly. That is why the script might look formatted strangely.

</output>
اس جواب کو سیاق و سباق میں پڑھیں 👍 1

تمام جوابات (5)

more options

Hello Marko,

Thanks for contacting Mozilla Support.

You mentioned that you were using the window.open method and that resizeTo was no longer working. Have you tried specifying height/width with the window.open method?

http://www.w3schools.com/jsref/met_win_open.asp

Let me know if this works or if we can help further.

Cheers, Patrick

more options

On Windows, you might be able to use the system script engine to launch a window and send it a resize (WM_SIZE) message. I don't know whether there is an equivalent on Linux.

Can a Greasemonkey userscript still use resizeTo()? If so, you might create a userscript that watches for a custom parameter in the page's window object (e.g., global object resizeParams) to know what size the window should be.

more options

resizeTo() and moveTo() only work in tabs with XUL pages like about:addons, but not on normal tabs in the main window.
You can use the Web Console (Firefox/Tools > Web Developer;Ctrl+Shift+K) to run the command while such a XUL page is selected.


See also:

more options

I was also thinking about writing a bash script to resize the window after it is open.

At first I tried it with devilspie. https://wiki.gnome.org/DevilsPie This utility is great. I wrote the rule, that windows with specific name should be resized. However this works only partially. The problem is that when firefox window is open it first gets the name "Firefox window" or something like that. When the page is loaded into the window, it changes the name to page title. That may be to late for devilspie. So, when I open the window it sometimes is resized and sometimes not. It depends whether Firefox manages to open the page and set the title before devilspie reads the title.

I will now try it with a script. The script will start firefox, wait a little and then resize the new window with wmctrl utility. http://tomas.styblo.name/wmctrl/ I can even run wmctrl before and after running firefox to identify the exact window which needs to be resized.

markohrastovec کی جانب سے میں ترمیمکی گئ

more options

منتخب شدہ حل

I have written a bash script that makes a list of windows, starts firefox and makes a list again. Then it finds the differences in lists from before and after opening firefox. At the end the script uses wmctrl to change window's size that was found as newly opened. There is a small chance that some other window might pop up while opening firefox and it will get resized too. However in our case that probability is very small and it is not worth the effort.

Here's the script which takes 3 parameters: width, height, URL.

#!/bin/bash

diff(){
  awk 'BEGIN{RS=ORS=" "}
       {NR==FNR?a[$0]++:a[$0]--}
       END{for(k in a)if(a[k])print k}' <(echo -n "${!1}") <(echo -n "${!2}")
}

window_count=$(wmctrl -l | wc -l)

windows=()

wmctrl -l > output

exec 0<output 


while read id type machine name

do

  windows=("${windows[@]}" "$id")

done

# width and height in this call are ignored if some other firefox window is already open

/usr/bin/firefox -P profile -width $1 -height $2 -new-window $3 &


new_window_count=$window_count

while [ "$window_count" -eq "$new_window_count" ]

do

  #echo waiting...

  sleep 1

  new_window_count=$(wmctrl -l | wc -l)

done


new_windows=()

wmctrl -l > output

exec 0<output while="" read="" id="" type="" machine="" name="" do="" new_windows='("${new_windows[@]}"' "$id")="" done="" differences="($(diff" windows[@]="" new_windows[@]))="" for="" i="" in="" "${differences[@]}"="" wmctrl="" -i="" -r="" $i="" -e="" 0,-1,-1,$1,$2="" <="" pre="">

done


I had to do some tweaking in the script to fool the HTML editor. Some formatting of text is performed, that is not source friendly. That is why the script might look formatted strangely.

</output>

cor-el کی جانب سے میں ترمیمکی گئ