| Author |
Message |
don570

Joined: 10 Mar 2010 Posts: 2527 Location: Ontario
|
Posted: Sat 04 Aug 2012, 15:36 Post_subject:
Restrain COMBOBOX list |
|
I've written a short script to demonstrate the restraining of
a COMBOBOX list
The script simply plays a sound file or it can be an m3u playlist
(for hours of music with just the click of a button).
It's easy to set the
the sound file in the beginning of the script if you wish.
The basic idea is this...
From a list of possible Audio players a search is done to
find the Audio players that are actually installed in your computer.
The COMBOBOX shows the list of installed players, so the
user can choose among these to play a sound file.
I wanted to show that it was easy to edit the list and
I think I succeeded.
It's a very simple script. I'll show it in the next post.
Notice the quoting of
This is the function that makes the list.
_______________________________________________
Edited_times_total
|
|
Back to top
|
|
 |
don570

Joined: 10 Mar 2010 Posts: 2527 Location: Ontario
|
Posted: Sat 04 Aug 2012, 15:42 Post_subject:
script to restrain combobox using ls |
|
| Code: |
#!/bin/sh
#aug2 2012
#Combobox example by don570
# find version of gtkdialog
for P in gtkdialog4 gtkdialog3 gtkdialog; do
GTKDIALOG=$(which $P) && break
done
mkdir -p /tmp/COMBOBOX_LIST
rm -f /tmp/COMBOBOX_LIST/* # clear out temp folder of files
export SOUND=/root/puppy-reference/audio/2barks.wav
export i=0 # initialize loop counter
# loop through the list of apps that you make
for P in pmusic audacious deadbeef gnome-mplayer aqualung xine; do
APP_FOUND=`echo $(which $P)`
if [ -n "$APP_FOUND" ] ; then
APP[$i]="${APP_FOUND##*/}" # shorten to the app name
let i=$i+1 # number of apps found
fi
done
# fill folder with files representing the APP names
cd /tmp/COMBOBOX_LIST
for ((a=0; a <= i ; a++))
do
touch ${APP[$a]}
done
function COMBOBOX()
{
ls -A | while read line; do
echo "<item>${line}</item>"
done
}
export BUILD_LIST='
<vbox>
<text>
<label>Audio Player</label>
</text>
<combobox case-sensitive="false" value-in-list="true">
<variable>PLAYER</variable>
'"$(COMBOBOX)"'
</combobox>
<hbox>
<button cancel></button>
<button>
<label>Play Sound</label>
<action>$PLAYER "$SOUND" &</action>
</button>
</hbox>
</vbox>
'
$GTKDIALOG --program=BUILD_LIST
|
Here's the script to download. Remove gz extension
________________________
| Description |
remove gz extension to obtain script
|

Download |
| Filename |
build_list.sh.gz |
| Filesize |
1.55 KB |
| Downloaded |
153 Time(s) |
|
|
Back to top
|
|
 |
don570

Joined: 10 Mar 2010 Posts: 2527 Location: Ontario
|
Posted: Tue 07 Aug 2012, 18:17 Post_subject:
|
|
Here's an alternate way to restrain the combobox that is even
simpler. It uses the 'cat' command rather that the 'ls' command.
This script avoids the use of an array and the use of a temporary
folder. It uses a temporary file to hold the app names.
| Code: |
#!/bin/sh
#aug2 2012
#Combobox example by don570
# find version of gtkdialog
for P in gtkdialog4 gtkdialog3 gtkdialog; do
GTKDIALOG=$(which $P) && break
done
rm -f /tmp/COMBO_LIST
export SOUND="$HOME/puppy-reference/audio/2barks.wav"
# loop through the list of apps that you make
for P in pmusic audacious deadbeef gnome-mplayer aqualung xine; do
APP_FOUND=`echo $(which $P)`
APP="${APP_FOUND##*/}" # shorten to the app name
if [ -n "$APP" ] ; then # avoid blank lines
echo $APP >> /tmp/COMBO_LIST
fi
done
function COMBOBOX()
{
cat /tmp/COMBO_LIST | while read line; do
echo "<item>${line}</item>"
cat /tmp/COMBO_LIST | sed '1d' > /tmp/COMBO_LIST_tmp
mv -f /tmp/COMBO_LIST_tmp /tmp/COMBO_LIST
done
rm -f /tmp/COMBO_LIST
}
export BUILD_LIST='
<vbox>
<text>
<label>Audio Player</label>
</text>
<combobox case-sensitive="false" value-in-list="true">
<variable>PLAYER</variable>
'"$(COMBOBOX)"'
</combobox>
<hbox>
<button cancel></button>
<button>
<label>Play Sound</label>
<action>$PLAYER "$SOUND" &</action>
</button>
</hbox>
</vbox>
'
$GTKDIALOG --program=BUILD_LIST
|
 |
| Description |
remove gz extension to obtain the script
|

Download |
| Filename |
build_list_alt.sh.gz |
| Filesize |
1.45 KB |
| Downloaded |
159 Time(s) |
|
|
Back to top
|
|
 |
8-bit

Joined: 03 Apr 2007 Posts: 3033 Location: Oregon
|
Posted: Wed 22 Aug 2012, 13:49 Post_subject:
Sub_title: bug? |
|
I have Thunor's PMusic installed and when I select play sound, the sound file keeps repeating until I close PMusic.
But maybe that is a PMusic problem in that it may be setup to loop it's playlist.
|
|
Back to top
|
|
 |
don570

Joined: 10 Mar 2010 Posts: 2527 Location: Ontario
|
Posted: Sat 02 Mar 2013, 14:42 Post_subject:
|
|
If you have gtkdialog 8 or better here is an interesting script
that lists all your mounted partitions including USB.
It is based on the previous script.
The button simply puts a message on your screen but
it might be useful to a developer.
Here's a look at it. Home refers to the partition where
your pupsave file is located. It should also work with a full install,
but I haven't tested that configuration.
| Description |
remove fake gz extension to obtain script
|

Download |
| Filename |
drive-list.sh.gz |
| Filesize |
1.88 KB |
| Downloaded |
39 Time(s) |
|
|
Back to top
|
|
 |
R-S-H
Joined: 18 Feb 2013 Posts: 367
|
Posted: Sat 02 Mar 2013, 15:01 Post_subject:
|
|
Hi don570,
you are surely not only a "funny person" (remember?) you are surely a very kind person to show me a way how to get the unmounted drives in a seperate list?
Thanks
RSH
_________________ Freiheit für Mollath - JETZT !!!
Free Mr. Mollath !!!
Send the People responsible to The Hague International Court for trial !!!
|
|
Back to top
|
|
 |
don570

Joined: 10 Mar 2010 Posts: 2527 Location: Ontario
|
Posted: Sat 02 Mar 2013, 16:44 Post_subject:
|
|
'probepart' gives the full list. (Apparently related to 'partprobe command')
Then subtract my list from that list.
..but it's apparently buggy
http://bkhome.org/blog2/?viewDetailed=00094
I learned a lot about puppy when I put togeter 'report-system'
In my 'report-system' I looked for '/dev_save/'
to find which partition the pupsave file was stored.
| Code: | # PupSave file - LUCID or LAZY distro uses rootfs and unionfs
echo -e "\n========== $(gettext 'PupSave file') =========\n" >> /tmp/report-video
df -h > /tmp/top.tmp
sed -n '/dev_save/p' /tmp/top.tmp > /tmp/top.tmp2
sed -n '/unionfs/p' /tmp/top.tmp > /tmp/top.tmp3
if [ ! -s /tmp/top.tmp2 ] || [ ! -s /tmp/top.tmp3 ] ; then
echo -e "$(gettext 'PupSave file is not in use')\n" >> /tmp/report-video
else
...
|
Here is the code that detects which SFS packages are installed
| Code: |
# detect SFS files - code by James Budiono
if [ -n "`which losetup-FULL`" ]; then
echo -e "\n=========== $(gettext 'SFS files loaded') ============\n" >> /tmp/report-video
losetup-FULL -a | sed '/loop[0-3]:/ d;s_^.*/__;s/)$//' | sort >> /tmp/report-video
fi
|
|
|
Back to top
|
|
 |
don570

Joined: 10 Mar 2010 Posts: 2527 Location: Ontario
|
Posted: Mon 04 Mar 2013, 21:00 Post_subject:
version 1.4 of bulldog finder |
|
Version 1.4 of Bulldog finder uses this code to make a list of
mounted drives
http://murga-linux.com/puppy/viewtopic.php?t=78592
.
|
|
Back to top
|
|
 |
don570

Joined: 10 Mar 2010 Posts: 2527 Location: Ontario
|
Posted: Sat 09 Mar 2013, 15:42 Post_subject:
|
|
I made small change to script to recognize the partitions
in a full install.
| Description |
remove gz extension to obtain script
|

Download |
| Filename |
drive-list2.sh.gz |
| Filesize |
1.89 KB |
| Downloaded |
30 Time(s) |
|
|
Back to top
|
|
 |
|