bayasdev / envycontrol

Easy GPU switching for Nvidia Optimus laptops under Linux
MIT License
1.22k stars 62 forks source link

[REQUEST] EnvyControl on an immutable distro #180

Closed PilotGuy772 closed 4 weeks ago

PilotGuy772 commented 1 month ago

Is your feature request related to a problem? Please describe. I cannot run envycontrol in its current state on my ostree-based distro because the software is not able to write to the read-only directory /lib/udev/.

Describe the solution you'd like If possible, the software should have some sort of compatibility mode or just be retooled to work in an immutable distro. In most immutable distros, the files in /etc/udev/rules.d/ are mutable. Envycontrol should be reworked to manipulate rules in /etc/udev/rules.d/ instead of in /lib/udev/rules.d/. In fact, the entire purpose of /etc/udev/rules.d/ is for things like envycontrol, while /lib/udev/rules.d/ is really for OS default rules. .rules files in /etc/udev/rules.d/ should override files in /lib/udev/rules.d/ anyways, so I wouldn't imagine it would be too painful to implement.   Describe alternatives you've considered This is frankly the only software around that appears to be still maintained and does what I want it to. There aren't any other alternatives. I've considered moving to a mutable distro, but I like bluefin too much ;) and I don't want to set up a whole new OS install.

Additional context When I try to switch graphics, it errors out the ass with this output:

❯ sudo envycontrol -s integrated
Place your finger on the fingerprint reader
Switching to integrated mode
Successfully disabled nvidia-persistenced.service
ERROR: Failed to remove file '/lib/udev/rules.d/50-remove-nvidia.rules': [Errno 30] Read-only file system: '/lib/udev/rules.d/50-remove-nvidia.rules'
ERROR: Failed to remove file '/lib/udev/rules.d/80-nvidia-pm.rules': [Errno 30] Read-only file system: '/lib/udev/rules.d/80-nvidia-pm.rules'
ERROR: Failed to create file '/lib/udev/rules.d/50-remove-nvidia.rules': [Errno 30] Read-only file system: '/lib/udev/rules.d/50-remove-nvidia.rules'
Rebuilding the initramfs...
ERROR: An error ocurred while rebuilding the initramfs
Operation completed successfully
Please reboot your computer for changes to take effect!

Bold of it to claim that the operation was completed successfully...

As for the errors with rebuilding the initramfs... rpm-ostree has sub-commands initramfs and initramfs-etc, which together seem to support modifying the initramfs.Add any other context or screenshots about the feature request here.

PilotGuy772 commented 1 month ago

This is an open-source project and I'm reasonably confident with Linux sysadmin and Python so... I think I'll just try to fix this up myself and open a PR. I'll share my findings along the way.

PilotGuy772 commented 1 month ago

Update: this works perfectly when the patches are applied in /etc/udev/rules.d/, at least on my install. I'm working on integrating a --ostree option to declare that the system uses ostree, but this should actually be relatively easy to implement into the platform checker.