Add way to toggle on/off internal display on laptops

This commit is contained in:
David Heinemeier Hansson
2026-04-09 09:53:12 +02:00
parent 6171d0ee8f
commit 8ad61cadcb
2 changed files with 24 additions and 1 deletions
+22
View File
@@ -0,0 +1,22 @@
#!/bin/bash
# Toggle the internal laptop display on/off.
# Useful when connected to an external monitor and you want to close the lid
# or just use the external display only.
INTERNAL=$(hyprctl monitors all -j | jq -r '.[] | select(.name | startswith("eDP")) | .name')
if [[ -z $INTERNAL ]]; then
notify-send -u low "󰍹 No internal display found"
exit 1
fi
DISABLED=$(hyprctl monitors all -j | jq -r --arg m "$INTERNAL" '.[] | select(.name == $m) | .disabled')
if [[ $DISABLED == "true" ]]; then
hyprctl keyword monitor "$INTERNAL,preferred,auto,auto"
notify-send -u low "󰍹 Internal display on"
else
hyprctl keyword monitor "$INTERNAL,disable"
notify-send -u low "󰍹 Internal display off"
fi
+2 -1
View File
@@ -168,7 +168,7 @@ show_share_menu() {
}
show_toggle_menu() {
case $(menu "Toggle" "󱄄 Screensaver\n󰔎 Nightlight\n󱫖 Idle Lock\n󰍜 Top Bar\n󱂬 Workspace Layout\n Window Gaps\n 1-Window Ratio\n󰍹 Display Scaling") in
case $(menu "Toggle" "󱄄 Screensaver\n󰔎 Nightlight\n󱫖 Idle Lock\n󰍜 Top Bar\n󱂬 Workspace Layout\n Window Gaps\n 1-Window Ratio\n󰍹 Monitor Scaling\n󰶐 Laptop Display") in
*Screensaver*) omarchy-toggle-screensaver ;;
*Nightlight*) omarchy-toggle-nightlight ;;
@@ -178,6 +178,7 @@ show_toggle_menu() {
*Ratio*) omarchy-hyprland-window-single-square-aspect-toggle ;;
*Gaps*) omarchy-hyprland-window-gaps-toggle ;;
*Scaling*) omarchy-hyprland-monitor-scaling-cycle ;;
*Laptop*) omarchy-hyprland-monitor-internal-toggle ;;
*) back_to show_trigger_menu ;;
esac
}