LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 07-04-2013, 11:06 AM   #1
edwin11
Member
 
Registered: Dec 2005
Distribution: Linux Mint 13 MATE
Posts: 120

Rep: Reputation: 15
Question Question on Zenity (or Any Better Option)


Hi all,

I have a cron job running a backup script, and at the end of the job, I want it to shutdown my machine unless I tell it not to.

I achieve this by using Zenity at the end of the script:

Code:
/usr/bin/zenity --question --title="Backup Complete" --timeout=60 --text="Backup Complete; Proceed to Shutdown?" --ok-label="Yes" --cancel-label="No";
if [ "$?" -eq "5" ]; then
	/sbin/shutdown -h now;
fi
The problem is this: Sometimes I'm using the machine when the job runs. The Zenity prompt appears, and I happen to just press enter (as I was typing something in another window), and the machine shuts itself down immediately. This is because the "Yes" option is the default one.

I could, of course, rephrase the question to something like "Keep Running?" and swap the yes and no options such that the default "Yes" option will not trigger a shutdown. The problem is upon timeout (which means I'm not at the machine, and hence I want it to shutdown), $? will return the same value as the default option, and hence the machine will not shutdown.

Another possibility is for the prompt not to be in focus when it appears (so that any keypress will not apply to it), but there's no such option.

Any suggestion for a better solution to this?



Thanks and Regards,
Edwin
 
Old 07-05-2013, 04:37 AM   #2
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301
I recommend Xdialog instead, as it does have a '--default-no' option.
 
  


Reply

Tags
zenity



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Zenity: This option is not available. Please see --help for all possible usages rahulkmnair Linux - Newbie 4 10-03-2012 01:32 AM
Option -o question Quest ion Programming 2 11-17-2011 09:30 PM
Zenity If else statement question? linux_newb Linux - General 4 09-01-2009 08:28 AM
How to generate option selection box using zenity........? shivarajM Linux - Software 1 04-29-2009 07:07 AM
just a question with an option in ppp chankunchan Linux - Networking 1 03-23-2004 01:55 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 08:03 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration