September 1, 2014 Leave a comment
I sometimes consult several dictionary Web sites concurrently. Typically I have them open simultaneously on different browser tabs so that I can switch between them quickly. Naturally I have the sites bookmarked, but it is still a bit of a nuisance to have to open each site by clicking on the browser’s ‘Open a new tab’ icon and then clicking on a bookmark. So I thought it would be nice if I could have an icon in the browser or on the Desktop that I could click to open all the desired Web pages at once.
Well, I could have created a Desktop Configuration File in ~/Desktop/ to launch a command such as the one listed below, and given the file a nice icon.
firefox http://www.oxforddictionaries.com/ http://michaelis.uol.com.br/moderno/portugues/index.php http://www.conjuga-me.net/ http://www.priberam.pt/dlpo/ http://www.wordreference.com/
Then I would have been able to double-click on the icon on my Desktop, which would have launched a separate Firefox window with those five required Web sites in different tabs. But what if I happened to have an existing window maximised? I would then have to move it to be able to see the icon on the Desktop. So I decided that was not an ideal approach.
Next I thought about the possibility of a Firefox extension, so I searched the Mozilla Add-ons site and found one called Open Multiple Locations. But, from what I read, it seems the extension is no longer being maintained. Furthermore, it appears it would have to be launched from the browser’s File menu, which would still be a little inconvenient.
Then I remembered that I have the excellent utility AutoKey installed, so why not define a hotkey sequence to do what I wanted? This is what I did.
When you install AutoKey, it creates a directory
~/.config/autokey/data/My Phrases/ which contains directories named
Sample Scripts. The latter two directories contain examples of what you can do with AutoKey. Now, one of the example scripts in
Sample Scripts is
Insert Date.py, a very simple script which enables you to issue the Linux
date command with a hotkey combination, preconfigured as Ctrl-Alt-d (Click on the Insert Date entry in the left pane of the AutoKey window and notice in the lower right pane that the hotkey is listed and there are
Clear buttons to enable you to change it).
So I used the Desktop Environment’s GUI to navigate to the directory
~/.config/autokey/data/My Phrases/ and created a directory which I called
~/.config/autokey/data/My Phrases/My Scripts/. I copied the file
~/.config/autokey/data/My Phrases/Sample Scripts/Insert Date.py into the new directory and renamed it
Launch_Firefox_with_dictionaries.py then set its AutoKey hotkey combination to be Ctrl-Alt-f and edited it to contain the desired command:
output = system.exec_command("firefox http://www.oxforddictionaries.com/ http://michaelis.uol.com.br/moderno/portugues/index.php http://www.conjuga-me.net/ http://www.priberam.pt/dlpo/ http://www.wordreference.com/") keyboard.send_keys(output)
Now, when I am using a browser (be it Firefox, Chrome, Konqueror or whatever) or any other application and I need to consult those dictionaries, I just press Ctrl-Alt-f and up pops a Firefox window containing five tabs with the Web sites I wish to be able to use. Done and done.
Of course, if you happen to be using a Desktop Environment that has its own shortcut tool, you can use that instead. For example, in KDE I could have instead used ‘System Settings’ > ‘Shortcuts and Gestures’ | ‘Custom Shortcuts’ and configured Ctrl-Alt-f to run the above-mentioned command to launch Firefox with those five URLs. (You need to log out of KDE and log in again for the shortcut to become active.) That would have achieved exactly the same result as with AutoKey.