Starting imwheel automatically on login

This was way more annoying than it should have been – I am using imwheel to increase scroll speed and wanted to set up my Manjaro 5.15 KDE environment so that it starts automatically at startup. The following things did not work:

  • Setting up an autostart shortcut to imwheel
  • Setting up a login script for autostart that ran imwheel

There are likely some better low-tech (read simple linking to bash_profile or something similar) that would work but I decided to go for more punishment. I decided to look into using systemd user configured units to set up a unit that will auto start imwheel on login.

The critical thing to note is that imwheel should be started once the X session is established and you have the X authentication cookie and DISPLAY environment variables set. Trying to articulate all of this in systemd is a sheer exercise in frustration. This is one place where the Internetz did not help despite my search-fu. In the end, I came up with the following magic incantation that works perfectly. You need to put this in $HOME/.config/systemd/user/imwheel.service:

[Unit]
Description=IMWheel
After=plasma-kwin_x11.service
PartOf=graphical-session.target
[Service]
Type=simple
Environment=XAUTHORITY=%h/.Xauthority
Environment=DISPLAY=:0
ExecStart=/usr/bin/imwheel -kill -d
ExecStop=/usr/bin/pkill imwheel
RemainAfterExit=yes
Restart=on-failure
Slice=session.slice
[Install]
WantedBy=graphical-session.target

After this, you should run systemctl --user enable imwheel and you should be all set to have imwheel automatically start when you login to your KDE environment. To come up with this magic incantation, I used systemctl --user status to list all the user level systemd units and then pieced this together. I really need to read the systemctl documentation to understand how to specify dependencies better but that needs to wait for another day.

Leave a Reply

Your email address will not be published. Required fields are marked *