Getting a progress bar to work will (I believe) be hard, and will have to be implemented on a case by case basis for different applications (apt-get, dd, etc.).
On the other hand, changing the icon when a prompt is available is easier. Assume that there exist two scripts iconprompt
and iconnoprompt
which change gnome-terminal's icon on execution. [I've added sample iconprompt
and iconnoprompt
in the end]
So, all that remains to be done is to
Execute iconprompt
when a prompt becomes available.
Execute iconnoprompt
when a command starts executing.
These can be accomplished by adding the lines
export PROMPT_COMMAND='iconprompt'
trap 'iconnoprompt' DEBUG
to the .bashrc
file in your homefolder.
The behaviour will not be as desired when you have more than one terminal open - one terminal running apt-get
and another on which you're working. In this case icon changes will not be indicators of process completion. To handle this consider the following alternative solution:
Add
monitor() { iconnoprompt; "$@"; iconprompt; }
to .bashrc
. To do sudo apt-get ...
you'll have to type monitor sudo apt-get ...
. The icon will be different only while the monitored command is running.
I recommend this solution, also because my iconprompt
and iconnoprompt
scripts take about 0.1 second to execute which will create a noticeable lag for commands like ls
and cd
.
(Sample) Content of iconnoprompt
:
#!/usr/bin/python
from gi.repository import Unity, GObject
import threading, time
launcher = Unity.LauncherEntry.get_for_desktop_id ("gnome-terminal.desktop")
launcher.set_property("progress", 0.5)
launcher.set_property("progress_visible", True)
GObject.threads_init()
loop = GObject.MainLoop()
t = threading.Thread()
t.daemon = True
t.run = loop.run
t.start()
time.sleep(0.1)
(Sample) Content of iconprompt
:
#!/usr/bin/python
from gi.repository import Unity, GObject
import threading, time
launcher = Unity.LauncherEntry.get_for_desktop_id ("gnome-terminal.desktop")
launcher.set_property("progress", 0.)
launcher.set_property("progress_visible", False)
GObject.threads_init()
loop = GObject.MainLoop()
t = threading.Thread()
t.daemon = True
t.run = loop.run
t.start()
time.sleep(0.1)
Set executable permissions to iconnoprompt
and iconprompt
and put them in your PATH
. iconnoprompt
will add a progress-bar to the gnome-terminal icon - but the progress value has no correlation with actual progress.