Combine xf86-input-evdev middle button + wheel emulation, Kensington Orbit Trackball

This “mouse” is the best thing since sliced bread. No more wrist bending carpal tunnel syndrome inducing table mice for me. Witness the awesomeness for yourself:

In the interest of keeping price low and functions simple, this thing only has two buttons. I now happened to run into a situation where Xorg’s standard wheel and middle button emulation configuration didn’t cut it, because evdev (as of 2.7.3) doesn’t support wheel emulation on top of middle button emulation.

My previous configuration consisted of having the right button do wheel emulation: holding it down and moving the trackball would scroll the document up and down. Single click gives the regular context menu popup etc. Apparently this works for about 99% of the time because I didn’t have a problem until I needed the right button held down for a Tcl/Tk application context menu (hi git gui!).

After finding out I can’t just hold both buttons down (middle button emulation) and scroll with it (wheel emulation on top of middle button emulation) — see above –, doing plenty of remapping logic exercises finally resulted in a configuration that works. Enter third button emulation into the picture, which will replace middle button emulation.

Here’s the final configuration (replace 11 with your device id from “xinput list”):

$ xinput list-props 11
Device 'Kensington      Kensington USB/PS2 Orbit':
	Device Enabled (134):	1
	Coordinate Transformation Matrix (136):	1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000
	Device Accel Profile (261):	0
	Device Accel Constant Deceleration (262):	1.000000
	Device Accel Adaptive Deceleration (263):	1.000000
	Device Accel Velocity Scaling (264):	10.000000
	Device Product ID (252):	1149, 4130
	Device Node (253):	"/dev/input/event6"
	Evdev Axis Inversion (560):	0, 0
	Evdev Axes Swap (562):	0
	Axis Labels (563):	"Rel X" (144), "Rel Y" (145)
	Button Labels (564):	"Button Left" (137), "Button Unknown" (559), "Button Right" (139), "Button Wheel Up" (140), "Button Wheel Down" (141)

We disable middle button emulation, because when enabling third button emulation there is no more use for it.

	Evdev Middle Button Emulation (565):	0
	Evdev Middle Button Timeout (566):	50

Hello third button emulation. Because right mouse button will be occupied for wheel emulation, which requires a real non-emulated button, this will be our new right-click that can be held down. Thing to watch out here for is the timeout. I’m finding 400ms delay is about right. Default of 1000ms was definitely annoyingly long. 200ms is too short, you will have trouble selecting text without getting a right-click.

Notice I’m setting the emulated button to “2″. This is for getting apps to keep functioning in a regular expected way.

	Evdev Third Button Emulation (567):	1
	Evdev Third Button Emulation Timeout (568):	400
	Evdev Third Button Emulation Button (569):	2
	Evdev Third Button Emulation Threshold (570):	20

Wheel emulation is all regular stuff, except for setting the emulated button to “3″.

	Evdev Wheel Emulation (571):	1
	Evdev Wheel Emulation Axes (572):	0, 0, 4, 5
	Evdev Wheel Emulation Inertia (573):	10
	Evdev Wheel Emulation Timeout (574):	200
	Evdev Wheel Emulation Button (575):	3
	Evdev Drag Lock Buttons (576):	0

And here’s the final piece of the puzzle, reversing buttons “2″ and “3″ mapping. This makes sure the wheel emulation ends up on the real, non-emulated button.

leho@s9 ~ $ xinput get-button-map 11
1 3 2 4 5

To sum it all up, problem solved here is getting a right-click that can be held, while still maintaining wheel emulation, with a 2-button mouse.

Everything in terms of /etc/X11/xorg.conf.d:

leho@s9 ~ $ cat /etc/X11/xorg.conf.d/51-kensington.conf
Section "InputClass"
    Identifier "My Kensington Orbit Trackball"
    Driver "evdev"
    Option "ButtonMapping" "1 3 2 4 5"
    Option "EmulateMiddleButton" "False"
    Option "EmulateThirdButton" "True"
    Option "EmulateThirdButtonButton" "2"
    Option "EmulateThirdButtonMoveThreshold" "0"
    Option "EmulateThirdButtonTimeout" "400"
    Option "EmulateWheel" "True"
    Option "EmulateWheelButton" "3"
    MatchProduct "Kensington USB/PS2 Orbit"
EndSection

EDIT
One more parameter needs to be tuned. Default setting of EmulateThirdButtonMoveThreshold 20 disturbs selecting text and drag-n-dropping stuff with the left. You can safely set the threshold to 0, since with a trackball there is pretty much no involuntary movement of the cursor after clicking, like there can be with the regular mouse connected to the whole palm of your hand. 51-kensington.conf has been updated accordingly.

WordPress – a solution to “You do not have sufficient permissions to access this page”

Ran into this wonderful WordPress “feature” with MicroKid Related Posts. I would get the error when saving “Related Posts” admin page options. Search hits like this didn’t apply. Browsing results made it seem like this error could’ve been caused by about a thousand different things, including your dog farting too loud.

Problem: plugin directory name “microkid-related-posts.svn”, since I check them out directly and like to know the scm type used

Solution: remove “.svn” from directory name

Should anyone know why that helps, I’d welcome some hints.

Using interactive commands during emerge ebuild phases

Gentoo Portage’s primary tool emerge is largely meant to run as a non-interactive process. Meaning aside from the –ask flag making it get user confirmation before beginning operations, rest of the process is supposed to finish without any further user input.

This mostly makes sense, because compiling software can be a lengthy process. Even more so when you’re possibly emerging tens of packages at a time. It makes no sense for the user to guard the terminal and stare at the Matrix, waiting to answer the occasional, usually trivial Yes/No prompt.

But in this particular use case I have, I’ve discovered I’d like to run an interactive command etc-update after every package finishes installing (ebuild postinst phase). My goal is to have a firm grip on a vserver bootstrap template configuration with the help of git. Portage’s configuration protection litters /etc with ._cfg* files and I would rather not spread the litter to the git repo by just blindly committing everything in postinst. Also, maintaining the bootstrap template is usually a rare and short operation (few packages at a time) where I can monitor the build and act on request.

Your ${ROOT}/etc/portage/bashrc could have something like this:

echo Phase: $EBUILD_PHASE
ETC="${ROOT}etc"
GITCMD="GIT_DIR=$ETC/.git GIT_WORK_TREE=$ETC git"

case "$EBUILD_PHASE" in
    "setup")
        STATUS=$(eval $GITCMD status -uno -s)
        [ -n "${STATUS}" ] && die "Error: $ETC is not clean"
    ;;
    "postinst")
        etc-update
        eval $GITCMD add $ETC
        eval $GITCMD commit -q -a -m \"emerge $CATEGORY/$P\"
    ;;
esac

Problem is that emerge pipes everything to its logfiles and won’t let etc-update get any input from you. Some googling revealed a solution by redirecting stdin and stdout. /dev/tty is magic that always has the right answer, google it yourself for details.

${ROOT}/etc/portage/bashrc:

...
    "postinst")
        etc-update 0</dev/tty 1>/dev/tty
...

N950 tip: enable ssh user@n950 with public key authentication

EDIT This continues to work just fine with 39-5 for me.
EDIT Seems to also work on the fresh 34-2 firmware without issues.

With aegis watching over us like a true eye in the sky, getting N950 to let you ssh in as unprivileged user with public key authentication took a bit of effort. Sure, you could ssh root@n950 and then su – user, but doesn’t the sane world do it the other way around?

Anyway, get your authorized_keys file on the device as root with sftp, or manually typing it. No, just sftp it, dude. Now aegis won’t let root see ~user/.ssh and also won’t let user see /root/.ssh contents.

# cp /root/.ssh/authorized_keys /tmp
# chmod 644 /tmp/authorized_keys
# su - user
$ cp /tmp/authorized_keys .ssh
$ exit

At this point ssh user@n950 still shouldn’t be letting you in, because apparently the account is locked by default. syslogd doesn’t by default log sshd stuff, so if you want to see this for yourself do this as root:

# echo "auth.* -/var/log/secure.log" >> /etc/syslog.conf
# stop syslogd
# start syslogd
# tail -f /var/log/syslog /var/log/secure.log

Now try ssh user@n950, this is what you should see:

==> secure.log <==
Jul 25 01:09:11 RM680 sshd[2838]: User user not allowed because account is locked
Jul 25 01:09:11 RM680 sshd[2838]: Failed none for invalid user user from 192.168.1.111 port 354
83 ssh2

Solution is to unlock the account.

EDIT Originally I thought usermod -U user would do the trick. It turns out it doesn't work out so well. aegis-loader (and possibly other parts) started puking when doing dpkg -i etc.

/home/developer $ dpkg -i conboy_0_0_1_armel.deb
aegis-loader: Failed parsing '/etc/passwd
...hanging forever

After a bunch of folks on #harmattan helped me get to the bottom of this, mgedim pointed out passwd seemed to work for him:

# passwd -u user

I have no idea what usermod and passwd are doing different aegis-wise. Hints welcome!

WP-to-Twitter test, done with Twitter Tools

So after Twitter Tools is reportedly malfunctioning on a number of sites, including mine, and doesn’t so far support URL shorteners and themsuch, I’m switching to WP-to-Twitter according to this hint.

N950 tip: run ranger, Pythonic vim-inspired file manager

Harmattan has Python 2.6.6, so ranger can run here, as opposed to N900 with Python 2.5.

Find address for latest tgz-ball. Unpack.

$ devel-su
Password: rootme
# cd hut-ranger-<hash>

We can’t execute scripts directly because of aegis, so just run the script into python.

# python ./setup.py install --optimize=1 --record=install_log.txt
# exit

This will install ranger into /usr/local and exit root shell. Now we also can’t run ranger directly because of aegis. Let’s set up an alias for this. Busybox needs $ENV to specify a startup script for it’s built-in ash.

$ vi .profile

Append “export ENV=$HOME/.bashrc” somewhere. Sure, why not “.bashrc”, we’ll be ready as soon as a working bash package gets finally built.

$ echo "alias ranger='python /usr/local/bin/ranger'" > .bashrc

Here’s a screenshot of ranger on N950. Just delicious, surely tastier than mangos.