Last active
May 12, 2018 19:07
-
-
Save Misko-2083/382223f7a25adb1b4ee89cbe10560963 to your computer and use it in GitHub Desktop.
bash script to remove highlight from yad form date filed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# check if xdotool is installed | |
if ! hash xdotool; then | |
echo "Install xdotool!" | |
exit 1 | |
fi | |
TEMPFILE="$(mktemp /tmp/yadformX.XXXXXX)" | |
# Trap that removes temporary file on exit | |
trap "rm -f $TEMPFILE" EXIT | |
# Class is necesary here | |
printf "%s\n" "12/05/18" "4:40" | yad --class "lilyad" --form --field="Date:DT" --field="Date" --cycle-read >>$TEMPFILE & YADFPID=$! | |
# Sleep untill main window opens, that is until window name appears | |
until xdotool getwindowname "$(xdotool search --any --class "lilyad" 2>/dev/null | tail -1 2>/dev/null)" &>/dev/null; do | |
# sleep until the window opens | |
sleep .1 | |
done | |
# Decimal window id | |
WindowID="$(xdotool search --any --class "lilyad" 2>/dev/null | tail -1)" | |
# Base seven | |
WindowIDbSeven=$(printf "0x%07x" ${WindowID}) | |
xprop -root -spy _NET_ACTIVE_WINDOW | # <- this is the watcher process | |
while IFS=$'#' read -a WIN; do | |
WIN="${WIN[1]%%","*}" | |
WIN="$(printf "%s\n" ${WIN})" # bypass weird array bug | |
if [[ "${WIN}" == "${WindowIDbSeven}" ]]; then | |
xdotool key --clearmodifiers "$WindowIDbSeven" ctrl+Right # send ctrl+Right to de-highlight | |
fi | |
WIN=() | |
done & WATCH_PID=$! | |
wait $YADFPID | |
YADEXITST=$? # yad form return status | |
kill $WATCH_PID | |
echo "Results:" | |
cat $TEMPFILE | |
echo "yad form exit status: $YADEXITST" | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment