forked from web1n/wechat-universal-flatpak
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wechat.sh
64 lines (53 loc) · 1.68 KB
/
wechat.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
#!/bin/bash
get_wechat_notifier_item() {
local notifier_items=$(
gdbus call --session \
--dest org.freedesktop.DBus --object-path /org/freedesktop/DBus \
--method org.freedesktop.DBus.ListNames |
grep -oE 'org.kde.StatusNotifierItem-[0-9]{1,}-[0-9]'
)
local notifier_item
for notifier_item in $notifier_items; do
local notifier_id=$(
gdbus call --session \
--dest="${notifier_item/\// \/}" --object-path /StatusNotifierItem \
--method org.freedesktop.DBus.Properties.Get org.kde.StatusNotifierItem Id
)
if [[ $notifier_id =~ "wechat" ]]; then
echo "${notifier_item/\// \/}"
fi
done
}
try_open_wechat_window() {
local notifier_item=$(get_wechat_notifier_item)
if [ -n "$notifier_item" ]; then
gdbus call --session \
--dest="$notifier_item" --object-path /StatusNotifierItem \
--method org.kde.StatusNotifierItem.Activate 0 0 >/dev/null
fi
}
try_exit_wechat() {
local notifier_item=$(get_wechat_notifier_item)
if [ -n "$notifier_item" ]; then
gdbus call --session \
--dest="$notifier_item" --object-path /MenuBar \
--method com.canonical.dbusmenu.Event 1 clicked '<"">' 0 >/dev/null
fi
}
setup_ime_env() {
if [[ "$XMODIFIERS" =~ fcitx ]]; then
[ -z "$QT_IM_MODULE" ] && export QT_IM_MODULE=fcitx
[ -z "$GTK_IM_MODULE" ] && export GTK_IM_MODULE=fcitx
elif [[ "$XMODIFIERS" =~ ibus ]]; then
[ -z "$QT_IM_MODULE" ] && export QT_IM_MODULE=ibus
[ -z "$GTK_IM_MODULE" ] && export GTK_IM_MODULE=ibus
fi
}
if [ "$1" == "--exit-wechat" ]; then
try_exit_wechat
exit
fi
try_open_wechat_window
setup_ime_env
export LD_PRELOAD=/app/lib/libredirect.so
exec /app/wechat/wechat "$@"