Page 1 of 4

Zenity/Yad and scripts

Posted: Sun 01 Aug 2010, 18:47
by technosaurus
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: Select all

#! /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

Posted: Sat 30 Oct 2010, 22:52
by technosaurus
new version for wary puppy (with zenity symlink)

Posted: Sun 20 Feb 2011, 12:59
by stu90
updated below.

Posted: Mon 21 Feb 2011, 13:02
by stu90
Ok here is a .pet for yad-0.8.1

Posted: Mon 21 Feb 2011, 20:18
by abushcrafter
stu90 wrote:Ok here is a .pet for yad-0.8.1
Compiled in which Puppy version?

Posted: Tue 22 Feb 2011, 00:09
by playdayz
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/viewto ... 570#497570

Yad

Posted: Wed 23 Feb 2011, 15:44
by seaside
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: Select all

#!/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

Posted: Thu 24 Feb 2011, 00:59
by stu90
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. 8)

Posted: Thu 24 Feb 2011, 18:01
by seaside
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. 8)
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) :)

Regards,
s

Posted: Thu 24 Feb 2011, 19:15
by stu90
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.

Posted: Thu 24 Feb 2011, 20:42
by seaside
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

Posted: Fri 25 Feb 2011, 03:45
by seaside
stu90,

You could slip this code in which would ask for a *.desktop file and then populate the editor.

Code: Select all

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

Posted: Fri 25 Feb 2011, 15:36
by stu90
Thanks Seaside, i have added it into update v3 in the other thread.

cheers.

Posted: Wed 09 Mar 2011, 16:57
by stu90
update to yad-0.9.0

Posted: Fri 11 Mar 2011, 22:27
by Makoto
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.

Posted: Sat 12 Mar 2011, 01:38
by stu90
Makoto wrote: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.
hello Makoto,
I don't use any of the older puppies so i am not sure?
Maybe try compiling it, i used the instructions posted by Technosaurus here:
http://murga-linux.com/puppy/viewtopic.php?t=35507

stu90 avatars

Posted: Sat 12 Mar 2011, 03:42
by cowboy
stu90,

sorry to intrude on the thread, and I truly apologize. But the rotating avatars are hilarious. 70's British sit-coms actors? right?

Posted: Sat 12 Mar 2011, 23:33
by Makoto
I was wondering, somewhat, if technosaurus or someone else might know, offhand, whether or not it links to glib or anything else of the sort. The website and documentation in the yad archive only mentions GTK 2.16 or higher as a dependency... not that I can recall what version of GTK2 is used by default in 4.3.1. :|

If it's not dependent upon glib or anything else like that, maybe the installs posted in this topic would work for me, as well. (I'd compile it myself, but I'm a little weary of trying to compile things at the moment... a little too much time spent tracking down dependencies. :lol: )

Posted: Sun 13 Mar 2011, 03:43
by technosaurus
All gtk deps are automatically included when you link it.

It can do the final link with -lgtk-x11-2.0 only ... the dynamic linker does the rest
I normally use the as-needed flag to allow backwards compat

4.3.x uses 2.14.7, AFAICT 2.16.6 is the last version without many annoying bugs - my pet is available somewhere in the forum, or try one of Barry's later versions with some workarounds.

It takes 1 min to download and compile and has no deps that are not in the devx... i'd do it but only have my Droid right now... for another week or so.

Posted: Sun 13 Mar 2011, 04:41
by Makoto
Wouldn't I have to update glib, too, if I updated GTK2 to 2.16? I'm remembering from this topic how those that tried upgrading to 2.16 might have problems with a scrambled desktop (and you said you'd created one of the update pets before recalling the insert-key-kills-Seamonkey bug, too, I believe), as well.

...of course, others reading that topic will notice I asked about the version of GTK2 used in Puppy 4.3.1 there, too, a while back. :) (I'd just prefer it if there was an easy way to tell the version... there's plenty of search engine links telling you it's extremely easy to do; all you have to do is check the Ubuntu package manager... :roll: :D)