A Go port of EnvyControl - a tool for switching graphics modes on NVIDIA Optimus laptops.
This is a one shot port from python (original EnvyControl) -> golang version using bolt.new, I didn't expect this to work at the first try and it must be unstable so use it with caution. USE IT WITH CAUTION!! USE IT WITH CAUTION!!
- Graphics Mode Switching: Switch between integrated, hybrid, and NVIDIA-only modes
- System Detection: Automatic detection of GPU hardware and display managers
- Configuration Management: Automated creation and cleanup of system configuration files
- Caching System: Optimized operations with intelligent caching
- Cross-Distribution Support: Works across different Linux distributions
- Service Management: Automatic handling of nvidia-persistenced service
# Clone the repository
git clone <repository-url>
cd envycontrol
# Build the project
./scripts/build.sh
# Install (requires root privileges)
sudo ./scripts/install.sh# Build for your platform
go build -o envycontrol .
# Copy to system directory
sudo cp envycontrol /usr/local/bin/
sudo chmod +x /usr/local/bin/envycontrol# Check current graphics mode
envycontrol query
# Switch to integrated graphics (power saving)
sudo envycontrol switch integrated
# Switch to hybrid mode (balanced)
sudo envycontrol switch hybrid
# Switch to NVIDIA-only mode (performance)
sudo envycontrol switch nvidia
# Reset all EnvyControl changes
sudo envycontrol reset# NVIDIA mode with additional options
sudo envycontrol switch nvidia \
--dm sddm \
--force-comp \
--coolbits 28
# Hybrid mode with RTD3 power management
sudo envycontrol switch hybrid --rtd3 2
# Use nvidia-current drivers instead of nvidia
sudo envycontrol switch hybrid --use-nvidia-current
# Verbose output for debugging
sudo envycontrol switch nvidia --verbose# Create cache (requires hybrid mode)
sudo envycontrol cache create
# View cache content
envycontrol cache query
# Delete cache
sudo envycontrol cache deleteEnvyControl supports the following display managers:
- GDM / GDM3 (default, no additional configuration needed)
- SDDM (automatic Xsetup script generation)
- LightDM (automatic configuration)
- Uses only the integrated GPU (Intel/AMD)
- Best battery life
- NVIDIA GPU is powered off
- Suitable for basic tasks
- Both GPUs available
- Automatic switching based on application requirements
- Balanced performance and battery life
- Supports RTD3 power management
- Uses NVIDIA GPU for all rendering
- Best performance for gaming and GPU-intensive tasks
- Higher power consumption
- Supports additional NVIDIA features
0: Disabled1: Enabled2: Fine-grained control (default)3: Coarse-grained control
Enables GPU overclocking and fan control:
28: Standard overclocking (default)- Custom values: 0-255
Reduces screen tearing by forcing composition pipeline.
- Linux distribution with systemd
- NVIDIA Optimus laptop with dual GPUs
- Root privileges for system configuration
- Go 1.21+ for building from source
EnvyControl automatically detects and supports:
- Ubuntu/Debian (update-initramfs)
- Fedora/RHEL/CentOS (dracut)
- Arch Linux/Manjaro (mkinitcpio)
- openSUSE (dracut)
- EndeavourOS (dracut-rebuild)
- ALT Linux (make-initrd)
- OSTree-based systems (rpm-ostree)
The Go port follows a clean, modular architecture:
envycontrol/
├── cmd/ # CLI commands and argument parsing
├── internal/ # Private application logic
│ ├── config/ # Configuration templates and caching
│ ├── system/ # System detection and file operations
│ ├── modes/ # Graphics mode switching logic
│ └── utils/ # Utilities and helpers
├── pkg/ # Public API and types
└── scripts/ # Build and installation scripts
The application provides comprehensive error handling with detailed error messages:
- SystemError: File system and command execution errors
- ConfigError: Configuration-related errors
- ValidationError: Input validation errors
- DetectionError: Hardware detection errors
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project maintains the same license as the original Python EnvyControl project.
This Go port is based on the original EnvyControl Python project by geminis3.