Prompt for Timed Shutdown dialog box

Source: Internet
Author: User
Tags gtk

[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 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.