Daniel 'MaTachi' Jonsson

Tag Archives: Command-Line

Control Keystrokes and Mouse from the Command-Line with Xautomation

There is a pretty cool command-line based application that can execute keystrokes, mouse movement and mouse clicks, called Xautomation. It’s kinda useless if you are sitting at the computer with the terminal in the foreground. But it’s really awesome if you are coding an application that runs in the background and responds to signals from a remote control or similar. I have coded a little command-line based Python 3 program that does just that. It reads USB signals from my Arduino board which is connected to a IR receiver, and executes hotkeys that fits in Totem Media Player.

As an Arch Linux user it was a piece of cake to get Xautomation by downloading it from the AUR:

To use it, open a terminal and print:

xte --help

Then you will get a list of stuff that you can do with this piece of software, like:

xte "key a"
xte "str aAa"
xte "keydown Shift_L" "key a" "keyup Shift_L"
xte "mousermove 100 100"

To execute these commands from a Python 3 application, use this code:

import subprocess
subprocess.call(["xte", "key a"])

Book Tip: GNU/Linux Command-Line Tools Summary

Effektivare LinuxOn my local library I stumbled over a really nice book called Effektivare Linux – Kom Igång Med Kommandoraden (its Swedish title), which essentially is a printed and translated version of GNU/Linux Command-Line Tools Summary. I don’t know if it’s available as a book in English, but it’s at least readable on their website since it’s licensed under GNU GPL.

I think it’s an excellent book for everybody who wants to learn how to use the command-line/terminal. Because it goes through 250 (170 in my revision from 2008) useful and common commands that will bring joy to your life. I have only read half the book so far, but I have already learn a lot of commands that may be useful in the future. I don’t think that I will remember every command mentioned in the book, but I think it’s good to at least know what is available, so can I look it up (on Internet) when I need it.

Links: