Skip to content

Instantly share code, notes, and snippets.

@komamitsu
Last active November 2, 2024 11:22
Show Gist options
  • Save komamitsu/307669cfedb9d97cef45c86f357b9b5b to your computer and use it in GitHub Desktop.
Save komamitsu/307669cfedb9d97cef45c86f357b9b5b to your computer and use it in GitHub Desktop.
Execute xremap from systemd

Execute xremap as root user

Create /etc/systemd/system/xremap.service file

[Unit]
Description=xremap service
After=default.target

[Service]
ExecStart=/usr/bin/xremap /home/komamitsu/xremap.yml

[Install]
WantedBy=default.target

Register the service to systemd

sudo systemctl enable xremap.service

Start the service

sudo systemctl start xremap.service

Execute xremap as a normal user

(Thank you https://github.com/dcraig327!)

Allow the user to access input events

Add the user to input group if it's not added.

sudo gpasswd -a YOUR_USER input

Then, execute the following command if /etc/udev/rules.d/input.rules doesn't have the entry.

echo 'KERNEL=="uinput", GROUP="input", TAG+="uaccess"' | sudo tee /etc/udev/rules.d/input.rules

Create $HOME/.config/systemd/user/xremap.service file

[Unit]
Description=xremap
After=default.target

[Service]
ExecStart=%h/.cargo/bin/xremap %h/.config/xremap/config.yml
StandardOutput=journal
StandardError=journal
Restart=always

[Install]
WantedBy=default.target

Register the service to systemd

systemctl --user enable xremap.service

Start the service

systemctl --user start xremap.service
@dcraig327
Copy link

dcraig327 commented Sep 21, 2024

Thank you. This also works to run as a user service.

$HOME/.config/systemd/user/xremap.service

[Unit]
Description=xremap
After=default.target

[Service]
ExecStart=%h/.cargo/bin/xremap --mouse %h/.config/xremap/config.yml
StandardOutput=journal
StandardError=journal
Restart=always

[Install]
WantedBy=default.target

Installation follow the rust instructions, then install the service

$ systemctl --user enable xremap.service
$ systemctl --user start xremap.service

Check status or errors

$ systemctl --user status xremap.service
$ journalctl -r

Editing and saving the new changes in config.yml file should auto-update without any extra work. In case it doesn't, find the error. After fixing the error in the service file reload it.

$ systemctl --user daemon-reload
$ systemctl --user restart xremap.service

Uninstallation

$ systemctl --user stop xremap.service
$ systemctl --user disable xremap.service

@komamitsu
Copy link
Author

@dcraig327 Thanks! I'll try it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment