Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Tue 10 Dec 2019, 16:24
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
GtkDialog - tips
Post new topic   Reply to topic View previous topic :: View next topic
Page 98 of 99 [1478 Posts]   Goto page: Previous 1, 2, 3, ..., 96, 97, 98, 99 Next
Author Message
MochiMoppel


Joined: 26 Jan 2011
Posts: 1943
Location: Japan

PostPosted: Wed 12 Dec 2018, 09:16    Post subject:  

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.
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.
Back to top
View user's profile Send private message 
smokey01


Joined: 30 Dec 2006
Posts: 2811
Location: South Australia :-(

PostPosted: Wed 12 Dec 2018, 17:12    Post subject:  

MochiMoppel wrote:
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.
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.

You are quite correct and thanks.

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:

#!/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
button-map.png
 Description   
 Filesize   4.7 KB
 Viewed   603 Time(s)

button-map.png


_________________
Software <-> Distros <-> Tips <-> Newsletters
Back to top
View user's profile Send private message Visit poster's website 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1943
Location: Japan

PostPosted: Thu 13 Dec 2018, 10:52    Post subject:  

zigbert wrote:
Smokey
You're missing the conditional option.
Code:
<action condition="file_is_false( /tmp/file )">disable:STATUS</action>

@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.
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.
Back to top
View user's profile Send private message 
zigbert


Joined: 29 Mar 2006
Posts: 6608
Location: Valåmoen, Norway

PostPosted: Thu 13 Dec 2018, 17:03    Post subject:  

MochiMoppel wrote:
At least I now understand why nobody uses this condition.
I do Embarassed Laughing
_________________
Stardust resources
Back to top
View user's profile Send private message Visit poster's website 
smokey01


Joined: 30 Dec 2006
Posts: 2811
Location: South Australia :-(

PostPosted: Thu 13 Dec 2018, 17:06    Post subject:  

MochiMoppel wrote:
zigbert wrote:
Smokey
You're missing the conditional option.
Code:
<action condition="file_is_false( /tmp/file )">disable:STATUS</action>

@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.
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.

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

_________________
Software <-> Distros <-> Tips <-> Newsletters
Back to top
View user's profile Send private message Visit poster's website 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1943
Location: Japan

PostPosted: Fri 14 Dec 2018, 00:24    Post subject:  

smokey01 wrote:
I'm still trying to find a way to enable/disable a button depending if a file exists or not
Argolance asked the same question here in this forum about 2 months ago.
Basically 2 ways to achieve this: Either with a timer widget or with file-monitor attribute.

Quote:
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.
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 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:
#!/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
Note that in above code the button has no icon but it would be no problem to add one in the usual manner.

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:
#!/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
Back to top
View user's profile Send private message 
smokey01


Joined: 30 Dec 2006
Posts: 2811
Location: South Australia :-(

PostPosted: Sat 15 Dec 2018, 18:49    Post subject:  

@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.

_________________
Software <-> Distros <-> Tips <-> Newsletters
Back to top
View user's profile Send private message Visit poster's website 
TwoPuppies


Joined: 29 Dec 2010
Posts: 77
Location: Melbourne, Australia

PostPosted: Sun 11 Aug 2019, 02:23    Post subject: GtkDialog Progress Bar in script
Subject description: Cannot work out how to insert progress bar into existing 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:
#!/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 &

_________________
What you really need is two puppies:
Puppy Linux, and the sort with four legs and a tail.

Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1943
Location: Japan

PostPosted: Sun 11 Aug 2019, 09:40    Post subject:  

My first progressbar...
May even work, but treat with caution and adapt as needed:
Code:
#!/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
Back to top
View user's profile Send private message 
TwoPuppies


Joined: 29 Dec 2010
Posts: 77
Location: Melbourne, Australia

PostPosted: Mon 12 Aug 2019, 00:46    Post subject:  

Hi MochiMoppel. Thanks for your Progress Bar script.

Firstly, is the following the correct way to integrate your script with mine?:
Code:
#!/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 &


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.

_________________
What you really need is two puppies:
Puppy Linux, and the sort with four legs and a tail.

Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1943
Location: Japan

PostPosted: Mon 12 Aug 2019, 01:26    Post subject:  

TwoPuppies wrote:
Firstly, is the following the correct way to integrate your script with mine?
No
Quote:
Secondly, if the above is correct, then there are two problems:
If the above would be correct you wouldn't have these problems Wink

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.
Back to top
View user's profile Send private message 
TwoPuppies


Joined: 29 Dec 2010
Posts: 77
Location: Melbourne, Australia

PostPosted: Mon 12 Aug 2019, 02:11    Post subject:  

OK, thanks. I'll see what I can do with it.
You might guess that I don't really have all that much idea what I am doing here. Embarassed

_________________
What you really need is two puppies:
Puppy Linux, and the sort with four legs and a tail.

Back to top
View user's profile Send private message 
TwoPuppies


Joined: 29 Dec 2010
Posts: 77
Location: Melbourne, Australia

PostPosted: Mon 12 Aug 2019, 03:38    Post subject:  

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:
Code:
#!/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 &


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?

_________________
What you really need is two puppies:
Puppy Linux, and the sort with four legs and a tail.


Last edited by TwoPuppies on Tue 13 Aug 2019, 01:03; edited 2 times in total
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1943
Location: Japan

PostPosted: Mon 12 Aug 2019, 07:03    Post subject:  

TwoPuppies wrote:
Got it working. Hooray!
Congratulations!

Quote:
Just out of interest, why does the Progress Bar close before the bar gets to the end?
because bash doesn't know how to calculate Laughing . Here is what happens:
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% Crying or Very sad

Quote:
Can this be changed?

Yes. Increase the accuracy of the step value. Try an increase of 1000
Change step=$((100/cnt)) to step=$((100000/cnt))
and
echo $bar to echo $((bar/1000))
which reverts the temporary increase. See if this helps.
Back to top
View user's profile Send private message 
misko_2083


Joined: 08 Nov 2016
Posts: 100

PostPosted: Mon 12 Aug 2019, 12:25    Post subject:  

[quote="MochiMoppel"]because bash doesn't know how to calculate Laughing
I would try next: Smile
Code:
 step=$(( 100 / cnt )).$(( (100 * 100 / cnt) % 100 ))

1.78
bc outputs the same:
Code:
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% Crying or Very sad

Bash can do floating point calculations. Wink
Arrow https://github.com/bluebat/.bash/blob/master/bashbc.sh
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 98 of 99 [1478 Posts]   Goto page: Previous 1, 2, 3, ..., 96, 97, 98, 99 Next
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1661s ][ Queries: 12 (0.0412s) ][ GZIP on ]