How To: Control The Mouse Pointer With A Remote Control

 

Lirc provides a mouse daemon (lircmd); however, if for some reason you don’t or can’t use lircmd, you can use xautomation as a simple alternative.

The Setup

Refer to my previous post for details on how to select a remote, basic lirc installation & setup, etc. For the sake of this tutorial, you can install lirc and xautomation via sudo apt-get install lirc xautomation.

Basic Configuration

The following .lircrc segment simply maps the arrow keys on the remote to xte mousermove (relative mouse cursor move) commands, and the central button to a left click. I’ve used 23 as the amount to move the cursor by on each click; it seems about right. Note the use of repeat to allow the buttons to be held down for rapid movement. You may need to edit the config before you can use it: i.e. to get remote and button values that are valid for your remote, run irw in a terminal and press the arrow buttons on your remote.

begin
        prog=irexec
        remote=Streamzap_PC_Remote
        button=UP
        config=xte "mousermove 0 -23"
        repeat=1
end

begin
        prog=irexec
        remote=Streamzap_PC_Remote
        button=DOWN
        config=xte "mousermove 0 23"
        repeat=1
end

begin
        prog=irexec
        remote=Streamzap_PC_Remote
        button=LEFT
        config=xte "mousermove -23 0"
        repeat=1
end

begin
        prog=irexec
        remote=Streamzap_PC_Remote
        button=RIGHT
        config=xte "mousermove 23 0"
        repeat=1
end

begin
        prog=irexec
        remote=Streamzap_PC_Remote
        button=OK
        config=xte "mouseclick 3"
end

Using A Magnifier

It may be useful to zoom in on the screen if you’re accessing it from across the room.

There are various magnifiers available for Gnome; I prefer the compiz magnifier (not the enhanced zoom desktop) — but experiment, and see what works for you. If you don’t already have it, install compizconfig-settings-manager. Launch compiz config, and assign a key combination to toggle zoom on / zoom off (I used shift ctrl z). Now add the following to your .lircrc:

begin
        prog=irexec
        remote=Streamzap_PC_Remote
        button=CH_UP
        config=xte "keydown Shift_L" "keydown Control_L" "key z" "keyup Shift_L" "keyup Control_L"
end

Defeat The Screensaver

Imagine you’re sitting across the room, and the screensaver has come on and locked. It might be handy if your remote control could unlock it, so that you could move the cursor around (e.g. to check for new email). Of course, this is a giant security hole if you don’t trust the physical location, but if you don’t care too much, then you can do the following. First, create and make executable ~/scripts/screensave, as follows:

#!/bin/bash

if [ $1 == 0 ] ; then
	gnome-screensaver-command -l
fi

if [ $1 == 1 ] ; then
	gnome-screensaver-command -d
fi

Now, add the following .lircrc configuration:

begin
        prog=irexec
        remote=Streamzap_PC_Remote
        button=MENU
        config=~/scripts/screensave 1
end

begin
        prog=irexec
        remote=Streamzap_PC_Remote
        button=EXIT
        config=~/scripts/screensave 0
end