forked from paperwm/PaperWM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·84 lines (76 loc) · 2.47 KB
/
install.sh
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
81
82
83
84
#!/usr/bin/env bash
REPO="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
UUID=paperwm@hedning:matrix.org
EXT_DIR=${XDG_DATA_HOME:-$HOME/.local/share}/gnome-shell/extensions
mkdir -p "$EXT_DIR"
ln -sn "$REPO" "$EXT_DIR"/"$UUID"
cat <<EOF
PaperWM runs best with some Gnome Shell settings changed:
workspaces-only-on-primary off: Required for working multi-monitor support
edge-tiling off: Natively tiled windows doesn't work in PaperWM
attach-modal-dialogs off: Attached modal dialogs can cause visual glitching
EOF
echo
read -p "Use recommended settings (generates a backup) [Y/n]: " consent
case "$consent" in
(Y|y|"")
$REPO/set-recommended-gnome-shell-settings.sh
;;
esac
echo
read -p "Enable the extension [Y/n]? " consent
case "$consent" in
(Y|y|"")
;;
*)
exit
;;
esac
# Coax gnome-shell to enable the extension, since gnome-extensions enable does't
# work without a restart
ENABLE=`cat <<EOF
try {
let path = "$EXT_DIR";
let uuid = "$UUID";
let Gio = imports.gi.Gio;
let extensionUtils, extensionSystem, paperwm;
// Work around differences between 3.32 and 3.34
if (imports.misc.extensionUtils.createExtensionObject) {
extensionSystem = imports.ui.extensionSystem;
extensionUtils = imports.misc.extensionUtils;
paperwm = extensionUtils[uuid];
} else {
extensionSystem = imports.ui.main.extensionManager;
extensionUtils = extensionSystem;
paperwm = extensionSystem.lookup(uuid);
}
if (paperwm)
throw new Error("paperwm-loaded");
let dir = Gio.File.new_for_path(path + "/" + uuid);
let extension = extensionUtils.createExtensionObject(uuid, dir, 2);
extensionSystem.loadExtension(extension);
extensionSystem.enableExtension(uuid);
true
} catch (e) {
if (e.message === "paperwm-loaded")
true
else
e.message + " " + e.stack;
};
EOF
`
echo "Trying to load and enable extension:"
RET=`gdbus call --session -d org.gnome.Shell -o /org/gnome/Shell -m org.gnome.Shell.Eval "$ENABLE"`
if [[ "(true, 'true')" == "$RET" ]]; then
# Enable with gnome-extensions tool since `extensionSystem.enableExtension`
# doesn't write to dconf in version < 3.34
if type gnome-extensions &> /dev/null; then
gnome-extensions enable "$UUID"
else
gnome-shell-extension-tool --enable="$UUID"
fi
else
echo something went wrong:
echo $RET | sed -e "s/(true, '\"//" | sed -e "s/\\\\n/\n/g"
echo Success
fi