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

stemsee

#401 Post by stemsee »

@miskY

Beautiful artistic 'painting'. Which program did you use to achieve that? I have a friend called beverly greene who also has an account on deviantart.

How about a yad paint!?!

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

#402 Post by fredx181 »

Hi Mike Walsh,
Unable to parse option --close on-unfocus
I see a whitespace where it should be a dash, this works maybe ?

Code: Select all

--close-on-unfocus
Fred

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

#403 Post by Mike Walsh »

Hi, Fred.

Well spotted, mate. Actually, I didn't perform a copy/paste for that one; I simply typed it in from memory.....and forgot one of the '-' symbols.

*smacked wrist* Bad Mike..! :lol:

But that definitely is a recent addition; it wasn't working in Precise 571, where I've been using v36.0 for some little while.....it simply doesn't recognise it.


Mike. :wink:

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

#404 Post by fredx181 »

Mike Walsh wrote:Actually, I didn't perform a copy/paste for that one; I simply typed it in from memory.....and forgot one of the '-' symbols.
Ah, I see,
I did a little digging and I think the --close-on-unfocus option was added from 0.37 on.

Fred

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

#405 Post by misko_2083 »

stemsee wrote:@miskY

Beautiful artistic 'painting'. Which program did you use to achieve that? I have a friend called beverly greene who also has an account on deviantart.

How about a yad paint!?!
I use Gimp mostly.
Making a paint application with yad is impossible.
Maybe some basic image manipulation like resizing and rotating or color efects can be scripted.

Those are more usefull with the file managers via context (right-click) menu.
https://ubuntu-mate.community/t/rotate- ... -menu/8762

stemsee

#406 Post by stemsee »

Well I know it is impossible ... but this is yad tips, afterall!
BTW
could you explain how NOTIF_ICON=$?
wait $NOTIF_ICON
functions and where else it can be used for example yad --list &

cheers
stemsee

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

#407 Post by misko_2083 »

stemsee wrote:Well I know it is impossible ... but this is yad tips, afterall!
BTW
could you explain how NOTIF_ICON=$?
wait $NOTIF_ICON
functions and where else it can be used for example yad --list &

cheers
stemsee
Yes certainly.
you probably ment these lines from the previous script. I needed to set the icon only after the notification icon appears.

Code: Select all

# Calls yad notification icon that listens on stdandard input.
# the process starts in the background & so the script can continue
# File descriptor 3 is redirected to standard input <&3
# notifpid=$! - The process id is stored in a variable notifpid
yad --notification --command="bash -c 'YAD_AUDIO_audio'" \
 --listen <&3 & notifpid=$!
# Script continues...

# Needed to set the notification icon, that is only possible
# when the notification finish loading
# xdotool search --pid "$notifpid" - finds the window id based on the process id
# xdotool getwindowname $window_id - returns the window name
# Untill there is a window name do --> sleep 1
until xdotool getwindowname $(xdotool search --pid "$notifpid" 2>/dev/null | tail -1) &>/dev/null; do
        # sleep until the window opens
        sleep 1       
done

# Window is ready, time to set the intitial volume icon
# We call the function "get_volume" that returns CURVOL variable
get_volume
# Redirects stdout to file descriptor 3
set_notification_icon $(printf "%3d" "$CURVOL") >&3

# Now when that is done, we can wait for the process with the id $notifpid to finish
wait $notifpid
# wait also returns the exit status of the yad notification
# We can check the exit status
echo $?

#Script continues...
This can be used with the lists also, but can't remember a useful example where that was really necessary except in the case of notification icon.
Maybe if a window would have to be resized or moved or something similar. Not a great example but nothing else crossed my mind.:)

Code: Select all

#!/bin/bash
# Temp file
export temp_list=$(mktemp -u --tmpdir temp.XXXXXXXX)

# create a named pipe
mkfifo "$temp_list"

#Trap that removes named pipe on exit
trap "rm -f $temp_list" EXIT

# Opens named pipe for reading and writing on file descriptor 3
exec 3<> $temp_list

yad --list --column="1" --listen --button "exit 1":1 --button "exit 50":50 --button "exit 0":0  <&3 & list_pid=$!

#We can use just sleep instead of calling xdotool and hope it opens in 5 seconds :)
sleep 5

#populate the list
echo "1" >&3
echo -e "2\n3\n4" >&3

# get win id
WIN_ID=$(xdotool search --pid "$list_pid" 2>/dev/null | tail -1)

#Resize the window
xdotool windowsize $WIN_ID 800 600

wait $list_pid
exit_status=$?

   yad --width=500 --height=300 --text="exit status is $exit_status"

# close file descriptor 3
exec 3>&-

exit 0

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

#408 Post by fredx181 »

stemsee wrote:How about a yad paint!?!
OK, pity, not possible, but maybe then a yad full Office-Suite !?? :lol:

Thanks misko for the valuable info !

Fred

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

#409 Post by wiak »

fredx181 wrote:
stemsee wrote:How about a yad paint!?!
OK, pity, not possible, but maybe then a yad full Office-Suite !?? :lol:

Thanks misko for the valuable info !

Fred
Okay, not yad, but it is absolutely possible to do both with IUPLUA actually. At the moment, in the examples there is a notepad and also a Color Picker:

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

http://www.murga-linux.com/puppy/viewto ... 612#987612

https://webserver2.tecgraf.puc-rio.br/i ... rowser.lua

https://webserver2.tecgraf.puc-rio.br/i ... tcolor.lua

Or for something else Lua-related:

http://compasstech.com.au/TNS_Authoring ... rials.html

http://compasstech.com.au/TNS_Authoring ... _tut7.html

Anyway... back to on-topic yad...

wiak

stemsee

#410 Post by stemsee »

How to re-open a yad gui in the same last location? In other words how to export yad gui location to a variable/file and re-open same gui using that geometry? Not hard-coded but according to last moved to location?

Post Reply