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 Mon 15 Sep 2014, 05:55
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
Restrain COMBOBOX list
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [9 Posts]  
Author Message
don570


Joined: 10 Mar 2010
Posts: 3279
Location: Ontario

PostPosted: 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. Laughing
It's a very simple script. I'll show it in the next post.

Notice the quoting of
Code:
'"$(COMBOBOX)"'


This is the function that makes the list.


_______________________________________________

Last edited by don570 on Sat 04 Aug 2012, 15:47; edited 3 times in total
Back to top
View user's profile Send private message 
don570


Joined: 10 Mar 2010
Posts: 3279
Location: Ontario

PostPosted: 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 Laughing

________________________
build_list.sh.gz
Description  remove gz extension to obtain script
gz

 Download 
Filename  build_list.sh.gz 
Filesize  1.55 KB 
Downloaded  225 Time(s) 
Back to top
View user's profile Send private message 
don570


Joined: 10 Mar 2010
Posts: 3279
Location: Ontario

PostPosted: 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

build_list_alt.sh.gz
Description  remove gz extension to obtain the script
gz

 Download 
Filename  build_list_alt.sh.gz 
Filesize  1.45 KB 
Downloaded  225 Time(s) 
Back to top
View user's profile Send private message 
8-bit


Joined: 03 Apr 2007
Posts: 3368
Location: Oregon

PostPosted: Wed 22 Aug 2012, 13:49    Post subject:
Subject description: 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
View user's profile Send private message 
don570


Joined: 10 Mar 2010
Posts: 3279
Location: Ontario

PostPosted: 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.

drive-list.sh.gz
Description  remove fake gz extension to obtain script
gz

 Download 
Filename  drive-list.sh.gz 
Filesize  1.88 KB 
Downloaded  108 Time(s) 
Back to top
View user's profile Send private message 
R-S-H

Joined: 18 Feb 2013
Posts: 490

PostPosted: 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

_________________
LazY Puppy Home
The new LazY Puppy Information Centre

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


Joined: 10 Mar 2010
Posts: 3279
Location: Ontario

PostPosted: 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
View user's profile Send private message 
don570


Joined: 10 Mar 2010
Posts: 3279
Location: Ontario

PostPosted: 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
View user's profile Send private message 
don570


Joined: 10 Mar 2010
Posts: 3279
Location: Ontario

PostPosted: Sat 09 Mar 2013, 15:42    Post subject:  

I made small change to script to recognize the partitions
in a full install.
drive-list2.sh.gz
Description  remove gz extension to obtain script
gz

 Download 
Filename  drive-list2.sh.gz 
Filesize  1.89 KB 
Downloaded  103 Time(s) 
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [9 Posts]  
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.0869s ][ Queries: 13 (0.0079s) ][ GZIP on ]