DEV Community

Discussion on: Game show feeling: How I created a hardware mute button for Linux

Collapse
 
goodevilgenius profile image
Dan Jones • Edited

With systemd, you can create a user service, so that you don't need root permissions to create the file and whatnot.

You create the .service file the same way, but without User=USER line, and change the WantedBy to default.target
Save this file to ~/.config/systemd/user/
Now, for all your systemd commands, instead of sudo systemd, do systemd --user.

So:

systemctl --user start mutebutton
systemctl --user enable mutebutton
Enter fullscreen mode Exit fullscreen mode

After reboot, it'll start up when you log in.

And when you want to read the logs, just do journalctl --user -u mutebutton.

Here's some more info: wiki.archlinux.org/index.php/syste...

Collapse
 
thormeier profile image
Pascal Thormeier

Thank you for this hint, I wasn't aware of this being possible! Is there any drawbacks to this?

Collapse
 
goodevilgenius profile image
Dan Jones

I've actually been using systemd to replace my user's crontab recently as well.

Thread Thread
 
thormeier profile image
Pascal Thormeier

Oh wow, didn't know this was possible, either! I really need to dig deeper into systemd then, thank you!

Collapse
 
goodevilgenius profile image
Dan Jones

I've been using it a lot for myself lately. I've only found two downsides.

  1. I sometimes forget to add --user
  2. The user instance of systemd doesn't start until the user's first login. So, if I need something to start right away, even if the user hasn't logged in yet, I need to use the system-wide systemd instead. This has never been a real issue to me, though, since I log in to my user as soon as I boot up the computer.