While working with Firebug's Console or Firefox's Web Console, you have to constantly keep switching focus from the web page to the respective command line and back, using the mouse. This gets very repetitive and tiring, real fast. If you are like me, then you have probably figured that (thankfully) there are keyboard shortcuts to focus the command lines of the respective consoles.
Switch to the respective consoles
In case you didn't know the shortcut keys, here they are:
- For Firebug's Console, the key combination is
Ctrl + Shift + L
- For Firefox's Web Console, the key combination is
Ctrl + Shift + K
Note: In the present stable version of Firefox (Firefox 27), the above key combination toggles the Firefox Web Console. In future versions of Firefox — probably starting from Firefox 30 — the behaviour will change to: always focus the command line (similar to the current behaviour of Firebug). Reference: https://bugzilla.mozilla.org/show_bug.cgi?id=612253
Now that we are able to focus the command lines of the respective consoles, another problem arises.
How to switch focus back to the web page?
Unfortunately, neither Firebug nor Firefox, seem to provide a shortcut to do so. At least I couldn't find a way to do so. So, I decided to use xdotool for the task.
On its website, xdotool is described as:
This tool lets you simulate keyboard input and mouse activity, move and resize windows, etc.
I used its ability to simulate mouse activity to achieve my goal. Basically, make it perform a pseudo mouse click on the web page, so that the focus is returned to the web page.
Here's a script that achieves this:
#!/usr/bin/env bash # Bring focus back to the web page # from Firebug Console's or Firefox # Web Console's command line sleep 1 # Move cursor to the specified position xdotool mousemove 475 395 # Perform a left mouse click on the above position xdotool click 1
In the following line:
xdotool mousemove 475 395
the values specify the x and y coordinates on your screen, where you wish to move your mouse pointer.
Get the desired mouse coordinates
You can use:
$ xdotool getmouselocation
to get the values specific to your screen. Just make sure to move the mouse pointer to the desired location (for instance, the centre of the screen), before running this command.
Here's a sample output for your reference:
$ xdotool getmouselocation findclient: 6291502 x:475 y:395 screen:0 window:6291502
Wrapping it up
Finally, put the script contents in a file, and bind it to a key combination using your Desktop Environment, Window Manager or similar.
Now, when the respective command line is focused, and you press the key combination assigned to the above script, the focus will be returned to the web page. So, using this script and the built-in shortcuts for the command lines, you can easily toggle between the web page and the command lines.