Fork the desktop off Omarchy as a self-contained system
This commit is contained in:
Executable
+73
@@ -0,0 +1,73 @@
|
||||
#!/bin/bash
|
||||
|
||||
# blob:summary=Enable, disable, toggle, or recover mirroring the internal display to an external monitor
|
||||
# blob:args=<on|off|toggle|recover>
|
||||
|
||||
TOGGLE="internal-monitor-mirror"
|
||||
TOGGLE_FLAG="$HOME/.local/state/blob/toggles/hypr/$TOGGLE.lua"
|
||||
DISABLE_TOGGLE="internal-monitor-disable"
|
||||
|
||||
INTERNAL=$(blob-hypr-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
|
||||
blob-notify-send -g "No external monitors found for mirror"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ -z $INTERNAL ]]; then
|
||||
blob-notify-send -g "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
|
||||
blob-notify-send -g "Refusing unsafe monitor name"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
blob-hypr-toggle $DISABLE_TOGGLE off
|
||||
|
||||
if blob-hypr-toggle-disabled $TOGGLE; then
|
||||
printf 'hl.monitor({ output = "%s", mode = "preferred", position = "auto", scale = 1, mirror = "%s" })\n' "$EXTERNAL" "$INTERNAL" >"$TOGGLE_FLAG"
|
||||
blob-notify-send -g "Mirroring enabled ($EXTERNAL)"
|
||||
hyprctl reload
|
||||
fi
|
||||
}
|
||||
|
||||
off() {
|
||||
if blob-hypr-toggle-enabled $TOGGLE; then
|
||||
blob-hypr-toggle $TOGGLE off
|
||||
blob-notify-send -g "Extended mode restored"
|
||||
fi
|
||||
}
|
||||
|
||||
toggle() {
|
||||
if blob-hypr-toggle-enabled $TOGGLE; then
|
||||
off
|
||||
else
|
||||
on
|
||||
fi
|
||||
}
|
||||
|
||||
recover() {
|
||||
if ! blob-hypr-monitor-external && blob-hypr-toggle-enabled $TOGGLE; then
|
||||
blob-hypr-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
|
||||
Reference in New Issue
Block a user