Minimal GPU MUX switcher for MSI laptops on Linux.
⚠️ Use at your own risk. This tool writes directly to UEFI variables and Embedded Controller registers. I take no responsibility for any damage or loss caused by its use.
| Laptop | EC Firmware |
|---|---|
| MSI Alpha 17 C7VG | 17KKIMS1.114 |
Other MSI models may work if they share the same UEFI variable and EC layout. Open an issue with your model and firmware version if it works or fails.
- Linux with
efivarfsmounted at/sys/firmware/efi/efivars ec_syskernel module loaded withwrite_support=1debugfsmounted at/sys/kernel/debug- Root privileges
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
msi-gpu-switcher = {
url = "github:elxreno/msi-gpu-switcher";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { nixpkgs, msi-gpu-switcher, ... }:
{
nixosConfigurations."hostname" = nixpkgs.lib.nixosSystem {
...
modules = [
({ pkgs, ... }: {
environment.systemPackages = [
msi-gpu-switcher.packages.${pkgs.stdenv.hostPlatform.system}.default
];
# Required for EC writes
boot.kernelModules = [ "ec_sys" ];
boot.extraModprobeConfig = "options ec_sys write_support=1";
})
];
};
};
}go build -o msi-gpu-switcher . msi-gpu-switcher [command]
Available Commands:
completion Generate the autocompletion script for the specified shell
dgpu Switch to dGPU (discrete)
help Help about any command
igpu Switch to iGPU (hybrid)
status Show current GPU/MUX/UEFI status
Flags:
--debug enable debug logging
-h, --help help for msi-gpu-switcherA reboot is required after switching.
UEFI variable is immutable:
chattr -i /sys/firmware/efi/efivars/MsiDCVarData-DD96BAAF-145E-4F56-B1CF-193256298E99The tool attempts this automatically via FS_IOC_SETFLAGS; run manually if it fails.
EC writes fail — reload ec_sys with write support:
modprobe -r ec_sys && modprobe ec_sys write_support=1ec0 not found — mount debugfs:
mount -t debugfs none /sys/kernel/debugLow-level details
Switches the primary GPU output by:
- Writing the UEFI variable
MsiDCVarData(GUIDDD96BAAF-145E-4F56-B1CF-193256298E99) - Triggering the EC switch (
0xD1) - Toggling the EC MUX bit (
0x2E, mask0x40)
- Written with the help of AI.