How bayasdev/envycontrol works
Project type and purpose
• This is a Python-based CLI tool (“envycontrol.py”) for switching GPU modes (integrated, hybrid, Nvidia) on Linux systems with hybrid graphics (Optimus). It handles configuration files (X11, modprobe, udev), calls into system utilities (nvidia-settings, xrandr), and manages a small JSON cache.
File structure
• Top-level files:
• envycontrol.py – main entry point containing CLI parsing and core logic
• setup.py – installer script for pip/packaging
• flake.nix – Nix packaging integration
• logos/ – project branding assets
• .github/, LICENSE, README.md, .gitignore – project metadata and CI/templates
• No frontend/backend split; it’s a single-process CLI with internal modules (all in envycontrol.py or imported from the standard library).
README for additional insights
• Describes supported modes, flags, cache behavior, display-manager workarounds, and deployment targets (AUR, Fedora COPR, Debian .deb, NixOS).
• Key architectural points: mode handlers for each GPU mode, a JSON cache in /var/cache/envycontrol, and per-DM hooks (GDM/SDDM/LightDM).
Capturing essential architectural elements
• GPU mode as a separate handler module.
• Cache Manager reading/writing the JSON file.
• How display-manager choice drives slight variations in file paths or scripts.
• Packaging artifacts (setup.py, flake.nix) as the installation/deployment component.