wheaney / breezy-desktop

XR virtual workspace library for Linux
GNU General Public License v3.0
272 stars 33 forks source link

Need a non root version of setup #8

Closed mnjm97 closed 2 months ago

mnjm97 commented 10 months ago

I am sure I am missing something but As far as I can tell there is really no need to require root to install this. isn't everything being installed into users home dir anyway?

wheaney commented 10 months ago

There are a couple things going on here:

  1. Decky and Breezy needed root to set up the systemd service, so Decky won't be able to avoid the root tag unless Breezy has some way to install without it.
  2. Root doesn't require udev rules to access USB devices, so my package doesn't have to maintain or install any of those.

(2) is just a convenience thing and could be worked around by adding udev rules if we found a way to work around (1). I can't remember if there were other reasons now because it's probably been 6 months since I converted it to root.

mnjm97 commented 10 months ago

for users that don't use systemd or simply don't want to have the daemon running, there really should be a way to install and run this manually without root.

also, this is causing me permission issues. which is why I inquired in the first place.

wheaney commented 10 months ago

The daemon was the only good way I found to go about this. I tried triggering the program from a udev rule (triggered when a device matching the rule is plugged in), as those can kick off commands, but they don't do well with long-running commands and it got very messy. The daemon approach has caused zero problems since. I'm happy to take a PR on this if you can do it in a way that works well across all platforms and primarily Steam Deck, but it's not something I care to tackle right now.

mnjm97 commented 10 months ago

you could use the --user flag for systemctl and place the xreal-air-driver.service inside $USER_HOME/.config/systemd/user

that would avoid any need for root.

I tested and verified this works on my system. not sure how to do a PR. never done that before.

wheaney commented 10 months ago

You would also need to place the udev rules if you're not using root. I believe also the systemctl calls during setup would require root (maybe not for a user daemon?). But, if the setup requires root, and running as root makes things simpler because then I don't have to manage udev rules for the devices I want to support, I'm not really inclined to move forward with this request. I'm also afraid we'll break something subtle in doing so. What exactly is the motivation?

mnjm97 commented 10 months ago

ah, sorry I was confused. I thought that the udev rules weren't being used. I still had the old udev rules installed when I tested. my bad.

as for motivation, I have always believed that root should be used only if absolutely necessary. in this case I guess it is.

wheaney commented 10 months ago

You're right, though, so I'll leave this open.

I would be okay going about this if:

I think the extra burden of managing udev rules is a small tradeoff for being able to get rid of excessive usage of root.

wheaney commented 9 months ago

This has come up a couple more times in the context of Breezy as a general Linux app, as some distros don't seem to be happy with this service running as root. My previous hesitation was Decky-setup specific because I don't see any way to move that setup away from root. For all other purposes -- and especially as non-decky Linux installs become more common after I get a productivity solution ready -- it's going to become important that we make this a user-level systemd service. The setup and uninstall scripts will still need to run as root, but the service itself should run as the user.

wheaney commented 3 months ago

The AUR installation of XR driver is now running it as a user service for use with Breezy GNOME (there's still not a gaming-ready driver setup in AUR). The scripted installation used for all other distros and gaming purposes is still running as root, but I'll be able to move that to a user service shortly. Install and uninstall will always require root, so the decky plugin will always have to have root access.

wheaney commented 3 months ago

Finally have an implementation ready to test for this in a branch. Setup still requires sudo to copy the udev rules, unfortunately, but after that, the service itself runs as your user. Here's how to test:

  1. Download the driver setup and set the execute flag on it: chmod +x ~/Downloads/xr_driver_setup
  2. Run it with the dev tag: sudo ~/Downloads/xr_driver_setup --tag v0.10-user-2. Keep an eye out for any errors, since the setup has changed significantly.
  3. Enable it and set it to mouse mode (don't combine the commands):
    • xr_driver_cli -e
    • xr_driver_cli -m
  4. Plug in your glasses, wait 15-30 seconds, then move them around. If it's working, it'll move the mouse cursor. If not, attach your driver log: ~/.local/state/xr_driver/driver.log

You can verify it's running as user by running ps aux | grep xrDriver and looking at the process details.

Other things to try:

wheaney commented 3 months ago

Initial testing on steam deck revealed that the /usr directory is part of the read-only file system, which is where I'm installing the udev rules. /etc is the other standard location, which is also read-only. Initial testing on my personal Arch linux machine showed that home-directory based udev rules wouldn't be picked up. I'll play around with this a little more on deck, but it may have to continue using a legacy root-service, while all other non-deck installs could use the user-service.

Edit: fortunately I was wrong about /etc, I've updated the script to copy files there for steamos and it worked!

wheaney commented 2 months ago

Resolved in https://github.com/wheaney/XRLinuxDriver/pull/70

To summarize: