-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathkakaotalk
executable file
·33 lines (27 loc) · 1.14 KB
/
kakaotalk
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
#!/usr/bin/env bash
# shellcheck disable=SC2128
###############################################################################
# Makeshift KakaoTalk client for Linux. Launches KakaoTalk on an ADB-enabled #
# Android device connected via USB and displays the application screen using #
# scrcpy. Also has rudamentary support for forwarding notifications. #
###############################################################################
set -o errexit -o nounset -o pipefail
shopt -s nullglob
name=com.kakao.talk
interval=10 # in seconds
icon=(/usr/share/icons/*/32x32/*/KakaoTalk.svg)
function forward_notifications(){
local tstamp notif="${name//./\\.}\\|[[:digit:]]+ -> -[[:alnum:]]+ ago$"
while read -r; do
if [[ $REPLY =~ $notif ]]; then
tstamp=$(sed 's/h/*360+/;s/m/*60+/;s/s.*//' <<< "${REPLY##*-> -}")
if (( ${tstamp%+} <= interval )); then
notify-send --icon="$icon" "Received KakaoTalk message!"
fi
fi
done < <(adb shell "while sleep $interval; do dumpsys notification; done")
}
adb shell monkey -p "$name" 1
forward_notifications&
trap "kill 0" EXIT
scrcpy --keyboard=uhid --stay-awake --turn-screen-off