Мне нужна помощь в создании сценария, который делает следующее:
Я задавался вопросом, как я могу заставить его произойти с Gedit и xdotool, поскольку xdotool может моделировать сочетание клавиш для сохранения документа Ctrl+S
Окно должно быть сфокусировано, потому что иначе gedit проигнорирует X событий, отправленных xdotool.
Вот, каков Ваш сценарий должен быть:
#!/bin/bash gedit -s /path/to/document # -s is standalone, meaning a new window will be opened instead of a tab in any existing gedit sleep 5 # wait for gedit to open, adjust if necessary GEDPID=$! # save PID of gedit process sleep 2 # wait for gedit to actually open document, adjust if necessary GEDWINID=`xdotool search --pid $GEDPID | tail -1` # gets window ID of gedit, the third "child" is the actual window xdotool windowactivate --sync $GEDWINID key --clearmodifiers --delay 100 ctrl+s ctrl+s alt+F4 # focus gedit window, wait until focused, then save twice and exit