Compare commits

...

14 Commits

Author SHA1 Message Date
David Heinemeier Hansson
79dc4c4b52 Reminder to add to OPR 2026-01-19 17:09:55 -04:00
David Heinemeier Hansson
3678b27170 Prevent race condition 2026-01-19 14:16:21 -04:00
David Heinemeier Hansson
08fead671e Merge branch 'dev' into toggle-hybrid-gpu 2026-01-19 14:07:36 -04:00
David Heinemeier Hansson
df65a4aaef Relying on the new config should be enough since we are restarting anyway 2026-01-17 15:00:20 -05:00
David Heinemeier Hansson
b218655301 No need for extensions
Matches existing style
2026-01-17 14:57:55 -05:00
David Heinemeier Hansson
5fac51272c Make it exe 2026-01-17 14:56:34 -05:00
David Heinemeier Hansson
4921d68ee1 These are sudo actions 2026-01-17 14:53:54 -05:00
David Heinemeier Hansson
7e18659cd6 Spacing 2026-01-17 14:53:00 -05:00
David Heinemeier Hansson
989229d515 Merge branch 'dev' into toggle-hybrid-gpu 2026-01-17 14:50:32 -05:00
David Heinemeier Hansson
64f7880b08 Revise switching process 2026-01-17 14:30:08 -05:00
David Heinemeier Hansson
8e21a5341f Wording 2026-01-15 18:02:55 -05:00
David Heinemeier Hansson
e73f56b1b1 Simplify 2026-01-15 18:01:15 -05:00
David Heinemeier Hansson
16edd8982b Use correct exit 2026-01-15 17:59:26 -05:00
David Heinemeier Hansson
06d06c0c3d Toggle hybrid GPU mode via supergfxctl
Very useful for Asus G14 and other laptops with NVIDIA + AMD iGPU
combos.
2026-01-15 17:56:08 -05:00
4 changed files with 88 additions and 1 deletions

View File

@@ -88,10 +88,11 @@ show_learn_menu() {
} }
show_trigger_menu() { show_trigger_menu() {
case $(menu "Trigger" " Capture\n Share\n󰔎 Toggle") in case $(menu "Trigger" " Capture\n Share\n󰔎 Toggle\n Tweaks") in
*Capture*) show_capture_menu ;; *Capture*) show_capture_menu ;;
*Share*) show_share_menu ;; *Share*) show_share_menu ;;
*Toggle*) show_toggle_menu ;; *Toggle*) show_toggle_menu ;;
*Tweaks*) show_tweaks_menu ;;
*) show_main_menu ;; *) show_main_menu ;;
esac esac
} }
@@ -143,6 +144,13 @@ show_toggle_menu() {
esac esac
} }
show_tweaks_menu() {
case $(menu "Tweaks" " Toggle Hybrid GPU") in
*"Toggle Hybrid GPU"*) present_terminal omarchy-toggle-hybrid-gpu ;;
*) show_trigger_menu ;;
esac
}
show_style_menu() { show_style_menu() {
case $(menu "Style" "󰸌 Theme\n Font\n Background\n Hyprland\n󱄄 Screensaver\n About") in case $(menu "Style" "󰸌 Theme\n Font\n Background\n Hyprland\n󱄄 Screensaver\n About") in
*Theme*) show_theme_menu ;; *Theme*) show_theme_menu ;;

55
bin/omarchy-toggle-hybrid-gpu Executable file
View File

@@ -0,0 +1,55 @@
#!/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
# FIXME: Convert this to OPR instead of AUR
omarchy-pkg-aur-add supergfxctl
sudo systemctl enable supergfxd
sudo 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
# Remove the startup delay override (not needed for Hybrid mode)
sudo rm -rf /etc/systemd/system/supergfxd.service.d/delay-start.conf
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 -p $OMARCHY_PATH/default/systemd/system-sleep/force-igpu /usr/lib/systemd/system-sleep/
# Delay supergfxd startup to avoid race condition with display manager
# that can cause system freeze when booting in Integrated mode
sudo mkdir -p /etc/systemd/system/supergfxd.service.d
sudo cp -p $OMARCHY_PATH/default/systemd/system/supergfxd.service.d/delay-start.conf /etc/systemd/system/supergfxd.service.d/
omarchy-cmd-reboot
fi
;;
*)
echo "Hybrid GPU not found or in unknown mode."
exit 1
;;
esac

View File

@@ -0,0 +1,18 @@
#!/bin/bash
# Use the Vfio to Integrated trick to turn off NVIDIA dgpu when in integrated mode
# without needing to restart the computer. This is needed because computers like the Asus G14
# will wake after suspend in Hybrid mode, even if the system was in Integrated mode before
# suspending.
if [[ $1 == "post" ]]; then
# small delay so the device is fully re-enumerated
sleep 4
# force-bind dGPU to vfio (fully detached from nvidia)
/usr/bin/supergfxctl -m Vfio
sleep 1
# then go back to Integrated, which powers it off again
/usr/bin/supergfxctl -m Integrated
fi

View File

@@ -0,0 +1,6 @@
[Service]
# Delay startup to avoid race condition with display manager initialization
# when booting in Integrated mode. Without this delay, the system can freeze
# on boot because supergfxd tries to disable the dGPU while the display
# subsystem is still initializing.
ExecStartPre=/bin/sleep 5