jeudi 8 janvier 2015

terminal warn on close when opened within a script


First, the question: How can I warn the user that a script is running when the user clicks the close button and the terminal itself (and the process running in it) was started from the command line.


I have a script that performs actions that the user will want to reverse before the script terminates. There is a read statement that pauses the process until the user hits [enter]. But, a hapless user will occasionally click the close button [x] in the top right-hand corner. I have not found a trap that catches the close button, but a warning will do. The gnome-terminal provides the needed warning.


But, when the gnome-terminal is launched from a script (say a Thunar custom action) the feature does not work. To clarify, consider the script:



gnome-terminal --command="sh readx.sh"


Where readx.sh contains a single line: read x


On clicking the top right [x] button, a terminal launched this way closes without warning while the script is still active.


Any method for trapping or warning will work for me.



Aucun commentaire:

Enregistrer un commentaire