Views:
3,220β
Votes: 1β
β
Solution
Tags:
command-line
bash
scripts
notification
zenity
Link:
π See Original Answer on Ask Ubuntu β§ π
URL:
https://askubuntu.com/q/1211685
Title:
Cancel buttons Zenity
ID:
/2020/02/20/Cancel-buttons-Zenity
Created:
February 20, 2020
Upload:
September 15, 2024
Layout: post
TOC:
false
Navigation: false
Copy to clipboard: false
Assuming that return value is 1
for βcancelβ and 0
for βokβ you will want to use:
#!/bin/sh
#InputBox1Test
title=$(zenity --entry --text 'Type what you want your Notification Title to Say!' --title 'Notification')
[[ "$?" != "0" ]] && exit 1
text=$(zenity --entry --text 'Type what you want your Notification body to Say!' --title 'Notification')
[[ "$?" != "0" ]] && exit 1
DISPLAY=:0.0 notify-send "$title" "$text"
You can make a longer traditional check like this:
if [[ "$?" != "0" ]] ; then
exit 1
fi
however I like the shortcut of:
[[ "$?" != "0" ]] && exit 1
No matter which method you choose the importance is consistency with your programming style so those that follow in your footsteps and maintain your code can think inside your head.