how to handle unwanted exiting of в command and its output in bash рукописный шрифт

I made в one liner рукописный шрифт to автомобиль hide в specific window when мышь is not hover over that window. It gets мышь position and geometry of the window and its position (topleftx, toplefty), I added its geometry to the window's starting position to get (bottomrightx, bottomrighty) coordinates, then it сравни if мышь is over the window. If мышь is not on the window, it hides the window.

It works but only одиннадцать, because xprop window info command that I использовал to extract window info in the рукописный шрифт fails if it doesn't find the window ямс in the window stack. It outputs an ошибка message and --help message then exits.

I need xprop because it's the only window info command that gives info about decoration id of any window. Because mainstream window info tools in Linux only prints geometry and position of в window without its decoration. I wanted to include the window decoration for completeness.

How хан I trick it into working?

  while [ 1 ]
  do 
         string=$(xdotool getmouselocation 2>/dev/null | sed 's/x:\([0-9]\+\)[ \t]y:\([0-9]\+\)[ \t].*/\1;\2/' | tr ';' ',') 
         string2=$(xdotool getwindowgeometry $(xprop -name "kenn" | grep _COMPIZ_WINDOW_DECOR_INPUT_FRAME |  grep -Po ' # \K.*') | grep -Po ': \K.*' |cut -d" " -f1 | tr '\n' ',' | tr 'x' ','| sed 's/-[0-9][0-9]*/0/') 
         A="$string2$string" 
         IFS=, 
         set $A 
  if [[(($5 -lt $(($1+$3))))  && (($5 -gt $1))]] && [[(($6 -lt $(($2+$4))))  && (( $6 -gt $2 ))]]
         then echo "mouse is on the window"
  else 
         then echo "mouse is out of the window"
  fi 
  done
1
задан 25 December 2015 в 23:26

1 ответ

Можно попробовать

(xprop -name "kenn" 2>/dev/null || echo "") |...

, перенаправление stderr избавляется от ошибки и части после того, как || умирает, если xprop разбомбил.

1
ответ дан 7 December 2019 в 16:04

Другие вопросы по тегам:

Похожие вопросы: