-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgsconnect-cache-clear.service
More file actions
52 lines (48 loc) · 1.58 KB
/
gsconnect-cache-clear.service
File metadata and controls
52 lines (48 loc) · 1.58 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
[Unit]
Description=Clear GSConnect device cache
After=graphical-session.target
PartOf=graphical-session.target
[Service]
Type=oneshot
ExecStart=/bin/bash -l -c '\
# Check if GSConnect extension is active\
if ! gdbus introspect --session \
--dest org.gnome.Shell.Extensions.GSConnect \
--object-path /org/gnome/Shell/Extensions/GSConnect \
>/dev/null 2>&1; then \
echo "GSConnect not active, skipping"; \
exit 0; \
fi; \
\
# Try to call function (may already be loaded by login shell)\
if declare -F gnome.ext.gsconnect.dev.cache.clear >/dev/null 2>&1; then \
gnome.ext.gsconnect.dev.cache.clear; \
exit 0; \
fi; \
\
# Fallback: source common locations\
shopt -s nullglob; \
for f in /etc/bashrc.d/*/bash_utils/gnome_utils.sh \
/etc/profile.d/*/bash_utils/gnome_utils.sh \
~/.config/bash/*/bash_utils/gnome_utils.sh \
~/.profile.d/*/bash_utils/gnome_utils.sh \
~/.bashrc.d/*/bash_utils/gnome_utils.sh \
~/.bash_functions; do \
[[ -f "$f" ]] && source "$f"; \
done; \
\
# Try again after sourcing\
if declare -F gnome.ext.gsconnect.dev.cache.clear >/dev/null 2>&1; then \
gnome.ext.gsconnect.dev.cache.clear; \
else \
echo "ERROR: Function not found in any known location"; \
exit 0; \
fi'
[Install]
WantedBy=graphical-session.target
# sudo mkdir -p /etc/systemd/user
# sudo cp gsconnect-cache-clear.service /etc/systemd/user/
# systemctl --user enable gsconnect-cache-clear.service
# # Create preset file
# sudo mkdir -p /etc/systemd/user-preset
# echo "enable gsconnect-cache-clear.service" | sudo tee /etc/systemd/user-preset/90-gsconnect.preset