Zenity/Yad and scripts

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Message
Author
User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

Zenity/Yad and scripts

#1 Post 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
Attachments
yad-0.13.0-i486.pet
this is actually v0.13.0+some svn bugfixes
(43.36 KiB) Downloaded 1564 times
yad-0.3.1-i486.pet
(25.45 KiB) Downloaded 1804 times
run_command.png
screenshot of example
(14.75 KiB) Downloaded 8528 times
Last edited by technosaurus on Thu 01 Sep 2011, 20:09, edited 1 time in total.
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#2 Post by technosaurus »

new version for wary puppy (with zenity symlink)
Attachments
yad_NLS-0.5.2-i486.pet
(13.44 KiB) Downloaded 1618 times
yad-0.5.2-i486.pet
(26.62 KiB) Downloaded 1678 times
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

stu90

#3 Post by stu90 »

updated below.
Last edited by stu90 on Mon 21 Feb 2011, 13:05, edited 1 time in total.

stu90

#4 Post by stu90 »

Ok here is a .pet for yad-0.8.1
Attachments
yad-0.8.1-i486.pet
(38.83 KiB) Downloaded 1577 times

User avatar
abushcrafter
Posts: 1418
Joined: Fri 30 Oct 2009, 16:57
Location: England
Contact:

#5 Post by abushcrafter »

stu90 wrote:Ok here is a .pet for yad-0.8.1
Compiled in which Puppy version?
[url=http://www.adobe.com/flashplatform/]adobe flash is rubbish![/url]
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/

User avatar
playdayz
Posts: 3799
Joined: Fri 25 Apr 2008, 18:57

#6 Post 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

seaside
Posts: 934
Joined: Thu 12 Apr 2007, 00:19

Yad

#7 Post 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
Attachments
toolbar.png
toolbar for favorites
(20.07 KiB) Downloaded 8002 times

stu90

#8 Post 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)

seaside
Posts: 934
Joined: Thu 12 Apr 2007, 00:19

#9 Post 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

stu90

#10 Post 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.

seaside
Posts: 934
Joined: Thu 12 Apr 2007, 00:19

#11 Post 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

seaside
Posts: 934
Joined: Thu 12 Apr 2007, 00:19

#12 Post 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

stu90

#13 Post by stu90 »

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

cheers.

stu90

#14 Post by stu90 »

update to yad-0.9.0
Attachments
yad-0.9.0-i486.pet
(34.05 KiB) Downloaded 1456 times

User avatar
Makoto
Posts: 1665
Joined: Fri 04 Sep 2009, 01:30
Location: Out wandering... maybe.

#15 Post 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.
[ Puppy 4.3.1 JP, Frugal install ] * [ XenialPup 7.5, Frugal install ] * [XenialPup 64 7.5, Frugal install] * [ 4GB RAM | 512MB swap ]
In memory of our beloved American Eskimo puppy (1995-2010) and black Lab puppy (1997-2011).

stu90

#16 Post 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

User avatar
cowboy
Posts: 250
Joined: Thu 03 Feb 2011, 22:04
Location: North America; the Western Hemisphere; Yonder

stu90 avatars

#17 Post 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?
[i]"you fix what you can fix and you let the rest go.."[/i] - Cormac McCarthy - No Country For Old Men.

User avatar
Makoto
Posts: 1665
Joined: Fri 04 Sep 2009, 01:30
Location: Out wandering... maybe.

#18 Post 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: )
[ Puppy 4.3.1 JP, Frugal install ] * [ XenialPup 7.5, Frugal install ] * [XenialPup 64 7.5, Frugal install] * [ 4GB RAM | 512MB swap ]
In memory of our beloved American Eskimo puppy (1995-2010) and black Lab puppy (1997-2011).

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#19 Post 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.
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

User avatar
Makoto
Posts: 1665
Joined: Fri 04 Sep 2009, 01:30
Location: Out wandering... maybe.

#20 Post 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)
[ Puppy 4.3.1 JP, Frugal install ] * [ XenialPup 7.5, Frugal install ] * [XenialPup 64 7.5, Frugal install] * [ 4GB RAM | 512MB swap ]
In memory of our beloved American Eskimo puppy (1995-2010) and black Lab puppy (1997-2011).

Post Reply