1

I have a hot corner set up that runs other commands to turn off my laptop's display and lock my screen. However, I often accidentally mouse into this hot corner. Is there any way of me setting up a popup box that gives the user a yes or no option before executing the commands to turn the display off? I'm looking for functionality almost like that of gksudo.

Rohan
  • 3,561

1 Answers1

2

Try using zenityor a similar dialog-like command:

zenity --yesno 'do you want to suspend?'

It asks the question in a dialog with 'yes' and 'no' buttons. Once you click one of those buttons, it prints the response on standard error (I believe). If you capture that, you can then have a script decide what to do based on the choice made by the user.

zenity has many more options for the dialog box; they're documented in the man page.

  • zenity --yesno is apparently an unavailable option. But I looked in man page and tried --question, and it did the trick. Just quick question, how do I use the input zenity gives in an if statement in bash? – Rohan Apr 09 '16 at 19:39
  • The exit state: zenity --question && echo "ok, will continue" || echo "okay, won't continue then" – Wouter Verhelst Apr 12 '16 at 07:18
  • for an if statement, that's if zenity --question; then. The test command (aka [) is, after all, also just a command whose exit state you pass to the if command. Shell is weird ;-) – Wouter Verhelst Apr 12 '16 at 07:20