Add Tailscale panel connection controls

This commit is contained in:
David Heinemeier Hansson
2026-05-26 22:07:20 +02:00
parent 48a741e3ee
commit 67dd7a2953
16 changed files with 1568 additions and 784 deletions
+82
View File
@@ -0,0 +1,82 @@
#!/bin/bash
# omarchy:summary=Mutate the user shell.json bar layout
# omarchy:args=<append|prepend> <left|center|right> <plugin>
# omarchy:examples=omarchy config shell append right omarchy.tailscale
set -euo pipefail
CONFIG_FILE="$HOME/.config/omarchy/shell.json"
OMARCHY_ROOT="${OMARCHY_PATH:-}"
DEFAULTS_FILE="$OMARCHY_ROOT/config/omarchy/shell.json"
usage() {
echo "Usage: omarchy-config-shell <append|prepend> <left|center|right> <plugin>" >&2
}
fail() {
echo "omarchy-config-shell: $*" >&2
exit 1
}
operation="${1:-}"
section="${2:-}"
plugin="${3:-}"
if (( $# != 3 )); then
usage
exit 1
fi
[[ $operation == "append" || $operation == "prepend" ]] || fail "operation must be append or prepend"
[[ $section =~ ^(left|center|right)$ ]] || fail "section must be left, center, or right"
[[ -n $plugin ]] || fail "plugin is required"
[[ -n $OMARCHY_ROOT ]] || fail "OMARCHY_PATH is not set"
mkdir -p "$(dirname "$CONFIG_FILE")"
source_file="$CONFIG_FILE"
if [[ ! -s $source_file ]]; then
source_file="$DEFAULTS_FILE"
fi
[[ -s $source_file ]] || fail "could not find shell config or defaults"
tmp=$(mktemp)
trap 'rm -f "$tmp"' EXIT
jq --arg operation "$operation" --arg section "$section" --arg plugin "$plugin" '
def object_or_empty: if type == "object" then . else {} end;
def array_or_empty: if type == "array" then . else [] end;
def entry_id: if type == "object" then (.id // "" | tostring) else tostring end;
def append_anchor($section):
{
left: "omarchy.workspaces",
center: "omarchy.weather",
right: "omarchy.tray"
}[$section];
def insert_after_anchor($entries; $entry; $anchor):
($entries | map(entry_id) | index($anchor)) as $index
| if $index == null then
$entries + [$entry]
else
$entries[0:$index + 1] + [$entry] + $entries[$index + 1:]
end;
object_or_empty
| .version = 1
| .bar = (.bar | object_or_empty)
| .bar.layout = (.bar.layout | object_or_empty)
| .bar.layout.left = (.bar.layout.left | array_or_empty | map(select(entry_id != $plugin)))
| .bar.layout.center = (.bar.layout.center | array_or_empty | map(select(entry_id != $plugin)))
| .bar.layout.right = (.bar.layout.right | array_or_empty | map(select(entry_id != $plugin)))
| .plugins = (.plugins | array_or_empty)
| if $operation == "prepend" then
.bar.layout[$section] = ([{ id: $plugin }] + .bar.layout[$section])
else
.bar.layout[$section] = insert_after_anchor(.bar.layout[$section]; { id: $plugin }; append_anchor($section))
end
' "$source_file" >"$tmp"
mv "$tmp" "$CONFIG_FILE"
trap - EXIT
omarchy-shell -q shell rescanPlugins >/dev/null 2>&1 || true
+3
View File
@@ -13,4 +13,7 @@ sudo tailscale up --accept-routes
echo -e "\nAllowing $USER to manage Tailscale..."
sudo tailscale set --operator="$USER"
echo -e "\nAdding Tailscale to the bar..."
omarchy-config-shell append right omarchy.tailscale
omarchy-webapp-install "Tailscale" "https://login.tailscale.com/admin/machines" https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/png/tailscale-light.png