Skip to content

Commit

Permalink
Support for OSTREE-based distributions (#181)
Browse files Browse the repository at this point in the history
  • Loading branch information
PilotGuy772 authored Aug 14, 2024
1 parent 59f8f58 commit 7a52eca
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,16 @@ envycontrol.packages.x86_64-linux.default

Thanks to [@ITesserakt](https://github.com/ITesserakt) for adding initial NixOS support!

### OSTree Distros (Silverblue, Kinoite, Bazzite, etc.)

These distributions are also supported by the same COPR repo as Fedora Workstation. Use the [COPR](https://copr.fedorainfracloud.org/coprs/sunwire/envycontrol/) maintained by [@sunwire](https://github.com/sunwire).

1. Enable the COPR by downloading the `.repo` file from the COPR page, linked above. Put the `.repo` file in `/etc/yum.repos.d`.
2. Clean package cache with `rpm-ostree cleanup -m`.
3. Overlay the package with `rpm-ostree install python-envycontrol`.
4. Reboot to apply the overlay.
5. Use EnvyControl with `sudo envycontrol -s <MODE>`

### From source

1. Clone this repository with `git clone https://github.com/bayasdev/envycontrol.git` or download the latest tarball from the releases page
Expand Down
14 changes: 11 additions & 3 deletions envycontrol.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
alias i2c_nvidia_gpu off
'''

UDEV_INTEGRATED_PATH = '/lib/udev/rules.d/50-remove-nvidia.rules'
UDEV_INTEGRATED_PATH = '/etc/udev/rules.d/50-remove-nvidia.rules'

UDEV_INTEGRATED = '''# Automatically generated by EnvyControl
Expand All @@ -57,7 +57,7 @@
ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x03[0-9]*", ATTR{power/control}="auto", ATTR{remove}="1"
'''

UDEV_PM_PATH = '/lib/udev/rules.d/80-nvidia-pm.rules'
UDEV_PM_PATH = '/etc/udev/rules.d/80-nvidia-pm.rules'

UDEV_PM_CONTENT = '''# Automatically generated by EnvyControl
Expand Down Expand Up @@ -357,6 +357,8 @@ def cleanup():
MODESET_PATH,
LIGHTDM_SCRIPT_PATH,
LIGHTDM_CONFIG_PATH,
'/lib/udev/rules.d/50-remove-nvidia.rules',
'/lib/udev/rules.d/80-nvidia-pm.rules'
]

# remove each file in the list
Expand Down Expand Up @@ -465,8 +467,14 @@ def get_amd_igpu_name():


def rebuild_initramfs():

# OSTREE systems first
if any(os.path.exists(dir) for dir in ['/ostree', '/sysroot/ostree']):
print('Regenerating initramfs with rpm-ostree. This will take several minutes; please be patient.')
command = ['rpm-ostree', 'initramfs', '--enable', '--arg=--force']

# Debian and Ubuntu derivatives
if os.path.exists('/etc/debian_version'):
elif os.path.exists('/etc/debian_version'):
command = ['update-initramfs', '-u', '-k', 'all']
# RHEL and SUSE derivatives
elif os.path.exists('/etc/redhat-release') or os.path.exists('/usr/bin/zypper'):
Expand Down

0 comments on commit 7a52eca

Please sign in to comment.