YAD - Tips
- misko_2083
- Posts: 114
- Joined: Tue 08 Nov 2016, 13:42
Freddy, you've been a busy puppy since my last login.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
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".
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
Yeah, sure, but you should check here more often, MiskY !misko_2083 wrote:Freddy, you've been a busy puppy since my last login. Smile
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
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.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)).
- misko_2083
- Posts: 114
- Joined: Tue 08 Nov 2016, 13:42
Didn't have the time to "sit" by the computer.fredx181 wrote:Yeah, sure, but you should check here more often, MiskY !misko_2083 wrote:Freddy, you've been a busy puppy since my last login. Smile
"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). I never heard of such name.
Here is alsa version. *Requires alsa-utils.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)).
- Attachments
-
- yradio.fake.tar
- (22.41 KiB) Downloaded 163 times
-
- TheMagnificentManow.png
- (12.11 KiB) Downloaded 973 times
Thanks again Miskey !misko_2083 wrote:Here is alsa version. *Requires alsa-utils.
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')
https://github.com/fredx181/yradio/archive/master.zip
Fred
- misko_2083
- Posts: 114
- Joined: Tue 08 Nov 2016, 13:42
Very good Fred.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).
Well, at least you guessed the first letter right.stemsee wrote:I called you Manow as a guess because your 'handle' seemed to be in the cyrillic alphabet, which I recalled poorly!
As the consolation prize you get a link to my wallpaper "Resting fox 1920x1080" on Deviant Art. https://misko-2083.deviantart.com/art/R ... -726774960
It's possible to use use the checkbox for selection. However, in yad form dialogs, only button can be used as the trigger.stemsee wrote:Alsa version with VLC option (chkbox) would be ideal!
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.
- Attachments
-
- yad-alsa-notification.fake.tar
- (4.83 KiB) Downloaded 173 times
- Mike Walsh
- Posts: 6351
- Joined: Sat 28 Jun 2014, 12:42
- Location: King's Lynn, UK.
@ 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..... )
-----------------------------------------------------------------------------
Anyway; I've ended up with this:-
.....which resulted from the following script:-
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:-
So; time to re-compile the new version for all the other Pups!
Mike.
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..... )
-----------------------------------------------------------------------------
Anyway; I've ended up with this:-
.....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
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
Mike.
Last edited by Mike Walsh on Tue 03 Apr 2018, 14:45, edited 1 time in total.
Hi Mike Walsh,
Fred
I see a whitespace where it should be a dash, this works maybe ?Unable to parse option --close on-unfocus
Code: Select all
--close-on-unfocus
- Mike Walsh
- Posts: 6351
- Joined: Sat 28 Jun 2014, 12:42
- Location: King's Lynn, UK.
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..!
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.
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..!
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.
- misko_2083
- Posts: 114
- Joined: Tue 08 Nov 2016, 13:42
I use Gimp mostly.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!?!
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
- misko_2083
- Posts: 114
- Joined: Tue 08 Nov 2016, 13:42
Yes certainly.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
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...
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
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:fredx181 wrote:OK, pity, not possible, but maybe then a yad full Office-Suite !??stemsee wrote:How about a yad paint!?!
Thanks misko for the valuable info !
Fred
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