The installer asks for the language before the keyboard, and Setup > Language (omarchy language en|zh) switches it later. Under zh_CN the menu reads its labels from omarchy-menu.zh-cn.jsonc, the shell from I18nZh.js through I18n.tr, and notifications are worded by their sender through omarchy-text, which reads the same table. User text is never translated.
74 lines
2.1 KiB
Bash
Executable File
74 lines
2.1 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# omarchy:summary=Enable, disable, toggle, or recover mirroring the internal display to an external monitor
|
|
# omarchy:args=<on|off|toggle|recover>
|
|
|
|
TOGGLE="internal-monitor-mirror"
|
|
TOGGLE_FLAG="$HOME/.local/state/omarchy/toggles/hypr/$TOGGLE.lua"
|
|
DISABLE_TOGGLE="internal-monitor-disable"
|
|
|
|
INTERNAL=$(omarchy-hyprland-monitor-laptop)
|
|
# The first active external monitor
|
|
EXTERNAL=$(hyprctl monitors -j | jq -r '.[] | select(.name | test("^(eDP|LVDS|DSI)-") | not).name' | head -n 1)
|
|
|
|
on() {
|
|
if [[ -z $EXTERNAL ]]; then
|
|
omarchy-notification-send -g "$(omarchy-text "No external monitors found for mirror")"
|
|
exit 1
|
|
fi
|
|
|
|
if [[ -z $INTERNAL ]]; then
|
|
omarchy-notification-send -g "$(omarchy-text "No laptop monitor found to mirror")"
|
|
exit 1
|
|
fi
|
|
|
|
# Both names are written into generated Lua below, so only plain connector
|
|
# names may pass; a user-created headless output can carry any name.
|
|
for output in "$INTERNAL" "$EXTERNAL"; do
|
|
if [[ ! $output =~ ^[A-Za-z0-9._-]+$ ]]; then
|
|
omarchy-notification-send -g "$(omarchy-text "Refusing unsafe monitor name")"
|
|
exit 1
|
|
fi
|
|
done
|
|
|
|
omarchy-hyprland-toggle $DISABLE_TOGGLE off
|
|
|
|
if omarchy-hyprland-toggle-disabled $TOGGLE; then
|
|
printf 'hl.monitor({ output = "%s", mode = "preferred", position = "auto", scale = 1, mirror = "%s" })\n' "$EXTERNAL" "$INTERNAL" >"$TOGGLE_FLAG"
|
|
omarchy-notification-send -g "$(omarchy-text "Mirroring enabled (%1)" "$EXTERNAL")"
|
|
hyprctl reload
|
|
fi
|
|
}
|
|
|
|
off() {
|
|
if omarchy-hyprland-toggle-enabled $TOGGLE; then
|
|
omarchy-hyprland-toggle $TOGGLE off
|
|
omarchy-notification-send -g "$(omarchy-text "Extended mode restored")"
|
|
fi
|
|
}
|
|
|
|
toggle() {
|
|
if omarchy-hyprland-toggle-enabled $TOGGLE; then
|
|
off
|
|
else
|
|
on
|
|
fi
|
|
}
|
|
|
|
recover() {
|
|
if ! omarchy-hyprland-monitor-external-active && omarchy-hyprland-toggle-enabled $TOGGLE; then
|
|
omarchy-hyprland-toggle $TOGGLE off
|
|
fi
|
|
}
|
|
|
|
case "$1" in
|
|
on) on ;;
|
|
off) off ;;
|
|
toggle) toggle ;;
|
|
recover) recover ;;
|
|
*)
|
|
echo "Usage: $(basename "$0") {on|off|toggle|recover}" >&2
|
|
exit 1
|
|
;;
|
|
esac
|