3

Previously, in KDE, this was simple -- I called KDialog with number of steps, I got DCOP handle in return, then I called dcop with that reference and step, and progress dialog got updated.

However, now DCOP is obsolete, and since I moved from KDE 3.5.10 to XFCE, I thought it would be a good idea that instead converting my script from KDialog+DCOP to KDialog+DBUS I migrate to XFCE progress dialog.

So how do you build progress dialog for Bash purposes in XFCE? Bash purpose = I perform some computation in Bash, but the progress is shown in GUI way, as nice dialog on the desktop.

greenoldman
  • 6,176

1 Answers1

3

You can use dialog utility. It can works both inside and outside a terminal.

To get it on the X server, you may use its xdialog or gdialog/zenity variant. Take note that zenity is recommendend for XFCE, since its use GTK+. In fact, I think Kdialog is a KDE variant of Xdialog.

Here is a simple Zenity script, running on X server with a yes/no box :

DIALOG=zenity
$DIALOG --title " My first dialog" --clear \
--yesno "Hi, this is my first dialog" 10 30

Here's a simple tutorial with various example about the different dialog available. And there's also a nice tutorial about zenity.

About your graphical progress dialog, there's one dedicated for this purpose. Here's the sample script of the documentation :

#!/bin/sh
(
echo "10" ; sleep 1
echo "# Updating mail logs" ; sleep 1
echo "20" ; sleep 1
echo "# Resetting cron jobs" ; sleep 1
echo "50" ; sleep 1
echo "This line will just be ignored" ; sleep 1
echo "75" ; sleep 1
echo "# Rebooting system" ; sleep 1
echo "100" ; sleep 1
) |
zenity --progress \
  --title="Update System Logs" \
  --text="Scanning mail logs..." \
  --percentage=0

if [ "$?" = -1 ] ; then
        zenity --error \
          --text="Update canceled."
fi
manatwork
  • 31,277
Coren
  • 5,010
  • If anyone is wondering how to mimic KDialog further and use zenity as monitor in the background here is how I did it -- http://unix.stackexchange.com/questions/38807/how-to-pass-data-outside-process-for-zenity-progress/38846#38846 – greenoldman May 17 '12 at 10:43