Смотрите здесь [1123429], что означают записи в файлах [1123685].desktop[1123686][1123430].[1122941].
Я не понимаю, как это может сработать. Когда вы запустите
eval $term_cmd
, вы откроете окно терминала, и скрипт больше ничего не будет делать, пока вы его не закроете. Что вам нужно:
$term_cmd &
Запустите его в фоновом режиме (и не используйте eval
, он не нужен). Тогда вам также не нужно выбирать последнюю строку вывода wmctrl
., Вы устанавливаете заголовок терминала, поэтому установите его на что-то уникальное и grep
что:
#!/bin/bash
# This script starts a specified terminal-binary in "Always on Top"-mode
# The assumption is, that 'wmctrl -l' sorts windows with the
# in such a way, that the more recently a window has been created,
# the lower it will be on the list ( compared to windows with the
# same title).
#
# This is my assumption based on a short observation. The window
# ids are probably given out in ascending hex numbers
#
# Note: Using the pid will not help, since all terminals seem to
# be having the same pid
term_title_def='Terminal'
term_title="Terminal_top_$$" ## Use the script's PID for a unique title
term_cmd="mate-terminal --title=$term_title"
## Start terminal. No need to wait, the loop will run until
## the terminal has been opened
$term_cmd &
win_id=''
while [[ -z "$win_id" ]]; do
## No need for '[[:blank:]]' and \$, you are using a unique title,
## keep the regex general.
win_id=$(wmctrl -l | grep "$term_title" | awk '{ print $1 }')
done
# DEBUG
touch /tmp/$win_id
# rename, set as "Always on top"
wmctrl -ir $win_id -T "$term_title_def"
wmctrl -ir $win_id -b add,above
wmctrl -ia $win_id
В то время как цикл выполняется в подоболочке, поэтому любые изменения, сделанные в переменной в подоболочке, не сообщаются в оболочке отца : https://stackoverflow.com/questions/16854280/modifying-variable-inside-while-loop-is-not-remembered
Для второго вопроса на моей стороне у меня есть :
$ while true; do toto=plop; echo $toto; [[ $toto ]] && break ; done
plop
Так что я думаю, что у вас есть реальная проблема с определением $win_id
внутри цикла.