/ de-omarchy / bin / omarchy-plugin-manager
swadhinbiswas Plugin marketplace: omarchyplugins.com catalog, Plugin Manager/Library windows, registry.json with bundled plugins · 8/24/2026
12362d0
80 lines · 2.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/bin/bash

# omarchy:summary=Open or toggle the graphical Plugin Manager window
# omarchy:group=plugin
# omarchy:alias=omarchy plugin manager

LOCKDIR="/tmp/omarchy-plugin-manager.lock"
if ! mkdir "$LOCKDIR" 2>/dev/null; then
  lock_age=$(( $(date +%s) - $(stat -c %Y "$LOCKDIR" 2>/dev/null || echo 0) ))
  if (( lock_age > 3 )); then
    rm -rf "$LOCKDIR"
    mkdir "$LOCKDIR" 2>/dev/null || exit 0
  else
    exit 0
  fi
fi
trap 'rm -rf "$LOCKDIR"' EXIT

# The installed runtime is authoritative — never reference the dev checkout
# here; an installed desktop must not depend on (or prefer) a home git clone.
PATH_CANDIDATES=(
  "${OMARCHY_PATH:-/usr/share/de-omarchy}/plugin-library"
  "/usr/share/de-omarchy/plugin-library"
)

APP_PATH=""
for p in "${PATH_CANDIDATES[@]}"; do
  if [[ -f "$p/shell.qml" ]]; then
    APP_PATH="$p"
    break
  fi
done

if [[ -z $APP_PATH ]]; then
  echo "Plugin manager QML path not found!" >&2
  exit 1
fi

# Check if the Plugin Manager window already exists in Hyprland
existing_window=$(hyprctl clients -j 2>/dev/null | jq -r '.[] | select((.title | test("^(Omarchy Plugin Manager|Plugin Library)$")) or (.class == "org.quickshell" and (.title | test("Plugin")))) | .address' | head -n 1)
active_window=$(hyprctl activewindow -j 2>/dev/null | jq -r '.address // empty')
current_ws=$(hyprctl activeworkspace -j 2>/dev/null | jq -r '.id // "1"')

if [[ -n "$existing_window" ]]; then
  if [[ "$existing_window" == "$active_window" ]]; then
    # Toggle off if currently focused
    hyprctl dispatch "hl.dsp.window.close({ window = \"address:$existing_window\" })" >/dev/null 2>&1 || true
    pkill -f "quickshell.*plugin-library" 2>/dev/null || true
  else
    # Move to current workspace if needed, focus and raise
    hyprctl dispatch "hl.dsp.window.move({ workspace = \"$current_ws\", window = \"address:$existing_window\" })" >/dev/null 2>&1 || true
    hyprctl dispatch "hl.dsp.focus({ window = \"address:$existing_window\" })" >/dev/null 2>&1 || true
  fi
  exit 0
fi

# Clean up any stale quickshell plugin-library instances
pkill -f "quickshell.*plugin-library" 2>/dev/null || true
sleep 0.05

# Launch detached
if command -v uwsm-app >/dev/null 2>&1; then
  uwsm-app -- quickshell -p "$APP_PATH" >/dev/null 2>&1 &
else
  setsid quickshell -p "$APP_PATH" >/dev/null 2>&1 &
fi

# Ensure window appears on current workspace and gets focused
(
  for (( i = 0; i < 30; i++ )); do
    win_addr=$(hyprctl clients -j 2>/dev/null | jq -r '.[] | select((.title | test("^(Omarchy Plugin Manager|Plugin Library)$")) or (.class == "org.quickshell" and (.title | test("Plugin")))) | .address' | head -n 1)
    if [[ -n "$win_addr" ]]; then
      hyprctl dispatch "hl.dsp.window.move({ workspace = \"$current_ws\", window = \"address:$win_addr\" })" >/dev/null 2>&1 || true
      hyprctl dispatch "hl.dsp.focus({ window = \"address:$win_addr\" })" >/dev/null 2>&1 || true
      break
    fi
    sleep 0.05
  done
) &