Lavoro con uno script di shell, funziona perfettamente. Ma quando la funzione onLogout è attiva, non riesco a ottenere alcuna finestra di dialogo con l'OS. È possibile interrompere o uscire dalla funzione e quando un utente ha fatto clic su OK, la funzione continua?
#!/bin/bash
onLogout() {
# that works:
if [ "$USER" != "admin" ] && [ "$USER" != "Administrator" ]; then
rm -Rf ~/Downloads/*
rm -Rf ~/Movies/*
rm -Rf ~/Music/*
rm -Rf ~/Pictures/*
rm -Rf ~/Public/*
rm -Rf ~/Desktop/*
fi
# it doesn't work:
res=$(osascript -e 'tell app "System Events" to display dialog "Please save yout Data!" buttons {"Cancel", "OK"} default button 1 with icon caution with title "Important Information!"' 2>/dev/null)
if [[ $res == *OK* ]]; then
# continue logout?
else
# break logout?
fi
exit
}
trap 'onLogout' SIGINT SIGHUP SIGTERM
while true; do
sleep 86400 &
wait $!
done