Telegram reply now works super well

This commit is contained in:
inigoortega 2020-01-11 16:22:56 +01:00
parent 7cc38d0b50
commit fc6a1b2259
1 changed files with 16 additions and 15 deletions

View File

@ -1,38 +1,39 @@
#!/usr/bin/env sh
get_window_id () {
ids="$(dash $TSCRIPTS/get-xprop-from-pid.sh $telegram_id)"
ids=$(dash "$TSCRIPTS/get-xprop-from-pid.sh" "$telegram_id")
ids="$(echo "$ids" | awk '{print $3}')"
correct_id=""
ids=$(echo "$ids" | awk '{print $3}')
echo "$ids" |
while read line
do
correct1="$(xprop -id "$line" | grep "WM_STATE(WM_STATE):")"
correct2="$(xprop -id "$line" | \
grep "WM_NAME(STRING) = \"Telegram\"")"
[ -n "$correct1" -a -n "$correct2" ] && echo "$line"
correct1=$(xprop -id "$line" | grep 'WM_STATE(WM_STATE):')
correct2=$(xprop -id "$line" | grep 'WM_NAME(STRING) = "Telegram')
[ -n "$correct1" ] && [ -n "$correct2" ] &&
[ ${#line} -gt 2 ] && echo "$line" && break
done
}
}
telegram-desktop
telegram_id="$(pgrep Telegram)"
telegram_id=$(pgrep Telegram)
window_id="$(get_window_id "$telegram_id")"
iterations=1000
iterations=10000
i=0
while [ "$i" -lt $iterations ]
do
correct="$(xprop -id "$window_id" | grep "window state: Normal")"
window_id=$(get_window_id "$telegram_id")
[ -n "$correct" ] && break || i="$(( $i + 1))"
if [ -n "$window_id" ]; then
correct=$(xprop -id "$window_id" | grep "window state: Normal")
fi
[ -n "$correct" ] && break || i=$(( $i + 1 ))
done
if [ "$i" -lt $iterations ]; then
sleep 0.5
sleep 0.6
xdotool key alt+7 && xdotool key Return
fi