#!/bin/bash # Toggle dedicated vs integrated GPU mode via supergfxd (for hybrid gpu laptops, like Asus G14). # Requires reboot to take effect. # Ensure supergfxctl has been installed if omarchy-cmd-missing supergfxctl; then omarchy-pkg-aur-add supergfxctl systemctl enable supergfxd systemctl start supergfxd # Needed to deal with restoring to sleep where going through VFIO first means we don't need to reboot. sudo sed -i "s/\"vfio_enable\": \".*\"/\"vfio_enable\": true/" /etc/supergfxd.conf fi gpu_mode=$(supergfxctl -g) case "$gpu_mode" in "Integrated") if gum confirm "Enable dedicated GPU and reboot?"; then # Switch to hybrid mode sudo sed -i "s/\"mode\": \".*\"/\"mode\": \"Hybrid\"/" /etc/supergfxd.conf # Let hybrid mode be the default after system sleep sudo rm -rf /usr/lib/systemd/system-sleep/force-igpu.sh echo "Enabling dedicated GPU..." supergfxctl -m Hybrid omarchy-cmd-reboot fi ;; "Hybrid") if gum confirm "Use only integrated GPU and reboot?"; then # Switch to integrated mode sudo sed -i "s/\"mode\": \".*\"/\"mode\": \"Integrated\"/" /etc/supergfxd.conf # Force igpu mode after system sleep (or dgpu could get activated) sudo mkdir -p /usr/lib/systemd/system-sleep sudo cp $OMARCHY_PATH/default/systemd/system-sleep/force-igpu.sh /usr/lib/systemd/system-sleep/ echo "Disabling dedicated GPU..." supergfxctl -m Vfio supergfxctl -m Integrated fi ;; *) echo "Hybrid GPU not found or in unknown mode." exit 1 ;; esac