diff --git a/dot_local/bin/executable_brave-new-tab b/dot_local/bin/executable_brave-new-tab new file mode 100755 index 0000000..8bed772 --- /dev/null +++ b/dot_local/bin/executable_brave-new-tab @@ -0,0 +1,24 @@ +#!/bin/sh +# brave-new-tab URL +# Open URL in a new tab of the running Brave Origin (its last active window), +# or start Brave Origin with it. Detached, so the caller never blocks. +# Without a scheme, localhost, *.localhost, *.local, and 127.x get http://; +# anything else gets https://. +set -eu + +[ $# -eq 1 ] || { echo "usage: brave-new-tab URL" >&2; exit 2; } + +url=$1 +case $url in +*://* | about:*) ;; +*) + host=${url%%[/?#]*} + host=$(printf '%s' "${host%:*}" | tr '[:upper:]' '[:lower:]') + case $host in + localhost | *.localhost | *.local | 127.*) url="http://$url" ;; + *) url="https://$url" ;; + esac + ;; +esac + +exec setsid -f brave-origin --new-tab "$url" >/dev/null 2>&1 diff --git a/dot_local/bin/executable_umbriel-float-square b/dot_local/bin/executable_umbriel-float-square new file mode 100755 index 0000000..59c1137 --- /dev/null +++ b/dot_local/bin/executable_umbriel-float-square @@ -0,0 +1,40 @@ +#!/bin/sh +# umbriel-float-square +# Floating focused window: square, as tall as the usable height (below +# Noctalia's bar) minus PAD px above and below, centered on its output. +# Tiled: center its column (the old Mod+C). Extents are fractions of the +# usable area, so both sides are computed from the output's usable size. +set -eu + +PAD=4 + +window=$(umbriel windows --json | jq -c '[.[] | select(.active)][0] // empty') +[ -n "$window" ] || exit 0 + +if [ "$(printf '%s' "$window" | jq -r .floating)" != true ]; then + exec umbriel msg column-center +fi + +id=$(printf '%s' "$window" | jq -r .id) +output=$(printf '%s' "$window" | jq -r .output) +extents=$(umbriel outputs --json | jq -r --arg o "$output" --argjson pad "$PAD" ' + def frac: . * 10000 | floor / 10000; + .[] | select(.name == $o) | .usable_area + | (.height - 2 * $pad) as $side + | "\($side) \([$side / .width, 1] | min | frac) \($side / .height | frac)"') +set -- $extents +side=$1 + +umbriel msg "window-set-secondary-extent:$3" +umbriel msg "window-set-primary-extent:$2" + +# window-center uses the size the client has committed; centering before the +# resize lands centers the old width. Wait up to 1 s for the new width. +i=0 +while [ $i -lt 20 ]; do + w=$(umbriel windows --json | jq -r --arg id "$id" '.[] | select(.id == $id) | .w') + [ $((w - side)) -ge -1 ] && [ $((w - side)) -le 1 ] && break + sleep 0.05 + i=$((i + 1)) +done +exec umbriel msg window-center diff --git a/dot_local/bin/executable_umbriel-launch b/dot_local/bin/executable_umbriel-launch index b719afa..eead14d 100755 --- a/dot_local/bin/executable_umbriel-launch +++ b/dot_local/bin/executable_umbriel-launch @@ -11,11 +11,12 @@ pattern=$1 shift # Matches in a stable order (window id); the one after the focused match, or -# the first when focus is elsewhere. +# the first when focus is elsewhere. `.active` is the one window with keyboard +# focus; `.focused` is set on every output's last-focused window. target=$(umbriel windows --json | jq -r --arg p "$pattern" ' [.[] | select(.scratchpad == "" and (.app_id | test($p; "i")))] | sort_by(.id) | if length == 0 then empty - else (map(.focused) | index(true)) as $i + else (map(.active) | index(true)) as $i | if $i == null then .[0].id else .[($i + 1) % length].id end end')