summaryrefslogtreecommitdiff
path: root/scripts/install-extension
blob: fd861dc5334e74744c3b2a4a8de9c754e03a26f1 (plain)
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
#!/usr/bin/env bash
set -euo pipefail

root=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)
uuid=parley@org.parley
destination=${XDG_DATA_HOME:-$HOME/.local/share}/gnome-shell/extensions/$uuid

mkdir -p "$(dirname -- "$destination")"
if [[ -L "$destination" ]]; then
    unlink "$destination"
elif [[ -e "$destination" ]]; then
    rm -rf -- "$destination"
fi
ln -s "$root/extension" "$destination"

cd "$root"
python - "$uuid" <<'PY'
import sys
from gi.repository import Gio

uuid = sys.argv[1]
settings = Gio.Settings.new("org.gnome.shell")
enabled = list(settings.get_strv("enabled-extensions"))
if uuid not in enabled:
    enabled.append(uuid)
    if not settings.set_strv("enabled-extensions", enabled):
        raise SystemExit("could not update GNOME's enabled extension list")
PY

if gnome-extensions info "$uuid" >/dev/null 2>&1; then
    gnome-extensions enable "$uuid"
    echo "Installed and enabled $uuid from $root/extension"
else
    echo "Installed and marked $uuid for enablement."
    echo "Log out and back in once so GNOME Shell discovers the new extension."
fi