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 Wed 16 Apr 2014, 01:30
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
Zenity/Yad and scripts
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 5 [66 Posts]   Goto page: 1, 2, 3, 4, 5 Next
Author Message
technosaurus


Joined: 18 May 2008
Posts: 4133

PostPosted: Sun 01 Aug 2010, 14:47    Post subject:  Zenity/Yad and scripts  

The zenity project had gone stale until Victor Ananjevsky forked it to add some patches and produce Yet Another Dialog. It no longer depends on deprecated libraries like libglade or gnome-canvas (just gtk2)

Zenity is still used in many *buntu scripts so I compiled Yad and made a symlink for zenity.

Here is a simple example:
Code:
#! /bin/bash
XTERM="xterm"
# create history file
mkdir -p ${XDG_CACHE_HOME:-$HOME/.cache}/
HISTFILE=${XDG_CACHE_HOME:-$HOME/.cache}/ix-run.history
touch $HISTFILE
# create and run dialog
TITLE="Run command"
TEXT="\nEnter command to execute:\n"
CMD='yad --width=500 --center --window-icon="gtk-execute" --name="${0##*/}" --title="$TITLE" --text="$TEXT" --image="gtk-execute" --entry --editable'
ARGS=$(perl -pe 's/(^.*$)/"\1"/;s/\n/ /' $HISTFILE)
rcmd=$(eval $CMD $ARGS)
[[ -z "$rcmd" ]] && exit 0
# run command
case $rcmd in
    http://*|https://*|ftp://*)
        xdg-open $rcmd &
        ;;
    mailto://*)
        xdg-email $rcmd &
        ;;
    man://*)
        eval $XTERM -e "man ${rcmd#man://}" &
        ;;
    telnet*|ssh*)
        eval $XTERM -e "$rcmd" &
        ;;
    *)
        eval $rcmd &
        ;;
esac
# add command to history
grep -q -F "$rcmd" $HISTFILE || echo $rcmd >> $HISTFILE
exit 0


more examples here:
http://code.google.com/p/yad/w/list
or use an of the many zenity examples
yad-0.13.0-i486.pet
Description  this is actually v0.13.0+some svn bugfixes
pet

 Download 
Filename  yad-0.13.0-i486.pet 
Filesize  43.36 KB 
Downloaded  650 Time(s) 
yad-0.3.1-i486.pet
Description 
pet

 Download 
Filename  yad-0.3.1-i486.pet 
Filesize  25.45 KB 
Downloaded  948 Time(s) 
run_command.png
 Description   screenshot of example
 Filesize   14.75 KB
 Viewed   5758 Time(s)

run_command.png


_________________
Web Programming - Pet Packaging 100 & 101

Last edited by technosaurus on Thu 01 Sep 2011, 16:09; edited 1 time in total
Back to top
View user's profile Send private message 
technosaurus


Joined: 18 May 2008
Posts: 4133

PostPosted: Sat 30 Oct 2010, 18:52    Post subject:  

new version for wary puppy (with zenity symlink)
yad_NLS-0.5.2-i486.pet
Description 
pet

 Download 
Filename  yad_NLS-0.5.2-i486.pet 
Filesize  13.44 KB 
Downloaded  749 Time(s) 
yad-0.5.2-i486.pet
Description 
pet

 Download 
Filename  yad-0.5.2-i486.pet 
Filesize  26.62 KB 
Downloaded  802 Time(s) 

_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send private message 
stu90


Joined: 25 Feb 2010
Posts: 1401
Location: England. Dell Inspiron 1501. Dpup

PostPosted: Sun 20 Feb 2011, 08:59    Post subject:  

updated below.
Last edited by stu90 on Mon 21 Feb 2011, 09:05; edited 1 time in total
Back to top
View user's profile Send private message 
stu90


Joined: 25 Feb 2010
Posts: 1401
Location: England. Dell Inspiron 1501. Dpup

PostPosted: Mon 21 Feb 2011, 09:02    Post subject:  

Ok here is a .pet for yad-0.8.1
yad-0.8.1-i486.pet
Description 
pet

 Download 
Filename  yad-0.8.1-i486.pet 
Filesize  38.83 KB 
Downloaded  766 Time(s) 
Back to top
View user's profile Send private message 
abushcrafter


Joined: 30 Oct 2009
Posts: 1447
Location: England

PostPosted: Mon 21 Feb 2011, 16:18    Post subject:  

stu90 wrote:
Ok here is a .pet for yad-0.8.1
Compiled in which Puppy version?
_________________
adobe flash is rubbish!
My Quote:"Humans are stupid, though some are clever but stupid." http://www.dependent.de/media/audio/mp3/System_Syn_Heres_to_You.zip http://www.systemsyn.com/
Back to top
View user's profile Send private message Visit poster's website 
playdayz


Joined: 25 Apr 2008
Posts: 3788

PostPosted: Mon 21 Feb 2011, 20:09    Post subject:  

stu90, Talk about immediately useful stu90--I just used this in wine to run winetricks with a better ui--and it saved 300KB over zenity. Thanks.

http://www.murga-linux.com/puppy/viewtopic.php?p=497570#497570
Back to top
View user's profile Send private message 
seaside

Joined: 11 Apr 2007
Posts: 878

PostPosted: Wed 23 Feb 2011, 11:44    Post subject: Yad
Subject description: Toolbar example
 

After looking at the Yad documentation, I saw some features that I was looking for in other dialogs and found missing - the ability to select multiple items. So I checked out some of the features and put together a small, scrollable toolbar to create, add, delete, and start favorite programs. When you press "add" it gives you a list of your *.desktop files, where you can select multiple items for your "toolbar" favorites (and the same process in reverse by pressing "delete"). You can size and place the dialog with the --geometry option.

Note that icons only appear for *.desktop files that contain the actual path.

Yad seems to be somewhere between Xdialog and Gtkdialog3, providing several useful features such as forms, multiple selection, notifications and more. I couldn't get the Filelist widget in forms to work in multiple selection mode, but maybe I missed something.

It seems a good tool for constructing useful projects.

Cheers,
s

Code:

#!/bin/sh

TOOLBAR="/root/.toolbar"

[ ! -d $TOOLBAR ] && mkdir $TOOLBAR

yad  --title="Toolbar (double-click to run)" --center --icons --read-dir="$TOOLBAR" --button="gtk-add:0" --button="gtk-delete:2" --button="gtk-cancel:1"
CHOICE=$?
[ $CHOICE -eq 0 ] && SEL=`ls /usr/share/applications  | cut -d. -f1 | yad --separator=" " --height=300 --list --multiple --column="files"` && for i in $SEL;do ln -s /usr/share/applications/$i.desktop $TOOLBAR/$i.desktop; done
[ $CHOICE -eq 1 ] && exit 0
[ $CHOICE -eq 2 ] && DEL=`ls $TOOLBAR | cut -d. -f1 | yad --separator=" " --height=300 --list --multiple --column="files"` && for i in $DEL;do rm -f $TOOLBAR/$i.desktop; done

exec $0
toolbar.png
 Description   toolbar for favorites
 Filesize   20.07 KB
 Viewed   5028 Time(s)

toolbar.png

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


Joined: 25 Feb 2010
Posts: 1401
Location: England. Dell Inspiron 1501. Dpup

PostPosted: Wed 23 Feb 2011, 20:59    Post subject:  

abushcrafter:
it was compiled on lucid puppy.

Playdayz:
glad to be of help - i think one could probably get yad even abit smaller if it wasn't a noob like me compiling and leaving in uneeded file.

seaside:
I had a similar idea about yads use as an application launcher.
http://www.murga-linux.com/puppy/viewtopic.php?t=65011

cheers. Cool
Back to top
View user's profile Send private message 
seaside

Joined: 11 Apr 2007
Posts: 878

PostPosted: Thu 24 Feb 2011, 14:01    Post subject:  

stu90 wrote:


seaside:
I had a similar idea about yads use as an application launcher.
http://www.murga-linux.com/puppy/viewtopic.php?t=65011

cheers. Cool


Stu90,

I downloaded "Pap" and see it makes it's own *.desktop files (instead of reusing the standard puppy's, like my lazy approach). Since "Pap" provides for a customized program name and icon, it makes for a much nicer appearance.

Since most of Puppy's *.desktop icon paths rely on the window manager to find, using "TOOLBAR" would require editing many of the *.desktop files with the full icon path in order to have them appear in the window. (Hmmm. if only there were some way to tap into the icon path) Smile

Regards,
s
Back to top
View user's profile Send private message 
stu90


Joined: 25 Feb 2010
Posts: 1401
Location: England. Dell Inspiron 1501. Dpup

PostPosted: Thu 24 Feb 2011, 15:15    Post subject:  

Hi seaside,
I have updated pap to version 2 (script is in the second post on the PaP thread) you need to create a directory in root called /root/pap and inside that directory a new directory for each panel.

For instance with the example panels that are in the pap v2 script, you would need directories:
/root/pap/pap-app
/root/pap/pap-desktop
/root/pap/pap-setup
/root/pap/pap-system

You can have any number of panels (line 6 of script) as long as they have a corresponding directory of the same name in /root/pap.

Maybe it wold be more straight forward just to package into a pet with several pre defined panels?

I looked at using existing desktop icons but found as you did them to be inconsistent, many missing full icon paths - perhaps PaP Add application could be addapted and used to edit existing desktop files?

cheers.
Back to top
View user's profile Send private message 
seaside

Joined: 11 Apr 2007
Posts: 878

PostPosted: Thu 24 Feb 2011, 16:42    Post subject:  

stu90 wrote:
Hi seaside,

Maybe it wold be more straight forward just to package into a pet with several pre defined panels?

I looked at using existing desktop icons but found as you did them to be inconsistent, many missing full icon paths - perhaps PaP Add application could be addapted and used to edit existing desktop files?

cheers.


stu90,

One way might be.... to add a button "Add Application From Menus" and then offer a Filelist and text box which loads the selected *.desktop file for editing. The "name" "exec" and "icon" entries could be changed (well, probably not the exec) and then saved as a new "PaP" *.desktop file.

As to pre-populating panels, you'd probably run into path, progams and icon variability among pups.

Regards,
s
Back to top
View user's profile Send private message 
seaside

Joined: 11 Apr 2007
Posts: 878

PostPosted: Thu 24 Feb 2011, 23:45    Post subject:  

stu90,

You could slip this code in which would ask for a *.desktop file and then populate the editor.
Code:
addap="/tmp/addap"
panels='pap-app!pap-setup!pap-desktop!pap-system' # single for !

DESK=`ls /usr/share/applications  | yad --separator=" " --height=300 --list --column="files"`

for line in /usr/share/applications/$DESK;do
eval `grep -E '^Name|^Icon|^Exec' "$line" | tr " " "_"` # no spaces
done

yad --title "PaP - Add Application " --width=500 --form --separator='|' \
--text "                                 Add new applications to the panels.   " \
--field="Panel Choice":CB "$panels" \
--field="Application Name" "$Name" \
--field="Application Icon"  "$Icon" \
--field="Application Executable" "$Exec" \
--icons --button="gtk-cancel:1" --button="gtk-ok:2"  > $addap


Cheers,
s
Back to top
View user's profile Send private message 
stu90


Joined: 25 Feb 2010
Posts: 1401
Location: England. Dell Inspiron 1501. Dpup

PostPosted: Fri 25 Feb 2011, 11:36    Post subject:  

Thanks Seaside, i have added it into update v3 in the other thread.

cheers.
Back to top
View user's profile Send private message 
stu90


Joined: 25 Feb 2010
Posts: 1401
Location: England. Dell Inspiron 1501. Dpup

PostPosted: Wed 09 Mar 2011, 12:57    Post subject:  

update to yad-0.9.0
yad-0.9.0-i486.pet
Description 
pet

 Download 
Filename  yad-0.9.0-i486.pet 
Filesize  34.05 KB 
Downloaded  644 Time(s) 
Back to top
View user's profile Send private message 
Makoto


Joined: 03 Sep 2009
Posts: 1722
Location: Out wandering... maybe.

PostPosted: Fri 11 Mar 2011, 18:27    Post subject:  

Does Yad require Puppy 5, more or less, or can it be compiled for Puppy 4? I'm just wondering, because I've seen implications it requires newer versions of certain libs, that just aren't present (and not easily upgradable ones, like perhaps glib) in Puppy 4.
_________________
[ Puppy 4.3.1 JP, Frugal install | 1GB RAM | 1.3GB swap ] * My Pidgin Builds for Puppy 4.3.1+
In memory of our beloved American Eskimo puppy (1995-2010) and black Lab puppy (1997-2011).
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 5 [66 Posts]   Goto page: 1, 2, 3, 4, 5 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.0948s ][ Queries: 13 (0.0075s) ][ GZIP on ]