[Keywords]: shutdown, zenity, gnome-session-save, GTK-logout-helper
==>
Recently, self-control is a little poor. When you accidentally watch things in front of the computer every night for more than, it is necessary to remind you after the sleep time. Previously, it was very violent to set the time in cron to shutdown. The most important thing is that after shutdown, the disk will be checked for half a day each time it is restarted. In short, I want to bring up the shutdown dialog box after the time, just like clicking Shutdown On The GNOME panel. So I found the relevant call.Program, Mainly as follows:
# ! /Bin/bash Zenity -- Question -- Title = " Exit options " -- Text = " What do you want to do \? " -- Cancel-label =" Shutdown " -- OK-label = " Log out " If [$? = 0 ]; Then gnome -Session-save -- logout- Dialogelif [ $? = 1 ]; Then gnome -Session-save -- shutdown- Dialogfiexit 0
For more information, see the help documentation. After the script is written, set it in cron.
# M h Dom mon Dow USER command 17 * *** Root CD/& run-parts -- Report/etc/ Cron. Hourly 25 6 * ** Root test-x/usr/sbin/anacron | (CD/& run-parts -- Report/etc/ Cron. daily) 47 6 ** 7 Root Test-x/usr/sbin/anacron | (CD/& run-parts -- Report/etc/ Cron. Weekly) 52 6 1 ** Root test-x/usr/sbin/anacron | (CD/& run-parts -- Report/etc/ Cron. Monthly )# */ 10 * *** Usrname display =: 0 /Home/usrname/public/policy. Sh */ 30 * *** Usrname display =: 0 /Home/usrname/public/Timer. Sh 30 23 * ** Usrname display =: 0 /Home/usrname/public/shutdown.Sh # The shutdown dialog box is displayed at every night. #
In addition, there is a program to complete the same function. However, it is simpler:
# ! /Bin/bash Sel = $ (Zenity -- list -- Title = " Exit options " -- Text = " Make your selection " -- Column = " Log out " " Reboot " " Shutdown " ) If [ " $ Sel " = " Log out " ]; Then /Usr/lib/indicator-session/GTK-logout-helper- Lelif [ " $ Sel " = " Reboot " ]; Then /Usr/lib/indicator-session/GTK-logout-helper- Relif [ " $ Sel " = " Shutdown " ]; Then /Usr/lib/indicator-session/GTK-logout-helper- Sfiexit