April, 2013

29
Apr 13

Enabling keyboard mouse emulation out with Gnome/KDE

Gnome calls it “Mouse Keys” and it allows you to use something like xmodmap -e 'keycode 135 = Pointer_Button2' to make a key operate as a middle mouse button. If you don’t run Gnome/KDE though, you need to first turn on keyboard mouse emulation yourself by running:

xkbset m
xkbset exp =m

Goodbye gnome-settings-daemon, I won’t miss you.


28
Apr 13

User suspend/resume service scripts for systemd

I’m using Arch Linux these days, still with xmonad, and am trying to get away from as much Gnome stuff as possible. I have written these suspend and resume services for systemd to allow unprivileged users to suspend and lock the screen (using slock) and ensure that xmodmap runs on resume. They were adapted from the very useful Arch systemd wiki page and might come in handy for you too.

/etc/systemd/system/suspend@.service


[Unit]
Description=User suspend actions
Before=sleep.target

[Service]
User=%I
Type=simple
Environment=DISPLAY=:0
ExecStart=/usr/bin/slock

[Install]
WantedBy=sleep.target

/etc/systemd/system/resume@.service


[Unit]
Description=User resume actions
After=suspend.target

[Service]
User=%I
Type=oneshot
Environment=DISPLAY=:0
ExecStart=/usr/bin/sleep 1 ; /usr/bin/xmodmap /home/%u/.Xmodmap

[Install]
WantedBy=suspend.target

I’m not sure why I need to add the /usr/bin/sleep 1 in the resume service.

Don’t forget to enable them with systemctl enable suspend@yourusername.service and systemctl enable resume@yourusername.service as well as run systemctl --system daemon-reload whenever you change those files and something stuff like systemctl status resume@yourusername.service to help you debug them.

To suspend, run systemctl suspend as your unprivileged user. Zzz….