diff --git a/bin/omarchy-hyprland-flag-missing b/bin/omarchy-hyprland-flag-missing new file mode 100755 index 00000000..e99c6a66 --- /dev/null +++ b/bin/omarchy-hyprland-flag-missing @@ -0,0 +1,5 @@ +#!/bin/bash + +# Check if a Hyprland flag is currently disabled (missing). + +[[ ! -f "$HOME/.local/state/omarchy/flags/hypr/$1.conf" ]] diff --git a/bin/omarchy-hyprland-flag-present b/bin/omarchy-hyprland-flag-present new file mode 100755 index 00000000..ea66c717 --- /dev/null +++ b/bin/omarchy-hyprland-flag-present @@ -0,0 +1,5 @@ +#!/bin/bash + +# Check if a Hyprland flag is currently enabled. + +[[ -f "$HOME/.local/state/omarchy/flags/hypr/$1.conf" ]] diff --git a/bin/omarchy-hyprland-flag-toggle b/bin/omarchy-hyprland-flag-toggle new file mode 100755 index 00000000..6900bdf7 --- /dev/null +++ b/bin/omarchy-hyprland-flag-toggle @@ -0,0 +1,31 @@ +#!/bin/bash + +# Toggle permanent Hyprland flags by copying them into a directory that's sourced entirely. + +ENABLED_NOTIFICATION="" +DISABLED_NOTIFICATION="" + +while [[ $# -gt 1 ]]; do + case $1 in + --enabled-notification) ENABLED_NOTIFICATION="$2"; shift 2 ;; + --disabled-notification) DISABLED_NOTIFICATION="$2"; shift 2 ;; + *) break ;; + esac +done + +FLAG_NAME="$1" +flag="$HOME/.local/state/omarchy/flags/hypr/$FLAG_NAME.conf" +flag_source="$OMARCHY_PATH/default/hypr/flags/$FLAG_NAME.conf" + +if [[ -f $flag ]]; then + rm $flag + [[ -n $DISABLED_NOTIFICATION ]] && notify-send -u low "$DISABLED_NOTIFICATION" +elif [[ -f $flag_source ]]; then + cp $flag_source $flag + [[ -n $ENABLED_NOTIFICATION ]] && notify-send -u low "$ENABLED_NOTIFICATION" +else + echo "Flag not found" + exit 1 +fi + +hyprctl reload diff --git a/bin/omarchy-hyprland-monitor-internal-toggle b/bin/omarchy-hyprland-monitor-internal-toggle index 6e06d81b..3296adb4 100755 --- a/bin/omarchy-hyprland-monitor-internal-toggle +++ b/bin/omarchy-hyprland-monitor-internal-toggle @@ -1,29 +1,16 @@ #!/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. +# Toggle the internal laptop display on/off using the flag system. -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" - hyprctl dispatch movecursor 0 0 - notify-send -u low "󰍹 Internal display on" -else +if omarchy-hyprland-flag-missing internal-monitor-disable; then ACTIVE_COUNT=$(hyprctl monitors -j | jq 'length') if [[ $ACTIVE_COUNT -le 1 ]]; then notify-send -u low "󰍹 Can't disable the only active display" exit 1 fi - - hyprctl keyword monitor "$INTERNAL,disable" - notify-send -u low "󰍹 Internal display off" fi + +omarchy-hyprland-flag-toggle \ + --enabled-notification "󰍹 Internal display off" \ + --disabled-notification "󰍹 Internal display on" \ + internal-monitor-disable diff --git a/bin/omarchy-hyprland-window-single-square-aspect-toggle b/bin/omarchy-hyprland-window-single-square-aspect-toggle index 50ccdac9..b933643b 100755 --- a/bin/omarchy-hyprland-window-single-square-aspect-toggle +++ b/bin/omarchy-hyprland-window-single-square-aspect-toggle @@ -1,13 +1,8 @@ #!/bin/bash -# Check current single_window_aspect_ratio setting -CURRENT_VALUE=$(hyprctl getoption "layout:single_window_aspect_ratio" 2>/dev/null | head -1) +# Toggle single-window square aspect ratio using the flag system. -# Parse vec2 output: "vec2: [1, 1]" or "vec2: [0, 0]" -if [[ $CURRENT_VALUE == *"[1, 1]"* ]]; then - hyprctl keyword layout:single_window_aspect_ratio "0 0" - notify-send -u low " Disable single-window square aspect ratio" -else - hyprctl keyword layout:single_window_aspect_ratio "1 1" - notify-send -u low " Enable single-window square aspect" -fi +omarchy-hyprland-flag-toggle \ + --enabled-notification " Enable single-window square aspect ratio" \ + --disabled-notification " Disable single-window square aspect ratio" \ + single-window-aspect-ratio diff --git a/config/hypr/hyprland.conf b/config/hypr/hyprland.conf index 6478d1be..6866a136 100644 --- a/config/hypr/hyprland.conf +++ b/config/hypr/hyprland.conf @@ -19,5 +19,8 @@ source = ~/.config/hypr/bindings.conf source = ~/.config/hypr/looknfeel.conf source = ~/.config/hypr/autostart.conf +# Toggle config flags dynamically +source = ~/.local/state/omarchy/flags/hypr/*.conf + # Add any other personal Hyprland configuration below # windowrule = workspace 5, match:class qemu diff --git a/default/hypr/flags/flags.conf b/default/hypr/flags/flags.conf new file mode 100644 index 00000000..a6334225 --- /dev/null +++ b/default/hypr/flags/flags.conf @@ -0,0 +1,2 @@ +# This directory is intended for permanent config toggle flags. +# Do not remove this file (as the directory always needs at least one file). diff --git a/default/hypr/flags/internal-monitor-disable.conf b/default/hypr/flags/internal-monitor-disable.conf new file mode 100644 index 00000000..f5458f94 --- /dev/null +++ b/default/hypr/flags/internal-monitor-disable.conf @@ -0,0 +1,2 @@ +# Disable the internal laptop monitor +monitor=eDP-1,disable diff --git a/default/hypr/flags/single-window-aspect-ratio.conf b/default/hypr/flags/single-window-aspect-ratio.conf new file mode 100644 index 00000000..b51d0e41 --- /dev/null +++ b/default/hypr/flags/single-window-aspect-ratio.conf @@ -0,0 +1,5 @@ +# Avoid overly wide single-window layouts on wide screens +layout { + single_window_aspect_ratio = 1 1 +} + diff --git a/install/config/all.sh b/install/config/all.sh index b09332e6..5ec74701 100644 --- a/install/config/all.sh +++ b/install/config/all.sh @@ -22,6 +22,7 @@ run_logged $OMARCHY_INSTALL/config/unmount-fuse.sh run_logged $OMARCHY_INSTALL/config/sudoless-asdcontrol.sh run_logged $OMARCHY_INSTALL/config/input-group.sh run_logged $OMARCHY_INSTALL/config/omarchy-ai-skill.sh +run_logged $OMARCHY_INSTALL/config/omarchy-config-flags.sh run_logged $OMARCHY_INSTALL/config/kernel-modules-hook.sh run_logged $OMARCHY_INSTALL/config/powerprofilesctl-rules.sh run_logged $OMARCHY_INSTALL/config/wifi-powersave-rules.sh diff --git a/install/config/omarchy-config-flags.sh b/install/config/omarchy-config-flags.sh new file mode 100644 index 00000000..c5a46909 --- /dev/null +++ b/install/config/omarchy-config-flags.sh @@ -0,0 +1,3 @@ +# Flags are used to toggle certain features on/off in a persistent way +mkdir -p ~/.local/state/omarchy/flags/hypr +cp $OMARCHY_PATH/default/hypr/flags/flags.conf ~/.local/state/omarchy/flags/hypr/ diff --git a/migrations/1776410469.sh b/migrations/1776410469.sh new file mode 100644 index 00000000..a0e4d962 --- /dev/null +++ b/migrations/1776410469.sh @@ -0,0 +1,9 @@ +echo "Add flags sourcing to hyprland.conf" + +HYPR_CONF=~/.config/hypr/hyprland.conf + +source $OMARCHY_PATH/install/config/omarchy-config-flags.sh + +if [[ -f $HYPR_CONF ]] && ! grep -q "flags/hypr/\*\.conf" "$HYPR_CONF"; then + echo -e "\n# Toggle config flags dynamically\nsource = ~/.local/state/omarchy/flags/hypr/*.conf" >> "$HYPR_CONF" +fi