What do you mean by "good too"? It's what you tried to achieve with your example. Reading the contents is not what you asked for.smokey01 wrote:Ah this one is good too as it checks to see if a file exists rather than reading the contents of the file.
GtkDialog - tips
- MochiMoppel
- Posts: 2084
- Joined: Wed 26 Jan 2011, 09:06
- Location: Japan
You are quite correct and thanks.MochiMoppel wrote:What do you mean by "good too"? It's what you tried to achieve with your example. Reading the contents is not what you asked for.smokey01 wrote:Ah this one is good too as it checks to see if a file exists rather than reading the contents of the file.
I'm trying to automate the process a little more. If I explain the full requirements it might make more sense.
Attached is a logic map for the buttons. Red means disabled and Green enabled. There is actually a stop button which should stop the server and client and enable client and server buttons but not affect Teacher and Student buttons. The Teacher and Student buttons need to be enabled after their apps are closed. It's actually the same app but with different configuration. Not sure how to do this. Currently I have these buttons being enabled with the stop button.
I'm sure the code could be a lot smarter and tidier but it mostly works.
Thanks
Code: Select all
#!/bin/sh
[ -z $GTKDIALOG ] && GTKDIALOG=gtkdialog
MAIN_DIALOG='
<window>
<vbox>
<hbox>
<button>
<label>Server</label>
<variable>SERVER</variable>
<action>touch /tmp/server</action>
<action>touch /tmp/client</action>
<action>touch /tmp/teacher</action>
<action>disable:CLIENT</action>
<action>disable:TEACHER</action>
<action>disable:SERVER</action>
</button>
<button>
<label>Client</label>
<variable>CLIENT</variable>
<action>touch /tmp/client</action>
<action>touch /tmp/server</action>
<action>touch /tmp/student</action>
<action>disable:SERVER</action>
<action>disable:STUDENT</action>
<action>disable:CLIENT</action>
</button>
<button>
<label>Teacher</label>
<variable>TEACHER</variable>
<action>touch /tmp/teacher</action>
<action>touch /tmp/student</action>
<action>touch /tmp/server</action>
<action>disable:STUDENT</action>
<action>disable:SERVER</action>
<action>disable:TEACHER</action>
</button>
<button>
<label>Student</label>
<variable>STUDENT</variable>
<action>touch /tmp/student</action>
<action>touch /tmp/teacher</action>
<action>touch /tmp/client</action>
<action>disable:TEACHER</action>
<action>disable:CLIENT</action>
<action>disable:STUDENT</action>
</button>
<button tooltip-text="Reset all the buttons">
<label>Stop</label>
<variable>STOP</variable>
<action condition="command_is_true( [ -e /tmp/server ]&& echo true && rm /tmp/server)">enable:SERVER</action>
<action condition="command_is_true( [ -e /tmp/client ]&& echo true && rm /tmp/client)">enable:CLIENT</action>
<action condition="command_is_true( [ -e /tmp/teacher ]&& echo true && rm /tmp/teacher)">enable:TEACHER</action>
<action condition="command_is_true( [ -e /tmp/student ]&& echo true && rm /tmp/student)">enable:STUDENT</action>
</button>
<button ok></button>
</hbox>
</vbox>
</window>
'
export MAIN_DIALOG
case $1 in
-d | --dump) echo "$MAIN_DIALOG" ;;
*) $GTKDIALOG --program=MAIN_DIALOG ;;
esac
- Attachments
-
- button-map.png
- (4.7 KiB) Downloaded 747 times
- MochiMoppel
- Posts: 2084
- Joined: Wed 26 Jan 2011, 09:06
- Location: Japan
@zigbert: As smokey01 and I couldn't get this to work I would be keen to learn how this condition is supposed to work. The description in the manual makes no sense to me and I haven't found a single script or example where this condition has been used.zigbert wrote:Smokey
You're missing the conditional option.Code: Select all
<action condition="file_is_false( /tmp/file )">disable:STATUS</action>
I suspected that "file" would relate to a monitored input file, but tests were negative.
Do you know more?
[Edit] OK, figured it out. file_is_false tests if a given file contains "false", "no" or zero. In smokey01's example the tmp files contain nothing, hence the condition is not met. At least I now understand why nobody uses this condition.
Once I created a file containing the word false it work as you've also discovered.MochiMoppel wrote:@zigbert: As smokey01 and I couldn't get this to work I would be keen to learn how this condition is supposed to work. The description in the manual makes no sense to me and I haven't found a single script or example where this condition has been used.zigbert wrote:Smokey
You're missing the conditional option.Code: Select all
<action condition="file_is_false( /tmp/file )">disable:STATUS</action>
I suspected that "file" would relate to a monitored input file, but tests were negative.
Do you know more?
[Edit] OK, figured it out. file_is_false tests if a given file contains "false", "no" or zero. In smokey01's example the tmp files contain nothing, hence the condition is not met. At least I now understand why nobody uses this condition.
I'm still trying to find a way to enable/disable a button depending if a file exists or not in the following situation:
If I use a function that runs psip like this:
run_psip() {
touch /tmp/psip-file
psip
rm /tmp/psip-file
}
export -f run_psip
and call it from a button, the function only runs when the button is clicked.
When psip is terminated the "rm /tmp/psip-file" needs to be run after psip is closed, then a test to see if the file exists. The button in the GUI should be enabled when there is no /tmp/psip-file and disabled when there is.
I thought the <input file> option might work but apparently it only seems to display graphic files on the button widget, if they exist. I also tried it with tag attributes file-monitor and auto-refresh, no joy.
Is there are way to achieve this?
Thanks
- MochiMoppel
- Posts: 2084
- Joined: Wed 26 Jan 2011, 09:06
- Location: Japan
Argolance asked the same question here in this forum about 2 months ago.smokey01 wrote:I'm still trying to find a way to enable/disable a button depending if a file exists or not
Basically 2 ways to achieve this: Either with a timer widget or with file-monitor attribute.
You were close. <input file> is supposed to display the button icon but even if the file is no image file file-monitor can still monitor it. In Argolance's thread I gave an example with 2 buttons, but it can be done with only 1 button. Hold your breath, this is going to be weird.I thought the <input file> option might work but apparently it only seems to display graphic files on the button widget, if they exist. I also tried it with tag attributes file-monitor and auto-refresh, no joy.
I thought that this would not work, but it does (I use leafpad since I don't have psip).
The script starts by creating an empty file (> /tmp/leafpad-file).
The function removes any tmp file that may exist, then runs the application. After the application finished, an empty string is written to the empty file. Apart from the filedate nothing changed, right?. Normally I would expect that this does not trigger a file-changed signal, but apparently it does.
Code: Select all
#!/bin/bash
> /tmp/leafpad-file
run_leafpad() {
leafpad
> /tmp/leafpad-file
}
export -f run_leafpad
echo -n '<window>
<vbox>
<button label="run_leafpad" file-monitor="true">
<variable>BUT</variable>
<input file>/tmp/leafpad-file</input>
<action signal="file-changed">enable:BUT</action>
<action signal="file-changed">break:</action>
<action>disable:BUT</action>
<action>run_leafpad &</action>
</button>
</vbox>
</window>' | gtkdialog -s
rm /tmp/leafpad-file
Using a timer would be more efficient as the timer monitors the file only as long as leafpad is running and not continuously as in above example:
Code: Select all
#!/bin/bash
run_leafpad() {
> /tmp/leafpad-file
leafpad
rm /tmp/leafpad-file
}
export -f run_leafpad
echo -n '<window>
<vbox>
<button label="run_leafpad">
<variable>BUT</variable>
<action>disable:BUT</action>
<action>enable:TIMER</action>
<action>run_leafpad &</action>
</button>
<timer visible="false" sensitive="false">
<variable>TIMER</variable>
<action condition="command_is_true( [ -e /tmp/leafpad-file ] && echo true )">break:</action>
<action>disable:TIMER</action>
<action>enable:BUT</action>
</timer>
</vbox>
</window>' | gtkdialog -s
@MochiMoppel,
Two excellent examples. I prefer the second as it only creates the test file when the external app is running instead of the parent GUI. I was very close but no cigar, as they say.
I was using a timer widget at one stage but was unaware of the break command. I pretty sure this code will do the job nicely.
Thanks again.
Two excellent examples. I prefer the second as it only creates the test file when the external app is running instead of the parent GUI. I was very close but no cigar, as they say.
I was using a timer widget at one stage but was unaware of the break command. I pretty sure this code will do the job nicely.
Thanks again.
- TwoPuppies
- Posts: 77
- Joined: Wed 29 Dec 2010, 05:13
- Location: Melbourne, Australia
GtkDialog Progress Bar in script
I have a script here that installs VLC Media Player 2.2.2 from a collection of DEB packages that are archived in a directory. It runs in conjunction with a slightly modified version of Petget such that it installs the packages automatically and silently (without questions). Because there are 56 packages here, I would like to add a small GtkDialog window with a Progress Bar so that I can see how things are going. Can someone help me with this?
Code: Select all
#!/bin/sh
mv /usr/local/petget/{petget,petget_original}
cp /root/my-applications/"Install multiple packages"/Files/petget /usr/local/petget/
petget +fonts-freefont-ttf_20120503-4_all.deb
petget +libbasicusageenvironment1_2016.02.09-1_i386.deb
petget +libchromaprint0_1.3-1_i386.deb
petget +libfreerdp-cache1.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +libfreerdp-client1.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +libfreerdp-codec1.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +libfreerdp-common1.1.0_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +libfreerdp-core1.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +libfreerdp-crypto1.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +libfreerdp-gdi1.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +libfreerdp-locale1.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +libfreerdp-primitives1.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +libfreerdp-utils1.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +libgroupsock8_2016.02.09-1_i386.deb
petget +libkate1_0.4.1-7_i386.deb
petget +liblivemedia50_2016.02.09-1_i386.deb
petget +libmatroska6v5_1.4.4-1_i386.deb
petget +libmtp9_1.1.10-2ubuntu1_i386.deb
petget +libmtp-common_1.1.10-2ubuntu1_all.deb
petget +libproxy-tools_0.4.11-5ubuntu1_i386.deb
petget +libqt5core5a_5.5.1+dfsg-16ubuntu7.6_i386.deb
petget +libqt5dbus5_5.5.1+dfsg-16ubuntu7.6_i386.deb
petget +libqt5gui5_5.5.1+dfsg-16ubuntu7.6_i386.deb
petget +libqt5network5_5.5.1+dfsg-16ubuntu7.6_i386.deb
petget +libqt5widgets5_5.5.1+dfsg-16ubuntu7.6_i386.deb
petget +libqt5x11extras5_5.5.1-3build1_i386.deb
petget +libresid-builder0c2a_2.1.1-14ubuntu2_i386.deb
petget +libshout3_2.3.1-3_i386.deb
petget +libsidplay2v5_2.1.1-14ubuntu2_i386.deb
petget +libssh2-1_1.5.0-2ubuntu0.1_i386.deb
petget +libupnp6_1.6.19+git20160116-1_i386.deb
petget +libusageenvironment3_2016.02.09-1_i386.deb
petget +libvlc5_2.2.2-5ubuntu0.16.04.4_i386.deb
petget +libvlccore8_2.2.2-5ubuntu0.16.04.4_i386.deb
petget +libvncclient1_0.9.10+dfsg-3ubuntu0.16.04.3_i386.deb
petget +libwinpr-crt0.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +libwinpr-dsparse0.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +libwinpr-environment0.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +libwinpr-file0.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +libwinpr-handle0.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +libwinpr-heap0.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +libwinpr-input0.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +libwinpr-interlocked0.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +libwinpr-library0.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +libwinpr-path0.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +libwinpr-pool0.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +libwinpr-registry0.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +libwinpr-rpc0.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +libwinpr-sspi0.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +libwinpr-synch0.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +libwinpr-sysinfo0.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +libwinpr-thread0.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +libwinpr-utils0.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +vlc_2.2.2-5ubuntu0.16.04.4_i386.deb
petget +vlc-data_2.2.2-5ubuntu0.16.04.4_all.deb
petget +vlc-nox_2.2.2-5ubuntu0.16.04.4_i386.deb
rm -fR /usr/local/petget/petget
mv /usr/local/petget/{petget_original,petget}
/usr/sbin/fixmenus
[ "`pidof jwm`" != "" ] && { jwm -reload || jwm -restart ; }
export MAIN_DIALOG='
<window window_position="3" title="Installation complete" width_request="300" icon-name="gtk-info">
<vbox>
<pixmap><input file>/usr/local/lib/X11/pixmaps/invisible96x8.png</input></pixmap>
<hbox homogeneous="true">
<text use-markup="true" width_request="0"><label>"<b><big>Installation is complete</big></b>"</label></text>
</hbox>
<pixmap><input file>/usr/local/lib/X11/pixmaps/invisible96x8.png</input></pixmap>
<hbox homogeneous="True">
<button ok></button>
</hbox>
<pixmap><input file>/usr/local/lib/X11/pixmaps/invisible96x8.png</input></pixmap>
</vbox>
</window>
'
gtkdialog --program=MAIN_DIALOG &
[color=#006699]What you really need is two puppies:
Puppy Linux, and the sort with four legs and a tail.[/color]
Puppy Linux, and the sort with four legs and a tail.[/color]
- MochiMoppel
- Posts: 2084
- Joined: Wed 26 Jan 2011, 09:06
- Location: Japan
My first progressbar...
May even work, but treat with caution and adapt as needed:
May even work, but treat with caution and adapt as needed:
Code: Select all
#!/bin/bash
export PACKAGELIST='
libservice ubuntu1.3_i386.deb
libwinwin-psych0.1_1.1.0.deb
another sillyly named1.2.3.deb
'
function progress {
IFS=$'\n'
array=($PACKAGELIST)
cnt=${#array[@]}
step=$((100/cnt))
bar=$step
for ((c=0;c<$cnt;c++));do
file=${array[$c]}
echo $bar #progress indicator (MUST be number)
echo $file #text within progress bar (MUST NOT start with number)
gxmessage petget +$file #run executable (remove gxmessage after testing)
bar=$((bar+step)) #increase progress indicator
done;
echo 100 #bar value may not have reached 100; force 100 to trigger progress bar action
}; export -f progress
export MAIN_DIALOG='
<window>
<vbox>
<text label="Packages are being installed..."></text>
<progressbar>
<input>progress</input>
<action>exit:</action>
</progressbar>
</vbox>
</window>
'
gtkdialog
- TwoPuppies
- Posts: 77
- Joined: Wed 29 Dec 2010, 05:13
- Location: Melbourne, Australia
Hi MochiMoppel. Thanks for your Progress Bar script.
Firstly, is the following the correct way to integrate your script with mine?:
Secondly, if the above is correct, then there are two problems:
1. I only get a Progress Bar when the gxmessage line is present. (And, of course, I also get the gxmessage message windows). When I remove the gxmessage line, the message windows cease to display, but so does the Progress Bar.
2. In both of the above cases (with the gxmessage line or without it) my script no longer actually installs anything.
Firstly, is the following the correct way to integrate your script with mine?:
Code: Select all
#!/bin/sh
mv /usr/local/petget/{petget,petget_original}
cp /root/my-applications/"Install multiple packages"/Files/petget /usr/local/petget/
petget +fonts-freefont-ttf_20120503-4_all.deb
petget +libbasicusageenvironment1_2016.02.09-1_i386.deb
petget +libchromaprint0_1.3-1_i386.deb
petget +libfreerdp-cache1.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +libfreerdp-client1.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +libfreerdp-codec1.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +libfreerdp-common1.1.0_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +libfreerdp-core1.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +libfreerdp-crypto1.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +libfreerdp-gdi1.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +libfreerdp-locale1.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +libfreerdp-primitives1.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +libfreerdp-utils1.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +libgroupsock8_2016.02.09-1_i386.deb
petget +libkate1_0.4.1-7_i386.deb
petget +liblivemedia50_2016.02.09-1_i386.deb
petget +libmatroska6v5_1.4.4-1_i386.deb
petget +libmtp9_1.1.10-2ubuntu1_i386.deb
petget +libmtp-common_1.1.10-2ubuntu1_all.deb
petget +libproxy-tools_0.4.11-5ubuntu1_i386.deb
petget +libqt5core5a_5.5.1+dfsg-16ubuntu7.6_i386.deb
petget +libqt5dbus5_5.5.1+dfsg-16ubuntu7.6_i386.deb
petget +libqt5gui5_5.5.1+dfsg-16ubuntu7.6_i386.deb
petget +libqt5network5_5.5.1+dfsg-16ubuntu7.6_i386.deb
petget +libqt5widgets5_5.5.1+dfsg-16ubuntu7.6_i386.deb
petget +libqt5x11extras5_5.5.1-3build1_i386.deb
petget +libresid-builder0c2a_2.1.1-14ubuntu2_i386.deb
petget +libshout3_2.3.1-3_i386.deb
petget +libsidplay2v5_2.1.1-14ubuntu2_i386.deb
petget +libssh2-1_1.5.0-2ubuntu0.1_i386.deb
petget +libupnp6_1.6.19+git20160116-1_i386.deb
petget +libusageenvironment3_2016.02.09-1_i386.deb
petget +libvlc5_2.2.2-5ubuntu0.16.04.4_i386.deb
petget +libvlccore8_2.2.2-5ubuntu0.16.04.4_i386.deb
petget +libvncclient1_0.9.10+dfsg-3ubuntu0.16.04.3_i386.deb
petget +libwinpr-crt0.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +libwinpr-dsparse0.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +libwinpr-environment0.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +libwinpr-file0.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +libwinpr-handle0.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +libwinpr-heap0.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +libwinpr-input0.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +libwinpr-interlocked0.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +libwinpr-library0.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +libwinpr-path0.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +libwinpr-pool0.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +libwinpr-registry0.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +libwinpr-rpc0.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +libwinpr-sspi0.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +libwinpr-synch0.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +libwinpr-sysinfo0.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +libwinpr-thread0.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +libwinpr-utils0.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +vlc_2.2.2-5ubuntu0.16.04.4_i386.deb
petget +vlc-data_2.2.2-5ubuntu0.16.04.4_all.deb
petget +vlc-nox_2.2.2-5ubuntu0.16.04.4_i386.deb
export PACKAGELIST='
petget +fonts-freefont-ttf_20120503-4_all.deb
petget +libbasicusageenvironment1_2016.02.09-1_i386.deb
petget +libchromaprint0_1.3-1_i386.deb
petget +libfreerdp-cache1.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +libfreerdp-client1.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +libfreerdp-codec1.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +libfreerdp-common1.1.0_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +libfreerdp-core1.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +libfreerdp-crypto1.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +libfreerdp-gdi1.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +libfreerdp-locale1.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +libfreerdp-primitives1.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +libfreerdp-utils1.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +libgroupsock8_2016.02.09-1_i386.deb
petget +libkate1_0.4.1-7_i386.deb
petget +liblivemedia50_2016.02.09-1_i386.deb
petget +libmatroska6v5_1.4.4-1_i386.deb
petget +libmtp9_1.1.10-2ubuntu1_i386.deb
petget +libmtp-common_1.1.10-2ubuntu1_all.deb
petget +libproxy-tools_0.4.11-5ubuntu1_i386.deb
petget +libqt5core5a_5.5.1+dfsg-16ubuntu7.6_i386.deb
petget +libqt5dbus5_5.5.1+dfsg-16ubuntu7.6_i386.deb
petget +libqt5gui5_5.5.1+dfsg-16ubuntu7.6_i386.deb
petget +libqt5network5_5.5.1+dfsg-16ubuntu7.6_i386.deb
petget +libqt5widgets5_5.5.1+dfsg-16ubuntu7.6_i386.deb
petget +libqt5x11extras5_5.5.1-3build1_i386.deb
petget +libresid-builder0c2a_2.1.1-14ubuntu2_i386.deb
petget +libshout3_2.3.1-3_i386.deb
petget +libsidplay2v5_2.1.1-14ubuntu2_i386.deb
petget +libssh2-1_1.5.0-2ubuntu0.1_i386.deb
petget +libupnp6_1.6.19+git20160116-1_i386.deb
petget +libusageenvironment3_2016.02.09-1_i386.deb
petget +libvlc5_2.2.2-5ubuntu0.16.04.4_i386.deb
petget +libvlccore8_2.2.2-5ubuntu0.16.04.4_i386.deb
petget +libvncclient1_0.9.10+dfsg-3ubuntu0.16.04.3_i386.deb
petget +libwinpr-crt0.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +libwinpr-dsparse0.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +libwinpr-environment0.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +libwinpr-file0.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +libwinpr-handle0.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +libwinpr-heap0.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +libwinpr-input0.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +libwinpr-interlocked0.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +libwinpr-library0.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +libwinpr-path0.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +libwinpr-pool0.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +libwinpr-registry0.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +libwinpr-rpc0.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +libwinpr-sspi0.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +libwinpr-synch0.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +libwinpr-sysinfo0.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +libwinpr-thread0.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +libwinpr-utils0.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
petget +vlc_2.2.2-5ubuntu0.16.04.4_i386.deb
petget +vlc-data_2.2.2-5ubuntu0.16.04.4_all.deb
petget +vlc-nox_2.2.2-5ubuntu0.16.04.4_i386.deb
'
function progress {
IFS=$'\n'
array=($PACKAGELIST)
cnt=${#array[@]}
step=$((100/cnt))
bar=$step
for ((c=0;c<$cnt;c++));do
file=${array[$c]}
echo $bar #progress indicator (MUST be number)
echo $file #text within progress bar (MUST NOT start with number)
gxmessage petget +$file #run executable (remove gxmessage after testing)
bar=$((bar+step)) #increase progress indicator
done;
echo 100 #bar value may not have reached 100; force 100 to trigger progress bar action
}; export -f progress
export MAIN_DIALOG='
<window>
<vbox>
<text label="Packages are being installed..."></text>
<progressbar>
<input>progress</input>
<action>exit:</action>
</progressbar>
</vbox>
</window>
'
gtkdialog
rm -fR /usr/local/petget/petget
mv /usr/local/petget/{petget_original,petget}
/usr/sbin/fixmenus
[ "`pidof jwm`" != "" ] && { jwm -reload || jwm -restart ; }
export MAIN_DIALOG='
<window window_position="3" title="Installation complete" width_request="300" icon-name="gtk-info">
<vbox>
<pixmap><input file>/usr/local/lib/X11/pixmaps/invisible96x8.png</input></pixmap>
<hbox homogeneous="true">
<text use-markup="true" width_request="0"><label>"<b><big>Installation is complete</big></b>"</label></text>
</hbox>
<pixmap><input file>/usr/local/lib/X11/pixmaps/invisible96x8.png</input></pixmap>
<hbox homogeneous="True">
<button ok></button>
</hbox>
<pixmap><input file>/usr/local/lib/X11/pixmaps/invisible96x8.png</input></pixmap>
</vbox>
</window>
'
gtkdialog --program=MAIN_DIALOG &
1. I only get a Progress Bar when the gxmessage line is present. (And, of course, I also get the gxmessage message windows). When I remove the gxmessage line, the message windows cease to display, but so does the Progress Bar.
2. In both of the above cases (with the gxmessage line or without it) my script no longer actually installs anything.
[color=#006699]What you really need is two puppies:
Puppy Linux, and the sort with four legs and a tail.[/color]
Puppy Linux, and the sort with four legs and a tail.[/color]
- MochiMoppel
- Posts: 2084
- Joined: Wed 26 Jan 2011, 09:06
- Location: Japan
NoTwoPuppies wrote:Firstly, is the following the correct way to integrate your script with mine?
If the above would be correct you wouldn't have these problemsSecondly, if the above is correct, then there are two problems:
Note that in my example PACKAGELIST contains only the names of the package files (without the preceding "petget +")
The content of the gxmessage represents the command that would be executed if you would remove "gxmessage". Take a close look. With your script this command would be not correct.
Before the "export PACKAGELIST='" line you still run all those petget commands, i.e. you are actually installing the packages before the progress function will try to install them again. Makes no sense. Remove these petget commands.
- TwoPuppies
- Posts: 77
- Joined: Wed 29 Dec 2010, 05:13
- Location: Melbourne, Australia
- TwoPuppies
- Posts: 77
- Joined: Wed 29 Dec 2010, 05:13
- Location: Melbourne, Australia
Got it working. Hooray!
For anyone else reading this and wanting to understand what is going on, I made three mistakes:
1. My initial list of commands was not required. It duplicated the list in the 'PACKAGELIST=' section, so I was trying to install everything twice.
2. The prefix petget + in the 'PACKAGELIST=' section was not required because the later command petget +$file adds this automatically.
3. When testing later, I subsequently misunderstood the comment #run executable (remove gxmessage after testing) and removed the entire line (rather than just gxmessage), so nothing got installed.
I think I have all that right.
This version works:
As always, MochiMoppel, thank you for your help. What would I do without you?
Just out of interest, why does the Progress Bar close before the bar gets to the end? Can this be changed?
For anyone else reading this and wanting to understand what is going on, I made three mistakes:
1. My initial list of commands was not required. It duplicated the list in the 'PACKAGELIST=' section, so I was trying to install everything twice.
2. The prefix petget + in the 'PACKAGELIST=' section was not required because the later command petget +$file adds this automatically.
3. When testing later, I subsequently misunderstood the comment #run executable (remove gxmessage after testing) and removed the entire line (rather than just gxmessage), so nothing got installed.
I think I have all that right.
This version works:
Code: Select all
#!/bin/sh
mv /usr/local/petget/{petget,petget_original}
cp /root/my-applications/"Install multiple packages"/Files/petget /usr/local/petget/
export PACKAGELIST='
fonts-freefont-ttf_20120503-4_all.deb
libbasicusageenvironment1_2016.02.09-1_i386.deb
libchromaprint0_1.3-1_i386.deb
libfreerdp-cache1.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
libfreerdp-client1.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
libfreerdp-codec1.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
libfreerdp-common1.1.0_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
libfreerdp-core1.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
libfreerdp-crypto1.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
libfreerdp-gdi1.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
libfreerdp-locale1.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
libfreerdp-primitives1.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
libfreerdp-utils1.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
libgroupsock8_2016.02.09-1_i386.deb
libkate1_0.4.1-7_i386.deb
liblivemedia50_2016.02.09-1_i386.deb
libmatroska6v5_1.4.4-1_i386.deb
libmtp9_1.1.10-2ubuntu1_i386.deb
libmtp-common_1.1.10-2ubuntu1_all.deb
libproxy-tools_0.4.11-5ubuntu1_i386.deb
libqt5core5a_5.5.1+dfsg-16ubuntu7.6_i386.deb
libqt5dbus5_5.5.1+dfsg-16ubuntu7.6_i386.deb
libqt5gui5_5.5.1+dfsg-16ubuntu7.6_i386.deb
libqt5network5_5.5.1+dfsg-16ubuntu7.6_i386.deb
libqt5widgets5_5.5.1+dfsg-16ubuntu7.6_i386.deb
libqt5x11extras5_5.5.1-3build1_i386.deb
libresid-builder0c2a_2.1.1-14ubuntu2_i386.deb
libshout3_2.3.1-3_i386.deb
libsidplay2v5_2.1.1-14ubuntu2_i386.deb
libssh2-1_1.5.0-2ubuntu0.1_i386.deb
libupnp6_1.6.19+git20160116-1_i386.deb
libusageenvironment3_2016.02.09-1_i386.deb
libvlc5_2.2.2-5ubuntu0.16.04.4_i386.deb
libvlccore8_2.2.2-5ubuntu0.16.04.4_i386.deb
libvncclient1_0.9.10+dfsg-3ubuntu0.16.04.3_i386.deb
libwinpr-crt0.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
libwinpr-dsparse0.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
libwinpr-environment0.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
libwinpr-file0.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
libwinpr-handle0.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
libwinpr-heap0.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
libwinpr-input0.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
libwinpr-interlocked0.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
libwinpr-library0.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
libwinpr-path0.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
libwinpr-pool0.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
libwinpr-registry0.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
libwinpr-rpc0.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
libwinpr-sspi0.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
libwinpr-synch0.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
libwinpr-sysinfo0.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
libwinpr-thread0.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
libwinpr-utils0.1_1.1.0~git20140921.1.440916e+dfsg1-5ubuntu1.3_i386.deb
vlc_2.2.2-5ubuntu0.16.04.4_i386.deb
vlc-data_2.2.2-5ubuntu0.16.04.4_all.deb
vlc-nox_2.2.2-5ubuntu0.16.04.4_i386.deb
'
function progress {
IFS=$'\n'
array=($PACKAGELIST)
cnt=${#array[@]}
step=$((100/cnt))
bar=$step
for ((c=0;c<$cnt;c++));do
file=${array[$c]}
echo $bar #progress indicator (MUST be number)
echo $file #text within progress bar (MUST NOT start with number)
petget +$file #run executable (remove gxmessage after testing)
bar=$((bar+step)) #increase progress indicator
done;
echo 100 #bar value may not have reached 100; force 100 to trigger progress bar action
}; export -f progress
export MAIN_DIALOG='
<window>
<vbox>
<text label="Packages are being installed..."></text>
<progressbar>
<input>progress</input>
<action>exit:</action>
</progressbar>
</vbox>
</window>
'
gtkdialog
rm -fR /usr/local/petget/petget
mv /usr/local/petget/{petget_original,petget}
/usr/sbin/fixmenus
[ "`pidof jwm`" != "" ] && { jwm -reload || jwm -restart ; }
export MAIN_DIALOG='
<window window_position="3" title="Installation complete" width_request="300" icon-name="gtk-info">
<vbox>
<pixmap><input file>/usr/local/lib/X11/pixmaps/invisible96x8.png</input></pixmap>
<hbox homogeneous="true">
<text use-markup="true" width_request="0"><label>"<b><big>Installation is complete</big></b>"</label></text>
</hbox>
<pixmap><input file>/usr/local/lib/X11/pixmaps/invisible96x8.png</input></pixmap>
<hbox homogeneous="True">
<button ok></button>
</hbox>
<pixmap><input file>/usr/local/lib/X11/pixmaps/invisible96x8.png</input></pixmap>
</vbox>
</window>
'
gtkdialog --program=MAIN_DIALOG &
Just out of interest, why does the Progress Bar close before the bar gets to the end? Can this be changed?
Last edited by TwoPuppies on Tue 13 Aug 2019, 05:03, edited 2 times in total.
[color=#006699]What you really need is two puppies:
Puppy Linux, and the sort with four legs and a tail.[/color]
Puppy Linux, and the sort with four legs and a tail.[/color]
- MochiMoppel
- Posts: 2084
- Joined: Wed 26 Jan 2011, 09:06
- Location: Japan
Congratulations!TwoPuppies wrote:Got it working. Hooray!
because bash doesn't know how to calculate . Here is what happens:Just out of interest, why does the Progress Bar close before the bar gets to the end?
First we have to calculate cnt, the number of files in the list. Results in 56. So far so good.
We then have to calculate step, the portion of the progress bar added with each processed file. When all files are processed all steps should add up to 100, or at least close to it. My code calculates step as $((100/cnt)), i.e. 100 divided by 56, which should result in 1.786). Unfortunately bash can't do floating point calculation and rounds the result down to the nearest integer, which is 1. With a step of only 1 and 56 processed files the progress bar will only reach 56%
Yes. Increase the accuracy of the step value. Try an increase of 1000Can this be changed?
Change step=$((100/cnt)) to step=$((100000/cnt))
and
echo $bar to echo $((bar/1000))
which reverts the temporary increase. See if this helps.
- misko_2083
- Posts: 114
- Joined: Tue 08 Nov 2016, 13:42
Bash can do floating point calculations.MochiMoppel wrote:because bash doesn't know how to calculate
I would try next:1.78Code: Select all
step=$(( 100 / cnt )).$(( (100 * 100 / cnt) % 100 ))
bc outputs the same:Code: Select all
bc -l <<<"scale=2;100/56"
MochiMoppel wrote:Unfortunately bash can't do floating point calculation and rounds the result down to the nearest integer, which is 1. With a step of only 1 and 56 processed files the progress bar will only reach 56%
https://github.com/bluebat/.bash/blob/master/bashbc.sh
- MochiMoppel
- Posts: 2084
- Joined: Wed 26 Jan 2011, 09:06
- Location: Japan
I wouldn'tmisko_2083 wrote:I would try next:1.78Code: Select all
step=$(( 100 / cnt )).$(( (100 * 100 / cnt) % 100 ))
Remember that you would still have to add these values up. In bash? Good luck!
I find my approach much easier. Besides: The progressbar doesn't seem to care about fractions. Non-numeric characters after an integer are ignored. It doesn't matter if you echo a value of 1 or 1.99999 or even 1blabla, the bar will always show exactly 1% .
- TwoPuppies
- Posts: 77
- Joined: Wed 29 Dec 2010, 05:13
- Location: Melbourne, Australia
This worked as expected. The Progress Bar continued all the way to the end before the window closed. Thanks MochiMoppel.MochiMoppel wrote:Change step=$((100/cnt)) to step=$((100000/cnt))
and
echo $bar to echo $((bar/1000))
This caused the Progress Bar to freeze after only one Package was installed. No more Packages installed after that.misko_2083 wrote:I would try next:Code: Select all
step=$(( 100 / cnt )).$(( (100 * 100 / cnt) % 100 ))
[color=#006699]What you really need is two puppies:
Puppy Linux, and the sort with four legs and a tail.[/color]
Puppy Linux, and the sort with four legs and a tail.[/color]
- MochiMoppel
- Posts: 2084
- Joined: Wed 26 Jan 2011, 09:06
- Location: Japan
- misko_2083
- Posts: 114
- Joined: Tue 08 Nov 2016, 13:42
I know, just forgot to mention that I used the pure bash calculator.MochiMoppel wrote:I wouldn'tmisko_2083 wrote:I would try next:1.78Code: Select all
step=$(( 100 / cnt )).$(( (100 * 100 / cnt) % 100 ))
Remember that you would still have to add these values up. In bash? Good luck!
I find my approach much easier. Besides: The progressbar doesn't seem to care about fractions. Non-numeric characters after an integer are ignored. It doesn't matter if you echo a value of 1 or 1.99999 or even 1blabla, the bar will always show exactly 1% .
I saved && made executable this script https://github.com/bluebat/.bash/blob/master/bashbc.sh
Code: Select all
IFS=$'\n'
array=($PACKAGELIST)
cnt=${#array[@]}
step=$(( 100 / cnt )).$(( (100 * 100 / cnt) % 100 ))
bar=$step
for ((c=0;c<$cnt;c++));do
file=${array[$c]}
echo $bar #progress indicator (MUST be number)
echo $file #text within progress bar (MUST NOT start with number)
# set the path to bashbc.sh here !
bar=$(scale=2 bashbc.sh $bar+$step) #increase progress indicator
done;
echo 100
Code: Select all
bashbc.sh 2.555+6.335
8.89
scale=2 bashbc.sh 2*(3/7)
0.84
I have 20 button inside of scrollable vbox. When I use down arrow keyboard to move from one button to another button below that, after some button, the button not appear. Butwhen I usemoise to scroll down, it is select on that button. How to make the button always seen when we use down arrow keyboard? Just like tree. Is it possible? Thank you.