fusuma icon indicating copy to clipboard operation
fusuma copied to clipboard

Use systemd to start fusuma at boot

Open worldofpeace opened this issue 7 years ago • 14 comments

Currently the best way of starting fusuma is running fusuma & disown. I would expect fusuma to automatically start on boot but it doesn't.

This is a simple as creating a systemd unit file.

worldofpeace avatar Nov 15 '17 11:11 worldofpeace

For example:

$ cat /etc/systemd/user/fusuma.service 
[Unit]
Description=Fusuma touchpad gestures

[Service]
EnvironmentFile=/home/youruser/config/fusuma/env
ExecStart=/usr/local/bin/fusuma
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure
RestartSec=42s
User=youruser
Group=yourusergroup

[Install]
WantedBy=multi-user.target

The contents of the environment file at /home/youruser/config/fusuma/env is just DISPLAY=:0, where youruser is your user account name.

Then sudo systemctl enable /etc/systemd/user/fusuma.service

awlunsfo avatar Nov 20 '17 23:11 awlunsfo

@awlunsfo Thanks for your response!

The only thing I think that will cause problems is ExecStart=/usr/local/bin/fusuma. Everyone is getting ruby from different places and, they also could be using rvm, rbenv, etc. You can run which fusuma and that will give you the path of fusuma.

Also I think it would make sense for this service to be created when you install fusuma. So we'll have to make a template for the service and a script to setup fusuma.

worldofpeace avatar Nov 21 '17 15:11 worldofpeace

I think it's better to create [email protected] template and then enable it for specific user. When it's enabled this way %i becomes user so it's not necessary to write username into .service

Also DISPLAY=:0 can be set right in .service:

Here's my solution:

Create service file: /lib/systemd/system/[email protected]

[Unit]
Description=Fusuma multitouch gesture recognizer

[Service]
Type=simple
Environment="DISPLAY=:0"
User=%i
ExecStart=/usr/local/bin/fusuma
KillMode=process
Restart=on-failure
    
[Install]
WantedBy=graphical.target

Enable it for the user

systemctl enable [email protected]

yellowgh0st avatar Dec 11 '17 20:12 yellowgh0st

Instead of creating system-wide unit for specific user, it's advised to create user's unit which is managed by systemctl --user. At this case you don't need to specify user under which you need to run the service and DISPLAY var is automatically set (if you distribution is sane enough). Hint: DISPLAY isn't always a :0.

z0rc avatar Jan 11 '18 11:01 z0rc

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Apr 15 '18 07:04 stale[bot]

I think it's better to create [email protected] template and then enable it for specific user.

I don't know why specifying via template ([email protected]) worked and why just specifying just unit (fusuma.service) doesn't work.

rajeshisnepali avatar Feb 08 '21 06:02 rajeshisnepali

@rajeshisnepali, @z0rc: Fusuma needs to run under the input group but systemd user services cannot change their group. Thus a Fusuma system service can run successfully since it'll run as root, but a user service will fail since it'll only run under the user's group and won't have access to the input devices.

One solution to this would be creating a system wide service file and shipping it with the program. I might do this for the AUR package.

quantumgc avatar Mar 11 '21 19:03 quantumgc

@quantumgc what about these patterns [email protected] and fusuma.service.

rajeshisnepali avatar Mar 12 '21 00:03 rajeshisnepali

@rajeshisnepali: If I'm reading the thread correctly, the recommendation is to install both of those files in /usr/lib/systemd/system/ so they're not user service files. User service files are either installed in /usr/lib/systemd/user/ which installs them for every user (but they still run as user services) or in ~/.config/systemd/user for per-user files.

quantumgc avatar Mar 15 '21 20:03 quantumgc

for me saving in ~/.config/systemd/user didn't work. Neither in /usr/lib/systemd/user/. Only works if I'd name as [email protected], not as fusuma.service

rajeshisnepali avatar Mar 16 '21 11:03 rajeshisnepali

@yellowgh0st , not working, error

failed to creating new xdo instance

videni avatar Aug 20 '21 07:08 videni

@yellowgh0st thanks for you script, but i encounter a problem that i can not use qdbus command like qdbus org.kde.kglobalaccel /component/kwin invokeShortcut Expose with systemd service, but when i manully launch fusuma from terminal, the qdbus command works as expected.

ch3n9w avatar Oct 06 '21 08:10 ch3n9w

@ch4xer Same problem here.

NikhilSaini38 avatar Mar 13 '22 13:03 NikhilSaini38

If your systemd fusuma config not working you can check logs with journalctl -u fusuma (or your name for service) And if you have this error in logs

appmatcher doesn't support
XDG_CURRENT_DESKTOP: ''
XDG_SESSION_TYPE: ''"

Just add Environment="XDG_SESSION_TYPE=x11" to your systemd config. To check right values run echo $XDG_SESSION_TYPE

superpupervlad avatar Jul 18 '23 18:07 superpupervlad