I’ve been a loyal user of Firefox for years and plan to still use it as my secondary browser (and will use it regularly for Zotero). But Google’s new browser, Chrome, has really impressed me and I’m going to start using it as my primary browser for email, surfing the web, and every day online activities. Why is it better? It’s faster, does a better job rendering flash on Linux, doesn’t require restarts to install extensions, and isolates tabs, so if one crashes it doesn’t kill all of your other tabs. In short, Chrome has become a better browser than Firefox for everyday browsing.
I had held off switching to Chrome for several months because I was hoping someone would create a Chrome extension similar to clippings for Firefox. I’m still hoping someone will, but I figured out a way to work around it on Ubuntu Linux. It’s not for the faint-of-heart or novice computer user, but it does work, and works quite well. Basically, what I’ve done is installed some software that allows me to paste text into any window, unlike clippings, which only let me paste text into Firefox.
Here’s how you do it:
Ubuntu comes with some cool keyboard shortcuts built in, and includes the ability to customize a lot of those shortcuts. But it doesn’t come with the ability to paste text as a keyboard shortcut with the default install (learned this here). In order to do that, you need to install a program called “xbindkeys.” While you’re at it, you may as well install the GUI for setting the keybindings “xbindkeys-config” and the program you’ll use to generate the text “xvkbd”. You can install them all at once from the terminal (or find them in the Synaptic Package Manager and install them there):
$ sudo apt-get install xbindkeys xbindkeys-config xvkbd
Once you’ve installed “xbindkeys,” the first thing you need to do is create a default configuration file for it from the terminal:
$ xbindkeys -d > /home/your-user-name/.xbindkeysrc
Once that’s done, go ahead and open the xbindkeys GUI by typing the following at the terminal:
$ xbindkeys-config
This will pull up the xbindkeys GUI:
In here, you can create the key bindings to generate the text you want. This involves 6 steps.
1) At the bottom of the GUI, select “New”:
A new line in the list of keybindings will appear. Select it.
2) At the top right, choose a name for the keybinding and put it in the field labeled “Name:”
I don’t know that the name you choose here is particularly important, but you should probably make it something you’ll recognize.
3) Set the key binding. the xbindkeys GUI includes the ability to capture key combinations. All you have to do is press the “Get Key” button, wait a second for a small window to pop up, then press the desired key combination (e.g., Control+Mod2+Mod4+1). The GUI should capture everything for you correctly. The key combination will be coded into the language xbindkeys understands and will be put in the “Key:” field (e.g., Control+Mod2+Mod4+1 | m:Ox54 + c:10). What all of the code in the “Key:” field means, I’m not sure, but some of it is explained in the actual configuration file (which you created above; it’s located here: /home/your-user-name/.xbindkeysrc).
4) You then need to tell xbindkeys what to do when you press the key combination you just set up (this is called the “Action”). In order to paste text into a window, you have to actually call up a different program, which is why we installed it earlier. That program is xvkbd, an on-screen keyboard program. You won’t see the keyboard when you press the key combination, but it does generate the text for you. Here’s the command you use in the “Action:” field to generate text:
xvkbd -xsendevent -text “your text here“
The first part “xvkbd” opens the xvkbd program. The second part “-xsendevent” tells it to send an event to the X window. The third part “-text” tells it what type of event – text.
A couple of notes on the text you can include using this command are in order. First, you can put pretty much anything you want inside the quotes, except additional quotes, which the program doesn’t seem to recognize are quotes inside the quotes. So, don’t try quotes inside quotes. You can also include things like “Return” and “Tab.” I couldn’t figure out how to do that initially, which is why I ended up writing this tutorial. What I wanted to include in the text I was pasting was the text I usually include in my email signature:
Best,
Ryan
I was able to include the text, but couldn’t figure out how to include the line break. So, what I was initially getting when I pressed my key combination was:
Best,Ryan
I initially thought, erroneously, that the command for “Return” would be included in xbindkeys list of commands. Nope. The command for “Return” is part of xvkbd. I eventually found it on that software’s website: \r. So, if you want to create something like an email signature with a line break, here’s how it would look:
xvkbd -xsendevent -text “Best,\r\rRyan”
Note I’ve included two Return commands (i.e., “\r\r”) as one will just return me to the next line. I needed 2 for a blank line between “Best,” and “Ryan.”
5) You’re not quite done at this point. I found the GUI for xbindkeys to be a bit buggy. Before you do anything else, you should hit the buttons “Apply” and “Save & Apply & Exit”:
This will close the program, but it will also make sure that everything you just typed in will be saved in the configuration file. I have 5 different keyboard bindings for text I use regularly, 3 email signatures and 2 other text snippets. I created the first email signature, then started on the second and the GUI crashed, losing all my work. So, just hit the “Apply” and “Save & Apply & Exit” button after every keyboard binding you create just to be safe.
6) Test it. Open up a file or browser and try your keyboard combinations. If the text is pasted in – voila, you’re done. If not, well, you did something wrong or, well, who knows. The nice thing about this approach is that it is browser agnostic – it will paste your text into any browser or any other text input box for that matter.
Notes:
There are a couple of additional things you should do with xbindkeys before you’re done. First, a nifty keybinding that is included in the default configuration file is “CONTROL+SHIFT+q”, which opens up a list of all of your current keybindings:
This isn’t all that important to know, but it is a nice little feature.
You should also know that you can edit your configuration file by hand, though doing so is a bit tricky as the code for the key combinations isn’t all that intuitive. To do so, use the following command at the terminal:
$ gedit /home/your-user-name/.xbindkeysrc
Finally, once you’ve gotten everything working, if you want to make sure xbindkeys starts when you boot your computer, add it to the Startup Applications: “System -> Preferences -> Startup Applications”
Leave a Reply