-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun_after_wayland_wrappers.zsh.tmpl
executable file
·68 lines (56 loc) · 2.13 KB
/
run_after_wayland_wrappers.zsh.tmpl
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
#!/usr/bin/env zsh
{{ if .headless }}
# We're headless.
exit 0
{{ end }}
set -o errexit -o nounset
source $HOME/.config/.variables
wrappers_directory="$HOME/.bin/wrappers"
wayland_args="--enable-features=UseOzonePlatform --ozone-platform=wayland"
declare -A WAYLAND_WRAPPERS=(
[code]="code $wayland_args"
[code-fb]="code-fb $wayland_args"
[code-fb-insiders]="code-fb-insiders $wayland_args"
[code-fb-dev]="code-fb-dev $wayland_args"
[discord]="flatpak run --socket=wayland com.discordapp.Discord $wayland_args || discord $wayland_args || Discord $wayland_args"
[mattermost-desktop]="mattermost-desktop $wayland_args || /usr/lib/mattermost/mattermost-desktop $wayland_args"
[obsidian]="obsidian $wayland_args || flatpak run --socket=wayland md.obsidian.Obsidian $wayland_args"
# [tuba]="tuba || flatpak run --socket=wayland dev.geopjr.Tuba $wayland_args"
# Doesn't support copying.
# [1password]="1password $wayland_args"
[signal-desktop]="flatpak run --socket=wayland org.signal.Signal $wayland_args || signal-desktop $wayland_args"
[spotify]="spotify $wayland_args || flatpak run --socket=wayland com.spotify.Client $wayland_args"
[zulip]="zulip $wayland_args || flatpak run --socket=wayland org.zulip.Zulip $wayland_args"
[google-chrome]="google-chrome $wayland_args"
[google-chrome-stable]="google-chrome-stable $wayland_args"
)
set -A WRAPPERS ${(kv)WAYLAND_WRAPPERS}
if [[ $(uname -s) == "Darwin" ]]; then
rm -rf $wrappers_directory
exit 0
fi
mkdir -p $wrappers_directory
for file in "$wrappers_directory"/*; do
if [[ ! -v WAYLAND_WRAPPERS[$(basename "$file")] ]]; then
echo "Deleting old wrapper: $file"
rm "$file"
fi
done
for key value in ${(kv)WRAPPERS}; do
CONTENTS="#!/usr/bin/env zsh
FILE_PATH="\${0:a}"
PARENT_DIR="\${FILE_PATH:h}"
export PATH=\${PATH//\$PARENT_DIR:/:}
if [[ \$(which $key) == "\$FILE_PATH" ]]; then
notify-send \"Tried recursively running $key wrapper, exiting...\" --urgency=critical
exit 1
fi
$value \$@
"
to="$wrappers_directory/$key"
cmp --silent <(echo $CONTENTS) $to || (
echo "$key wrapper changed, copying to $to..."
echo $CONTENTS > $to
chmod +x $to
)
done