From cf1c0e2e3e880d33ae71ab0fa27904d79f3af6cd Mon Sep 17 00:00:00 2001 From: Prad Nukala Date: Thu, 15 Oct 2026 14:26:14 -0400 Subject: [PATCH] feat(cli): add omarchy-launch-browser and projects-sync scripts, update cycle launcher and monitor handling --- dot_local/bin/executable_omarchy-cycle | 2 +- .../bin/executable_omarchy-launch-browser | 19 ++++++++++ .../bin/executable_omarchy-toggle-scratch | 26 +++++++++----- dot_local/bin/executable_projects-sync | 36 +++++++++++++++++++ 4 files changed, 73 insertions(+), 10 deletions(-) create mode 100755 dot_local/bin/executable_omarchy-launch-browser create mode 100755 dot_local/bin/executable_projects-sync diff --git a/dot_local/bin/executable_omarchy-cycle b/dot_local/bin/executable_omarchy-cycle index 1612e3b..f4047c3 100755 --- a/dot_local/bin/executable_omarchy-cycle +++ b/dot_local/bin/executable_omarchy-cycle @@ -126,7 +126,7 @@ elif [[ $APP == "brave" ]]; then # real browser (class brave-origin) and the SSAs (class brave-) # share the brave- prefix, so one regex catches them all. INSTANCES=($(addresses_matching '^brave')) - DEFAULT_SPAWN="brave-origin" + DEFAULT_LAUNCHER="omarchy-launch-browser" elif [[ $APP == "terminal" ]]; then # Cycle all terminals. Tern (so.stencil.tern) is the SUPER + A scratch diff --git a/dot_local/bin/executable_omarchy-launch-browser b/dot_local/bin/executable_omarchy-launch-browser new file mode 100755 index 0000000..289192b --- /dev/null +++ b/dot_local/bin/executable_omarchy-launch-browser @@ -0,0 +1,19 @@ +#!/bin/bash + +# omarchy:summary=Launch the default browser; a cold Brave Origin start reopens the last session without the "Restore pages?" prompt. +# omarchy:args=[url] + +# Shadows /usr/bin/omarchy-launch-browser (~/.local/bin is earlier on PATH) +# and hands off to it. A reboot or power-off kills Brave uncleanly, so the +# next start counts as post-crash: Chromium then skips session restore and +# shows the "Restore pages?" bubble instead. --hide-crash-restore-bubble +# clears that post-crash state, and --restore-last-session reopens every +# window. Added only on a cold, non-private start: a running browser ignores +# both, and Omarchy's launcher would read the first flag as the URL to focus. +if [[ " $* " != *" --private "* ]] && + [[ $(env -u BROWSER xdg-settings get default-web-browser) == brave-origin.desktop ]] && + ! pgrep -f '^/opt/brave-origin-bin/brave( |$)' >/dev/null; then + set -- --restore-last-session --hide-crash-restore-bubble "$@" +fi + +exec /usr/bin/omarchy-launch-browser "$@" diff --git a/dot_local/bin/executable_omarchy-toggle-scratch b/dot_local/bin/executable_omarchy-toggle-scratch index 30d85a9..46e6745 100755 --- a/dot_local/bin/executable_omarchy-toggle-scratch +++ b/dot_local/bin/executable_omarchy-toggle-scratch @@ -15,28 +15,33 @@ set -uo pipefail # web apps) from piling up duplicates. The scrolling layout gives each # resident its own column, in the order they appear. # -# HOME_MONITOR is a connector name or an EDID description (the latter, as in -# the workspace rules, survives a different DP connector after re-docking). -# When it is empty or that monitor is absent, the workspace opens on the -# focused one. +# HOME_MONITOR lists connector names or EDID descriptions, separated by |; +# the first one connected wins (descriptions, as in the workspace rules, +# survive a different DP connector after re-docking). When it is empty or +# none is connected, the workspace opens on the focused monitor. EXTERNAL is +# the main external display: the Studio Display, else the Samsung ultrawide +# (same order as hypr/monitors.lua). +EXTERNAL="Apple Computer Inc StudioDisplay 0x984262A7|Samsung Electric Company S34CG50 HNTY501103" HOME_MONITOR="" case ${1:-scratchpad} in scratchpad) NAME="scratchpad" - HOME_MONITOR="Apple Computer Inc StudioDisplay 0x984262A7" + HOME_MONITOR=$EXTERNAL MEMBERS=("so.stencil.tern|tern") ;; claude) NAME="claude" - HOME_MONITOR="Apple Computer Inc StudioDisplay 0x984262A7" + HOME_MONITOR=$EXTERNAL MEMBERS=("com.anthropic.Claude|claude-desktop") ;; fastmail) NAME="fastmail" + HOME_MONITOR="eDP-1" MEMBERS=("com.fastmail.Fastmail|gtk-launch com.fastmail.Fastmail") ;; beeper) NAME="beeper" + HOME_MONITOR="eDP-1" MEMBERS=("Beeper|gtk-launch beeper") ;; home) @@ -87,10 +92,13 @@ toggle_on() { hyprctl dispatch togglespecialworkspace "$NAME" >/dev/null } -# The profile's home monitor when connected, else whatever is focused. +# The first connected home monitor, else whatever is focused. target_monitor() { - hyprctl monitors -j | jq -r --arg m "$HOME_MONITOR" \ - 'first(.[] | select(.name == $m or .description == $m)) // first(.[] | select(.focused)) | .name' + hyprctl monitors -j | jq -r --arg m "$HOME_MONITOR" ' + . as $monitors + | first(($m | split("|"))[] as $want | $monitors[] | select(.name == $want or .description == $want)) + // first($monitors[] | select(.focused)) + | .name' } # Showing: just hide, even if a member is gone. Missing members come back on diff --git a/dot_local/bin/executable_projects-sync b/dot_local/bin/executable_projects-sync new file mode 100755 index 0000000..4b77a9e --- /dev/null +++ b/dot_local/bin/executable_projects-sync @@ -0,0 +1,36 @@ +#!/bin/bash +# Mirror every repo under the ghq root (~/Code///) as a +# symlink ~/Projects/. Repos sharing a name across owners get +# -. Links into ~/Code whose repo is gone are removed; anything +# in ~/Projects that is not such a link is never touched. Run by +# projects-sync.timer (systemd user). +set -euo pipefail + +code=${GHQ_ROOT:-$HOME/Code} +projects=$HOME/Projects +mkdir -p "$projects" + +mapfile -t repos < <(find "$code" -mindepth 4 -maxdepth 4 -name .git -printf '%h\n' 2>/dev/null | sort) + +declare -A count keep +for repo in "${repos[@]}"; do + name=${repo##*/} + count[$name]=$((${count[$name]:-0} + 1)) +done + +for repo in "${repos[@]}"; do + name=${repo##*/} + if ((count[$name] > 1)); then + owner=${repo%/*} + name=${owner##*/}-$name + fi + link=$projects/$name + keep[$name]=1 + [[ -e $link && ! -L $link ]] && continue + [[ $(readlink "$link") == "$repo" ]] || ln -sfn "$repo" "$link" +done + +for link in "$projects"/*; do + [[ -L $link && $(readlink "$link") == "$code"/* && -z ${keep[${link##*/}]:-} ]] && rm "$link" +done +exit 0