forked from QubesOS/qubes-desktop-linux-i3-settings-qubes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
qubes-i3-xdg-autostart
30 lines (26 loc) · 970 Bytes
/
qubes-i3-xdg-autostart
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
#!/bin/bash
xdg_autostart() {
local config=$1
shopt -s nullglob
if [[ -d "$config/autostart" ]]; then
local i
for i in $config/autostart/*.desktop; do
grep -q -E "^Hidden=true" "$i" && continue
if grep -q -E "^OnlyShowIn=" "$i"; then
# need to test twice, as lack of the line entirely means we still run it
grep -E "^OnlyShowIn=" "$i" | grep -q 'I3;' || continue
fi
grep -E "^NotShowIn=" "$i" | grep -q 'I3;' && continue
local trycmd=$(grep -E "^TryExec=" "$i" | cut -d'=' -f2)
if [[ -n "$trycmd" ]]; then
which "$trycmd" >/dev/null 2>&1 || continue
fi
local cmd=$(grep -E "^Exec=" "$i" | cut -d'=' -f2)
if [[ -n "$cmd" ]]; then
$cmd &
fi
done
fi
}
xdg_autostart "${XDG_CONFIG_DIRS-/etc/xdg}"
xdg_autostart "${XDG_CONFIG_HOME-$HOME/.config}"