Skip to content
This repository was archived by the owner on May 3, 2026. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions envycontrol.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,7 @@ def get_amd_igpu_name():
except subprocess.CalledProcessError:
logging.warning(
"Failed to run the 'xrandr' command.")
return None

pattern = re.compile(r'(name:).*(ATI*|AMD*|AMD\/ATI)*')

Expand Down Expand Up @@ -646,7 +647,11 @@ def adapter(self):
global get_nvidia_gpu_pci_bus
use_cache = os.path.exists(CACHE_FILE_PATH)

if self.is_hybrid(): # recreate cache file when in hybrid mode
# Only cache the GPU PCI bus when leaving hybrid mode.
# Switching *to* hybrid never needs the cached value and the GPU
# may not be visible via lspci if old udev removal rules are still
# in place, which would make create_cache_file() exit early.
if self.is_hybrid() and self.app_args.switch != 'hybrid':

Copilot AI Mar 12, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if self.is_hybrid() and self.app_args.switch != 'hybrid': will also run when --reset / --reset-sddm are used (since app_args.switch is None), causing an unnecessary cache (re)creation and potential failure on systems where the dGPU isn’t visible even though get_current_mode() reports hybrid. If the intent is “only when leaving hybrid mode”, it would be safer to gate on an explicit switch target (e.g., only when switch is 'integrated' or 'nvidia').

Suggested change
if self.is_hybrid() and self.app_args.switch != 'hybrid':
if self.is_hybrid() and self.app_args.switch in ('integrated', 'nvidia'):

Copilot uses AI. Check for mistakes.
self.create_cache_file()

if use_cache:
Expand Down Expand Up @@ -716,7 +721,9 @@ def write_cache_file(self):

def get_current_mode():
mode = 'hybrid'
if os.path.exists(BLACKLIST_PATH) and (os.path.exists(UDEV_INTEGRATED_PATH) or os.path.exists('/lib/udev/rules.d/50-remove-nvidia.rules')):
if (os.path.exists(BLACKLIST_PATH) or
os.path.exists(UDEV_INTEGRATED_PATH) or
os.path.exists('/lib/udev/rules.d/50-remove-nvidia.rules')):
mode = 'integrated'
elif os.path.exists(XORG_PATH) and os.path.exists(MODESET_PATH):
mode = 'nvidia'
Expand Down
Loading