Today i make a script to automatically read what is underlined after pressing a shortcut
The script is this:
tce-load -i espeak xclip &>/dev/null
clip=`xclip -o`
lang="it"
if [[ $1 = en ]]; then
lang="en"
fi
if [[ `echo "$clip" | cut -c 1-8` = "file:///" ]]
then #if browser link
if [[ `echo "$clip" | tail -c 6` = ".html" ]] || [[ `echo "$clip" | tail -c 5` = ".htm" ]]
then #if is webpage
echo -e "\nweb page\n"
espeak -v "$lang" -s 150 -a 200 -g 5 --punct="." -k10 -m -f `echo "$clip" | sed -e "s/^file:\/\///g"` &>/dev/null
else #if isn't webpage
echo -e "\ntext file\n"
espeak -v "$lang" -s 150 -a 200 -g 5 --punct="." -k10 -f `echo "$clip" | sed -e "s/^file:\/\///g"` &>/dev/null
fi
elif [[ `echo "$clip" | cut -c 1-7` = "http://" ]] || [[ `echo "$clip" | cut -c 1-4` = "www." ]]
then #if is link
echo -e "\nhyperlink\n"
curl -s "$clip" | espeak -v "$lang" -s 150 -a 200 -g 5 --punct="." -k10 -m
else #if isn't browser link
if [ -f "$clip" ]
then #if is file
echo -e "\ntext file\n"
espeak -v "$lang" -s 150 -a 200 -g 5 --punct="." -k10 -f "$clip" &>/dev/null
else #if is not file
echo -e "\nread direct\n"
espeak -v "$lang" -s 150 -a 200 -g 5 --punct="." -k10 "$clip" &>/dev/null
fi
fi
return 0
I used the keybindings of enlightenment to start the script after highlighting the text; win+s to read the text in Italian and win+d to read it in English
However, I would use actkbd to make the shortcut more universal, but I was not able to do so.
In order i have:
1) downloaded actkbd
2) used xev to find the keycode of the keys win, s and d (in my case 115, 39 and 40)
3) insert this configuration in /usr/local/etc/actkbd.conf file:
#win+s
115+39:key:exec:~/.local/bin/_read_script
115+40:key:exec:~/.local/bin/_read_script en
4)start the daemon with sudo actkbd -d /dev/input/event1 -D
5)try the shortcut that however does yet not work
What little I knew of actkbd I read in
this topic, someone could give me a hand?