measuring jack themes technologies tooltips linux measuring jack themes technologies tooltip linux limejack claim limejack limejack

Start | Language  de en fr | Menu | Map | Search

You are here: start » en » tooltips » bash


Nice ideas for a nice programm.

selection on output

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
while [ -z "${menuclick}" -a  -z "${menuenter}" ]
  menuclick=`xclip -o 2>/dev/null` #select a line
  read -t 1 menuenter  #enter a menu number

#line selected
if [ -n "${menuclick}" ]
  echo "${menuclick}" | cut -f2- -d':' | xclip -r -i -selection clipboard
  echo "${menuclick}" | cut -f2- -d':' | xclip -r -i -selection primary

#key pressed
if [ -n "${menuenter}" ]
  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 ;;

mouse position on click

Use Escape-Sequences:

  • 1000 : start/stop X11 mouse
  • 1001 : highlight reports
  • 1002 : button movement reports
  • 1003 : all movement reports
  • 1005 : utf-8 report
  • 1006 : decimal values report (term dependent)
  • 1015 : decimal values report (term dependent)
#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 down

The 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

Disclaimer | Impressum | Privacy | Copyleft