YAD - Tips

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Message
Author
User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#381 Post by MochiMoppel »

Hi Fred,
nice, and using yad it's (still) very compact. Reminds me of dejan555's Simple GTK Radio, which is based on gtkdialog and kept me busy customizing many moons ago.
I made some code changes for my personal use and now it looks as in the screenshot (I wanted it to look like an old fashioned car radio). It has a recording function and some other features, but basically it works very similar to your yad version.

One suggestion: I find the "Failed to connect" dialog pretty annoying since it needs to be closed manually and it appears frequently as many small stations are frequently off. In SGR the problem is solved by - doing nothing. No message, no dialog. If I can't connect to a station within a reasonable time I move on to the next station.
Attachments
Simple_GTK_Radio.png
MochiMoppel's adaption of dejan555's Simple GTK Radio
(30.88 KiB) Downloaded 1200 times

stemsee

#382 Post by stemsee »

musher0 wrote:Euh... Fredx?
You do with your time what you will of course. If your radio app above is practice
for becoming an even greater yad virtuoso than you are already, that's fine.
Otherwise ....
musher0 .... I am curious, if Fred is programming yadradio for another reason other than the one you mention then you imply that it isn't ok. Why isn't it ok? What psychosis compels you to publish your judgement? If it's because you think Fred doesn't know why he does these things, then that's fine .... otherwise you're probably better off pouring your energy into writing better apps too! Don't you think?

Just a thought.
stemsee

User avatar
fredx181
Posts: 4448
Joined: Wed 11 Dec 2013, 12:37
Location: holland

#383 Post by fredx181 »

@mochimoppel
nice, and using yad it's (still) very compact. Reminds me of dejan555's Simple GTK Radio, which is based on gtkdialog and kept me busy customizing many moons ago.
Thanks for testing.
Yes, compactness was my goal, but still yad is very limited compared to gtkdialog of course (unfortunately I'm really no good with gtkdialog programming :( ), looks very nice your Simple GTK Radio mod ! I'm jealous :wink:

@stemsee
I may have misunderstood your earlier question:
how does the selected item (BBC) get read
Currently in yradio the output of --select-action outputs only the first part (URL only )
(and in function add_fav it does a grep for that to find the station name (BBC ...))
But I found by changing function sel_file to:

Code: Select all

function sel_file
{
echo -en "$1\n$2\n$3" | tr '\n' '|' > $LAUNCHDIR/tmp/sel-file   # full output
# echo $1 > $LAUNCHDIR/tmp/sel-file
#  xdg-open "$1" &> /dev/null
}
export -f sel_file
It gives the full output that way in tmp/sel-file , e.g.:

Code: Select all

http://bbcmedia.ic.llnwd.net/stream/bbcmedia_radio1_mf_p|BBC Radio 1 United Kingdom|Hits
So that would be better (but function add_fav needs also modified (simplified) then)

Fred

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#384 Post by MochiMoppel »

fredx181 wrote:

Code: Select all

echo -en "$1\n$2\n$3" | tr '\n' '|' > $LAUNCHDIR/tmp/sel-file
Should also work:

Code: Select all

echo -n "${1}|${2}|${3}" > $LAUNCHDIR/tmp/sel-file

User avatar
fredx181
Posts: 4448
Joined: Wed 11 Dec 2013, 12:37
Location: holland

#385 Post by fredx181 »

MochiMoppel wrote:
fredx181 wrote:

Code: Select all

echo -en "$1\n$2\n$3" | tr '\n' '|' > $LAUNCHDIR/tmp/sel-file
Should also work:

Code: Select all

echo -n "${1}|${2}|${3}" > $LAUNCHDIR/tmp/sel-file
Ah, yes works also, better solution (compact :wink: ), thanks.

mfb

#386 Post by mfb »

musher0's post from above is reproduced below in the first screen shot.

stemsee subsequently enquired, perhaps charitably, amongst other questions to musher0,
What psychosis compels you to publish your judgement?
The second screen shot comes courtesy of the Canadian Mental Health Association and suggests a likely explanation for yet another example of disgraceful behaviour from musher0.
Attachments
A few posts above quote.png
(66.77 KiB) Downloaded 1024 times
CMHA quote.png
(100.68 KiB) Downloaded 1016 times

Sailor Enceladus
Posts: 1543
Joined: Mon 22 Feb 2016, 19:43

#387 Post by Sailor Enceladus »

I wonder where they come up with these numbers. Only 8% experience major depression? That's only around 1 in 12 people. I'm pretty sure it's closer to 100%, maybe they meant 80%. Need to research this more I think...

stemsee

#388 Post by stemsee »

Mental Health issues are very common ... more than acknowledged or citable ... simply because there is no norm to rate against. Of course each one of us thinks we are normal ... but the happy truth is that there is no normal. What there is is a flux and dynamic equilibrium, which easily beomes unbalanced in isolation. Best remedy is to volunteer and become part of a real physical group. Being unendingly on a computer is too unreal and inhuman, there must be daily interaction, no matter how mundane, with other real human beings, not their virtual manifestations ... get out and about, if possible.

Mental Health problems are everywhere and touch everyone, to some degree ... it is the degree which needs control. Our societies actually promote isolation, more so in 1st world than 2nd and 3rd world socieities. The continuous cerebral preoccupation with detail and trivia is driving us to a wider degree of undetectable inbalance! Instead of behaving naturally, we behave calculatedly, this is the way we acheive a seemingly normal pattern of behaviour when sharing communal spaces, but for short periods of time only. When in isolation these calculations need only be slightly out, and will be detectable if with semi-permanence put in writing, and much more noticable to others too. I blame the governments and media pressure that try to force us to conform uniformly to the commercial objectives of societal behaviourism. My conclusion is, that the more intelligent you are, the more likely you will suffer from mental health issues, as you waste your computing power on calculating average behaviour, instead of behaving naturally, albeit unacceptably.

imho

I should write a program using yad to measure one's deviance.

stemsee

User avatar
fredx181
Posts: 4448
Joined: Wed 11 Dec 2013, 12:37
Location: holland

#389 Post by fredx181 »

Hi all, learning about use of "--cycle-read" in --form, found about it here:
https://groups.google.com/forum/#%21msg ... WgA0VoBQAJ
and here;
https://groups.google.com/forum/#%21top ... vXl3Xf40r0

But these examples are only for to update one field, but I wanted a form with multiple fields, update first field and keep the others "intact", here's simple example to demonstrate.
The trick is to set all the fields first (3 in this example), then when updating first field (while loop), by adding e.g. "echo "" >&3" for the other remaining fields.

Code: Select all

export pipe="/tmp/test-cycle-read.$RANDOM"
mkfifo "$pipe"
exec 3<> $pipe
echo "Hello World" > test  # Initial text, run e.g:  "echo foo > test" to change displaying text
READ=$(cat test 2> /dev/null)
echo "$READ"  >&3
echo 'bash -c "rox"'  >&3
echo 'bash -c "geany"' >&3

while true; do
NEWREAD=$(cat test 2> /dev/null)
if [ "$NEWREAD" != "$READ" ]; then
   echo "$NEWREAD"  >&3  # first field, new read from 'test' file
   echo ""  >&3    # bash -c "rox"
   echo "" >&3     # bash -c "geany"
READ=$NEWREAD
fi

sleep 2
done &

yad --title="Cycle Test" --form --cycle-read --field ": " --field="Rox:fbtn" --field="Geany:fbtn" <&3
Now while this is running, just replace the text inside 'test', e.g.

Code: Select all

echo "My Text" > test
And it will be display it in the first field text of the yad dialog.

Fred
Attachments
yad-cycle-read-form.gif
Cycle-read for form
(163.8 KiB) Downloaded 834 times

wiak
Posts: 2040
Joined: Tue 11 Dec 2007, 05:12
Location: not Bulgaria

#390 Post by wiak »

musher0 wrote:Euh... Fredx?

You do with your time what you will of course. If your radio app above is practice
for becoming an even greater yad virtuoso than you are already, that's fine.

Otherwise, why go through the trouble? There already exist a host of good radio
players on Linux: aqualung, deadbeef, mplayer,mpv, etc.

Just a thought.
I think it's a fair question, musher, and nothing to do with anyone's 'mental health' per say, except that all 'hobby-like' activities are probably undertaken for the pleasure derived in such. Different people no doubt have different motives for undertaking any kind of programming work. There are certainly usually plenty of alternatives out there nowadays, but that shouldn't mean we suddenly stop trying to do our own thing - particularly if we can achieve something slightly different. In the Puppy world it has always been the case that 'small' applications that provide a lot of functionality in a small footprint have been an important driving force.

It may be argued that even 'oldish' computers nowadays have sufficient resources available to them that size etc no longer matters at all to any important degree. Still, old habits die slowly, and there remains an attraction, it seems to me, to try and make tiny or small systems and that's where gtkdialog and yad-type apps come in (plus that it is relatively easy to program with them, whereas the likes of C++ and gtk or Qt, and even Python (and its extensive libs) are complicated to learn and use comparatively).

Aqualung and so on can certainly do the job but, as Fred has shown with Dog Radio, sometimes one of these tiny yad or gtkdialog-based apps has an appealing frugality, convenience and charm - perhaps because that old UNIX philosophy of designing a tool that only does one job but does it well is refreshing in this world of over-the-top-often-unnecessary-and-stressful-complexity.

But yeah, sometimes I wonder why we don't just all abandon small Linux distributions altogether since the larger offerings have most every facility available on tap anyway (in any shape or size or form). But small definitely sometimes means 'more efficient' - from a user point of view, that certainly depends on the user-interface provided though.

I haven't myself put much effort at all into learning yad, which is not a comment against yad, just that I've stuck to what I know a little of, which is gtkdialog with bash. The only thing is, I don't know who is likely to maintain gtkdialog for the future, whereas yad development appears to remain active.

Might be nice to become specialists in other programming languages such as Genie, Vala, Bacon, C etc (or even scripting ones such as Python, or small Lua) but still have to have some sort of graphical user interface toolkit to go along with the main programming language you are using. For bash, yad or gtkdialog are making that part of the programming effort relatively easy. Funnily enough early Pups came with John Murga's slant on Lua with a modified FLTK toolkit for graphics - I can't help feeling it is a shame that was left out of later Pups actually...

Despite John Murga not going with it in his early Lua/Puppy implementation, I still think this apparently simple-to-program multi-platform toolkit (IUP), for Lua, or C, sounds very interesting. It's been around for over 20 years (!) and is still actively being maintained. I guess I should try it:

http://webserver2.tecgraf.puc-rio.br/iup/

https://webserver2.tecgraf.puc-rio.br/iup/en/led.html

https://webserver2.tecgraf.puc-rio.br/i ... lkits.html

or... ?

http://www.murga-projects.com/forum/sho ... hp?tid=429
But is murga Lua still being maintainted??? Seems not?

I've started a thread for possible further discussion of IUP in following link, in case anyone starts using this in any productive way on Puppy-related distros. I can program in C, but only very little experience in using gtk+ with that, but have always had a desire to try Lua since I think a scripting language is best for small distro utils/app development work (since others can easily modify such work, without having that compile-need burden inbetween) - but need a simple graphical toolkit for such work (and Lua itself, unlike Python, is light enough to include in a small distro by default):

http://www.murga-linux.com/puppy/viewtopic.php?t=113013

wiak

User avatar
fredx181
Posts: 4448
Joined: Wed 11 Dec 2013, 12:37
Location: holland

#391 Post by fredx181 »

See new YRadio version here:
http://murga-linux.com/puppy/viewtopic. ... 591#986591
(merged with "Dogradio and YRadio" thread)

Why ??
My interest in exploring new yad options, (e.g. --cycle-read and --paned) and attempting to provide a simple and lightweight internet radio player.

Fred

User avatar
misko_2083
Posts: 114
Joined: Tue 08 Nov 2016, 13:42

#392 Post by misko_2083 »

fredx181 wrote:See new YRadio version here:
http://murga-linux.com/puppy/viewtopic. ... 591#986591
(merged with "Dogradio and YRadio" thread)

Why ??
My interest in exploring new yad options, (e.g. --cycle-read and --paned) and attempting to provide a simple and lightweight internet radio player.

Fred
Freddy, you've been a busy puppy since my last login. :)
If I may suggest that you put that "Update Index" button somewhere else. 4 out of five times I clicked that button instead of "Load". :oops:

I would add pulse audio volume control in a popup window.
The only trouble is positioning these windows for all the monitor resolutions can be tricky. Also not sure which previous versions of yad support these kind of windows.
Attachments
yradio.fake.tar
(22.94 KiB) Downloaded 181 times

User avatar
fredx181
Posts: 4448
Joined: Wed 11 Dec 2013, 12:37
Location: holland

#393 Post by fredx181 »

misko_2083 wrote:Freddy, you've been a busy puppy since my last login. Smile
Yeah, sure, but you should check here more often, MiskY ! :)
I would add pulse audio volume control in a popup window.


Many thanks, nice to have volume control, however... most puppy (and 'dog') systems don't have pulseaudio by default, just alsa.
Do you think something like you did that can work with just alsa ?
Works fine for me, but first had to install pulseaudio and also "gawk" (had only "mawk" installed, setting the volume didn't work with that (EDIT, I *think* also not with busybox awk)).

Best regards, and thanks again,

EDIT: YRadio also on github now:
https://github.com/fredx181/yradio

Fred

april

#394 Post by april »

Thought I'd have a look . Found it in /root
Found on xenialpup64 I did not have mplayer installed
Bum...Have no download capacity atm ,very expensive out here on the reef.

User avatar
rufwoof
Posts: 3690
Joined: Mon 24 Feb 2014, 17:47

#395 Post by rufwoof »

fredx181 wrote:Many thanks, nice to have volume control, however... most puppy (and 'dog') systems don't have pulseaudio by default, just alsa.
Do you think something like you did that can work with just alsa ?
Works fine for me, but first had to install pulseaudio and also "gawk" (had only "mawk" installed, setting the volume didn't work with that (EDIT, I *think* also not with busybox awk)).
Nowadays I just map Win key (special left) plus the up/down arrow keys to incrementally raise/lower the volume. Right menu to present the default menu (up and down arrows to navigate the menu) ... etc.

User avatar
misko_2083
Posts: 114
Joined: Tue 08 Nov 2016, 13:42

#396 Post by misko_2083 »

fredx181 wrote:
misko_2083 wrote:Freddy, you've been a busy puppy since my last login. Smile
Yeah, sure, but you should check here more often, MiskY ! :)
Didn't have the time to "sit" by the computer.

"MiskY", that's how my nephew used to call me when he was little. :)

No idea why Marc Conta called me "Manow" (see the screenshot bellow). :D I never heard of such name. :D
fredx181 wrote: Many thanks, nice to have volume control, however... most puppy (and 'dog') systems don't have pulseaudio by default, just alsa.
Do you think something like you did that can work with just alsa ?
Works fine for me, but first had to install pulseaudio and also "gawk" (had only "mawk" installed, setting the volume didn't work with that (EDIT, I *think* also not with busybox awk)).
Here is alsa version. *Requires alsa-utils.
Attachments
yradio.fake.tar
(22.41 KiB) Downloaded 163 times
TheMagnificentManow.png
(12.11 KiB) Downloaded 973 times

User avatar
fredx181
Posts: 4448
Joined: Wed 11 Dec 2013, 12:37
Location: holland

#397 Post by fredx181 »

misko_2083 wrote:Here is alsa version. *Requires alsa-utils.
Thanks again Miskey ! :wink:

I changed the CURVOL variable (check for pid of pulseaudio)
How it was, the current volume shows 0 for me if pulseaudio is not running.
Now works in both cases from what I tested (also with alsa only).

Code: Select all

# CURVOL=$(echo ${vol[4]} | sed 's/[][%]//g')
# fredx181, check if pulseaudio is running, set CURVOL accordingly.
[ $(pidof pulseaudio) ] && CURVOL=$(echo ${vol[4]} | sed 's/[][%]//g') || CURVOL=$(echo ${vol[3]} | sed 's/[][%]//g')
Added volume control in v0.0.5:
https://github.com/fredx181/yradio/archive/master.zip

Image

Fred

stemsee

#398 Post by stemsee »

Alsa version with VLC option (chkbox) would be ideal!

Hi MiskY

I called you Manow as a guess because your 'handle' seemed to be in the cyrillic alphabet, which I recalled poorly! ;-)

apologies
stemsee

User avatar
misko_2083
Posts: 114
Joined: Tue 08 Nov 2016, 13:42

#399 Post by misko_2083 »

fredx181 wrote:I changed the CURVOL variable (check for pid of pulseaudio)
How it was, the current volume shows 0 for me if pulseaudio is not running.
Now works in both cases from what I tested (also with alsa only).
Very good Fred.
stemsee wrote:I called you Manow as a guess because your 'handle' seemed to be in the cyrillic alphabet, which I recalled poorly!
Well, at least you guessed the first letter right. :)
As the consolation prize you get a link to my wallpaper "Resting fox 1920x1080" on Deviant Art. :D https://misko-2083.deviantart.com/art/R ... -726774960
stemsee wrote:Alsa version with VLC option (chkbox) would be ideal!
It's possible to use use the checkbox for selection. However, in yad form dialogs, only button can be used as the trigger.
Maybe paned dialog is too much but if Fred thinks it is worth the trouble I have an example with the alsa volume control and the paned dialog that launch from a notification icon but this can be modified to launch from any button.

Now about the notification area and sticky windows: I've tried to position the alsa volume control (yad paned) dialog near the notification icon. Sometimes it is positioned correctly, sometimes not. Notification area can sometimes be positioned to the left/right (top and bottom panels) and top/bottom (vertical panels).The idea is to determine the zone in which the notification icon is activated. Clicking the notification area grabs the mouse position and calculates the relative position in which the window will be launched. The last action is to pass the coordinates where the dialog will open. I whish this is easier with yad. :D
Attachments
yad-alsa-notification.fake.tar
(4.83 KiB) Downloaded 173 times

User avatar
Mike Walsh
Posts: 6351
Joined: Sat 28 Jun 2014, 12:42
Location: King's Lynn, UK.

#400 Post by Mike Walsh »

@ Smokey01:-

Hi, Grant. Just wanted to say 'Thanks' for your brilliant YAD tutorial:-

http://smokey01.com/yad/

I was browsing t'interweb this evening, looking for some tips on using YAD, since I wanted to create a small 3-button selector box for my SoftMaker FreeOffice packages. LibreOffice, as you probably know, has the 'StartCenter'; you click on a single MenuEntry, and you then get access to the entire suite from that point on. FreeOffice doesn't have anything like that, so you end up with a whole bunch of .desktop entries.....which is rather untidy.

(I came across your tutorial almost by accident - I must have overlooked the multiple references to it in the Newsletter! - by alighting on this site:-

http://www.thelinuxrain.com/articles/the-buttons-of-yad

...and discovering that you'd been credited down the bottom, along with a link to the tutorial. So it seems you've got fans in more places than you realised..... :lol:)


-----------------------------------------------------------------------------

Anyway; I've ended up with this:-


Image


.....which resulted from the following script:-

Code: Select all

#!/bin/sh
#
#Selector for SoftMaker FreeOffice components: © Mike Walsh Apr 2018 - with thanks to Smokey01
#
yad --center --window-icon=/usr/local/lib/X11/pixmaps/office-2-icon.png --title="SoftMaker FreeOffice2016 StartCenter" --form --width=425 --text="SOFTMAKER FREEOFFICE2016 STARTCENTER
                                                                   
Please choose your desired office module:-" \
--image="/usr/local/lib/X11/pixmaps/office-2-icon.png" \
--field="TEXTMAKER (word processor)":fbtn "textmaker16free" \
--field="PLANMAKER (spreadsheet)":fbtn "planmaker16free" \
--field="PRESENTATIONS (slideshows, etc.)":fbtn "presentations16free" \
--no-buttons --close-on-unfocus
I've probably made an unholy mess of the order in which I've listed the various options.....but, for a first attempt at this kinda thing, I don't think it's turned out too bad. I went with the '--no-buttons' option, 'cos it tidied-up the appearance. I was intending to use the '--timeout' option, but got the idea for '--close-on-unfocus' from the comments section of the LinuxRain page, so went with that instead. Works nicely! It seems that if you use the bog-standard '--form' box then you have to clear it manually.....otherwise it'll still be there when you've finished using whatever app you used it to select in the first place..!

Cheers.

EDIT:- I get the impression '--close-on-unfocus' is a fairly new addition to YAD, because I'd recently compiled the newest version (40) for Slacko 570, which is where I'd been doing this. I'm slowly sym-linking the new stuff into the kennels from the remote data partition where they live, and I'm finding that most Pups won't run it:-

Code: Select all

Unable to parse option --close on-unfocus
So; time to re-compile the new version for all the other Pups!


Mike. :wink:
Last edited by Mike Walsh on Tue 03 Apr 2018, 14:45, edited 1 time in total.

Post Reply