I'd like to trigger a tab refresh on Firefox from a command line. I'm working on a web app and the refresh goes after the app compiles. I trigger the compile from a command in my IDE. It's not a fixed url, nor can it be derived from the open file in the IDE. Thus, the currently open url in the active tab.
The thing is, I'm in a double headed box with no Xinerama support, which means I can't alt+tab to Firefox, instead I must move the mouse to the other screen, click on Firefox and then Ctrl+R. That can't be right.
I tried some sort of bookmarklet stuff, like DISPLAY=':0.1' firefox -remote 'openurl(javascript:alert(1);)'
, but FF wouldn't run that.
Any ideas?
You can enable the auto-refresh from Firefox Advanced Options by clicking the orange Firefox button on the top left corner of the browser and then clicking "Options." From the list of options, select "Advanced." Under the "General" tab, in the "Accessibility" section, you will be able to remove the check mark next to " ...
Firefox and Windows: To hard refresh on Firefox on Windows, there are also two easy hotkey commands you can use: Hold down Ctrl, Shift and the 'R' key. Or Hold down Ctrl and press F5.
Hold down Ctrl (Control) + Shift and click R. Or hold down Ctrl (Control) and click the Reload button. Or hold down Ctrl (Control) and click F5.
No mouse needed. firefox -safemode or -safe-mode then a new window should show to enter safe mode or Reset, hit the right keyboard key, and press enter on "Reset Firefox". No mouse needed.
You can use xdotool for automation. Install on Ubuntu with
sudo aptitude install xdotool
Then you can search for windows and send keys or mouse events, see man xdotool
for the full documentation. I use following script on Ubuntu 16.04 LTS during development:
WID=`xdotool search --name "Mozilla Firefox" | head -1` xdotool windowactivate $WID xdotool key F5
Note: in the older versions, e.g. Ubuntu 14.04 the flag is --title
instead of --name
.
See also the xdotool project site.
Here's an updated version of @geekQ's script that will return focus to the previous program (however, the firefox window will still be pulled to the top).
#!/bin/bash CURRENT_WID=$(xdotool getwindowfocus) WID=$(xdotool search --name "Mozilla Firefox") xdotool windowactivate $WID xdotool key F5 xdotool windowactivate $CURRENT_WID
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With