dotfiles/scripts/telegram-reply.sh

34 lines
683 B
Bash

#!/usr/bin/env sh
get_window_id () {
ids="$(dash $TSCRIPTS/get-xprop-from-pid.sh $telegram_id)"
ids="$(echo "$ids" | awk '{print $3}')"
correct_id=""
echo "$ids" |
while read line
do
correct="$(xprop -id "$line" | grep "WM_STATE(WM_STATE):")"
[ -n "$correct" ] && echo "$line"
done
}
telegram-desktop
telegram_id="$(pgrep Telegram)"
window_id="$(get_window_id "$telegram_id")"
i=0
while [ "$i" -lt 200 ]
do
correct="$(xprop -id "$window_id" | grep "window state: Normal")"
[ -n "$correct" ] && break || i="$(( $i + 1))"
done
if [ "$i" -lt 200 ]; then
xdotool key alt+7 && xdotool key Return
fi