When I was using Windows I really liked the AutoHotKey tool. After moving to Linux and Awesome WM I missed some of the features of AHK, but finally I found time to investigate the alternatives and came up with native solution for Awesome WM, which I’d like to share.
Hotkeys
In AHK you can:
Remap keys and buttons on your keyboard, joystick, and mouse. Create hotkeys for keyboard, joystick, and mouse. Essentially any key, button or combination can become a hotkey.
In Awesome it’s super easy to create shortcuts and map script execution to them:
so this part more or less solved depending of complexity of hotkeys you want to use.
Interaction with browser/apps
Another thing I used quite a lot is possibility to open browser on address depending on what text I have in clipboard/or type in input box.
Input box
Since Awesome is tiling manager one of the biggest problem of AHK alternatives (like AutoKey) is pop-up windows - depends of the layout of current workspace they can appear in strange places and break the current layout of windows. But this problem easily solves with custom prompt - the same one which is used to execute commands Mod4
+R
.
So lets create custom prompt which will be used for our automation needs, let’s map it with Mod4
+E
combination and for the sake of test show notification with inserted text:
Now using regexps it’s quite easy to write rules and run different apps/scripts according to what was inserted in that prompt. For example following rules:
calc
would open calculator application;so java
would open stackoverflow page with questions tagged ‘java’;wi cat
would open wikipedia page about cats;- anything else would open google search page for inserted text.
would look like this:
Note that lua regex patterns are a bit specific
Clipboard
Here the idea is the same. But text is taken from clipboard. Awesome provides handy function - selection() which gets the content of the clipboard. The function stays almost the same: