Shell script to run command and show output in notification box

I have command line utility that generates text strings, by running a command within the directory:

./Utility -P

it prints output on terminal. How to make a shell script showing the generated string in the Info dialog box, where the output can be selected by mouse and copied. So I need send information from a shell script to a GUI desktop environment.
I mean launch a shell scipt by double click on it, so there is no longer needs to open terminal every time and write command.

EDIT: working example

output="$( ./Utility -P )"
zenity --info  --text "${output}" --icon-name=info --title "Daily test" --width=300 --height=80
Asked By: minto


This will capture standard output from this sub shell and save it to an environment variable named output. You can call it any other name.

output="$( ./Utility -P )"
zenity --info --text "${output}" --title "Utility finished"

There are alternative tools such as yad (a fork of zenity iirc), or even a way to use your desktop’s notification utility (using dbus) if you have one. Assuming you have xfce4-notification-daemon or some other daemon consuming that notification stuff:

notify-send --icon /opt/icons/Utility.png -- "Utility finished" "${output}"

Where the first string will go to the "title" of the notification, and the second string will be the "body" of the notification.

EDIT: or even just xmessage "${output}" if you like minimal dependencies, though that assumes ${output} doesn’t match one of the options supported by xmessage. Alternatively: ./Utility -P | xmessage -file - which doesn’t have the problem.

Answered By: bgStack15