Nice ideas for a nice programm.
This approach is using the X11 clipboard, it's LimeJACK proofed.
This code make the shell clickable via mouse. E.g. the items start stop help print
can be selected and will be interpreted by the shell script.
#delete clipboard echo | xclip -i #menu output echo '1:Line A' echo '2:Line B' echo '3:Line C' #wait for action via mouse or key menuclick='';menuenter=''; while [ -z "${menuclick}" -a -z "${menuenter}" ] do menuclick=`xclip -o 2>/dev/null` #select a line read -t 1 menuenter #enter a menu number done #line selected if [ -n "${menuclick}" ] then echo "${menuclick}" | cut -f2- -d':' | xclip -r -i -selection clipboard echo "${menuclick}" | cut -f2- -d':' | xclip -r -i -selection primary fi #key pressed if [ -n "${menuenter}" ] then case "${menuenter}" do a|A|1) echo 'Line A' | xclip -r -i -selection clipboard ; echo 'Line A' | xclip -r -i -selection primary ;; b|B|2) echo 'Line B' | xclip -r -i -selection clipboard ; echo 'Line B' | xclip -r -i -selection primary ;; c|C|3) echo 'Line C' | xclip -r -i -selection clipboard ; echo 'Line C' | xclip -r -i -selection primary ;; esac fi
Use Escape-Sequences:
#Activate mouse reporting via (h) echo -e "\e[?1000;1006;1015h" read -p "Type any keys" keys echo "${keys}" #Disable mouse reporting via (l) echo -e "\e[?1000;1006;1015l"
The output is:
^[[<0;11;21M
: press button 1 on x=11 and y=21 (columns and lines)^[[<0;11;21m
: release button 1 on x=11 and y=21 (columns and lines)^[[<1;7;22M
: press button 1 on x=7 and y=22 (columns and lines)^[[<1;7;22m
: release button 1 on x=7 and y=22 (columns and lines)^[[<2;20;19M
: press button 3 on x=20 and y=19 (columns and lines)^[[<2;20;19m
: release button 3 on x=20 and y=19 (columns and lines)^[[<64;31;19M
: mouse wheel up^[[<65;31;19M
: mouse wheel downThe use of bind as bash builtin should trap a specific mouse actions by executing code. But it is not very practical: bind must be declareted on terminal outside your shell script and it dosn't match by our experiments. Nice tipp