The macro feature of Notepad++ was really useful. On Ubuntu I've had to do without Notepad++, and anyway it would be better to have something that works inn any program. I've found/made something today, and since StackOverflow locks all questions about such things, I'll post it here.
sudo apt-get install -y xmacro. The basic commands are
xmacrorec2 > "$macrofile" and
xmacroplay "$DISPLAY" < "$macrofile". I've made a few small improvements:
- Assigned hotkeys so I can use it in any program more conveniently and without recording alt+tab.
- Include ESC as the decault termination key so it doesn't need to be set each time.
- Increase the playback speed, since letters got mixed up if I played back several times in succession.
- Send desktop notifications upon start, completion and playback, but only send playback ones if there isn't one already (or you'll be getting the whole queue of them for several minutes after completion).
- Prevent a recording from starting if there's already one running.
- Add a timeout (of 2.5 min) on recording so you don't accidentally leave it running and record your password.
It's simple to get started:
- Copy the record and playback files from the repository.
- In the dash menu find Keyboard, then click Shortcuts and select Custom Shortcuts.
+, enter a name and enter the command
bash /path/macro_record.sh. Repeat for playback.
- Click the shortcut area where it says "Disabled" and assign your shortcut, e.g.
ctrl+alt+T) and start recording a macro (
F9) (you should see a notification). Type some harmless command like
echo "hello world!", then press the
ESCkey (another notification should appear). [You might have to press spacebar (nothing happens) at this point because ESC eats the next keypress]. Now you can press
F10a whole bunch of times to greet the world with appropriate enthusiasm!