YAD - Tips

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Message
Author
slavvo67
Posts: 1610
Joined: Sat 13 Oct 2012, 02:07
Location: The other Mr. 305

#541 Post by slavvo67 »

Hi oldaolgeezer,

I ran without the list.txt file being there and as you could imagine, my output was a mess. So I added the following after your DIR= line but before your SOURCE= line. To be exact, my if statement started on line 29.

if [ -e list.txt ]; then
yad --text="list.txt exists!"
else
touch list.txt
echo "01 apples
01 apricot
01 asparagus
01 bananas
01 beets
01 brocoli
01 brussel sprouts
01 cantelope
01 carrots
01 green peppers
01 ketchup
01 kiwi
01 milk
01 mozrla chs block
01 mozrla chs slices
01 mushrooms
01 onion
01 orange juice pure
01 oranges
01 peas
01 spinach
01 strawberries
01 tomato
01 tzaziki
01 yams
01 yogurt
02 butter
02 cheddar
02 cheese slices
02 cheese sticks
02 chili beans
02 cottage cheese
02 eggsDairy
02 jam
02 mayonaise
02 pork& beans
02 salmon
02 soup
02 soya sauce
03 shampoo
03 tea bisk
03 zest
04 chickpeas
04 egg noodles
04 jello
04 oil
04 parmesan cheese
04 pasta
04 pineapple slices
04 potatoes canned
04 pudding
04 raisins
04 rice
04 salt
04 sphagetti sauce
04 wheat germ
05 crackers
05 mustard
05 peanut butter
05 tea bags
06 dog food
06 flour
06 ginger ale
06 gravy (canned)
06 pumpkin pie filling
06 sugar
07 bounce
07 dish soap
07 dishwasher soap
07 hand soap liquid
07 lasagne noodles
07 laundry detergent
07 tomato canned
03 toothpaste
07 water
08 kleenex
08 minty bones
08 napkins
08 paper towels
08 toilet paper
04 mandarin oranges
04 pineapple chunks
12 bacon
12 chicken breasts
12 ground beef
12 ham roast
12 ham slices
12 meatballs
12 pork cutlets
12 sausage
12 spare ribs
12 steak flank
12 steak round
12 steak sirloin
12 steak tenderloin
12 wieners
16 comet
16 garbage bags
03 cereal
19 Bread
19 bread crumbs
19 buns
19 hamburg buns
19 hotdog buns
19 pita slices
19 rice cakes
20 cabbage Rolls
20 cake
20 chicken Cordon Swiss
20 cool whip
20 corn frozen
20 frozen dinners
20 ice-cream
20 mravioli
20 perogies
20 raspberries frozen (425g)
20 waffles
20 whipped cream">>list.txt
fi

oldaolgeezer
Posts: 64
Joined: Sun 03 Dec 2006, 19:34

YAD - Tips

#542 Post by oldaolgeezer »

slavvo67

I'm glad you were able to get Anthony Tekatch's
list.txt file extracted. (Others who are interested can copy
and paste it from your above post.)

I, myself, was very impressed with the "professional look" of
MochiMoppel's Xdialog command's window.
(I've attached a screen shot to show this.)

I downloaded grocget-0.6.tar.gz file and clicked on it and scanned its
contents and then selected his "grocget-0.6/list.txt" only and extracted just that
to a small directory I made called "grocery_shopping_for_Linux_stuff" on my
Windows NTFS drive. I put just the "list.txt" and my "yad_groceryshoppinglist.sh"
files in that directory.

I brought that directory up in a ROXfiler window and with a right click, choose
"window" then "terminal here". In my roxterm terminal window which opened, I entered
my script name with ". ./":
. ./yad_groceryshoppinglist.sh
after many cycles of trying, Geany editing and retrying "window" then "terminal here",
I wanted to share the versatility of MochiMoppel code.

Perhaps MochiMoppel's Xdialog script showing how to select file names and this
yad_groceryshoppinglist script showing selecting lines from within one file
will inspire others to code even more useful little script programs.
Attachments
Screenshot_of_yad_groceryshoppinglist_script.jpg
(59.38 KiB) Downloaded 651 times

User avatar
lamplinux
Posts: 31
Joined: Mon 21 Jan 2019, 06:05
Contact:

RE: Failing - That's me ! All your code worked,

#543 Post by lamplinux »

Hi all, your code worked fine. I was trying to use awk to copy files with spaces and had problems. I will work with your code this weekend and learn more about what it does.

@step, your code with printf did the trick with copying files with spaces. Thanks !

Thanks Everyone for your help. I just need to test more to see what all the code does. I'm learning and still a newbie.

Will come back next week after testing, tweaking, learning. Thanks Again !!!! You all are very much appreciated.

User avatar
lamplinux
Posts: 31
Joined: Mon 21 Jan 2019, 06:05
Contact:

Yad as a mp3 player using mpv

#544 Post by lamplinux »

Experimenting with both mpg123 and mpv I need to send a keystroke to advance to next song.

mpg123 requires the "f" key to go to next song. mpg123 -C *.mp3

mpv requires the "Return" key to go to next sone. mpv *.mp3

Can not understand why when I click on Next Track Music button, another instance of mpv is executed.

Code: Select all

#!/bin/bash

play_mpv(){
cd /home/bobby/yadbash/sparky-launcher/music/
mpv *.mp3
}
export -f play_mpv


yad --form \
 --field="Play Random Music:BTN" "bash -c play_mpv" \
 --field="Next Track Music:BTN" "xdotool key Return" \
 --field="STOP MUSIC:BTN" "killall mpv"

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

Re: Yad as a mp3 player using mpv

#545 Post by MochiMoppel »

lamplinux wrote:Can not understand why when I click on Next Track Music button, another instance of mpv is executed.
Because when you click the button, yad becomes the active window and the xdotool sends a Return keystroke - without further instructions of course to the active window. Yad receives the keystroke and applies it to the first button and starts another instance of mpv. You should be happy that the Return key does not go to the button you just pushed as this would result in an infinite loop.

What you need to do is let your command activate the mpv window and then send Return.

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

#546 Post by misko_2083 »

lamplinux aka Bobby I'm glad you are still around.

You can try with the mpv's built in command interface.
https://mpv.io/manual/master/#list-of-input-commands

Code: Select all

#!/bin/bash

export COMMAND_PIPE=$(mktemp -u --tmpdir ${0##*/}.XXXXXXXX)
mkfifo $COMMAND_PIPE

exec 3<> $COMMAND_PIPE

function exit() {
    echo "quit" >&3
    rm -f $COMMAND_PIPE
}
trap exit EXIT

mpv --input-file=$COMMAND_PIPE --cache 2048 --no-config --idle=yes 2>&1 &

cd "/home/bobby/yadbash/sparky-launcher/music/"
printf "%s\n" *.mp3 | sort -R > playlist.m3u

yad --form \
 --field="Load Playlist Music:BTN" \
   'bash -c "echo loadlist \"/home/bobby/yadbash/sparky-launcher/music/playlist.m3u\" >> $COMMAND_PIPE"' \
 --field="Next Track:BTN" 'bash -c "echo playlist_next >> $COMMAND_PIPE"' \
 --field="Previous Track:BTN" 'bash -c "echo playlist_prev >> $COMMAND_PIPE"' \
 --field="STOP MUSIC:BTN" 'bash -c "echo stop >> $COMMAND_PIPE"'

exit 0

User avatar
lamplinux
Posts: 31
Joined: Mon 21 Jan 2019, 06:05
Contact:

mpv - yad - mp3 playing

#547 Post by lamplinux »

@misko So glad you knew it was me !! and that you are helping. Still trying to learn both Yad and Bash. Thank You So Much !!

User avatar
puppy_apprentice
Posts: 299
Joined: Tue 07 Feb 2012, 20:32

#548 Post by puppy_apprentice »

Suppose i use YAD script that resides in tray. Can i change icon of this YAD script from other script. I'm thinking to make something similar to Windows notification area. For example when bash script will finish work will change icon of YAD script in the tray eg. for exclamation sign so user will know that there is some message to read. Next when user will click on YAD script icon a message from bash script will be displayed.

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

#549 Post by fredx181 »

Yes, you can change the icon, for example, to test I did this in one terminal:

Code: Select all

mkfifo /tmp/noti 
exec 3<> /tmp/noti
yad --notification --no-markup                  \
    --listen                        \
    --image="/usr/share/pixmaps/flame.png"              \
    --text="My Text"   \
    --command="bash -c on_click" 2> /dev/null <&3 &
Then in another terminal:

Code: Select all

echo icon:/usr/share/pixmaps/disc.png >/tmp/noti
echo action:'yad --text="My message"' >/tmp/noti
And the icon changed from flame to disc.
EDIT: And message when clicking on icon

EDIT: For the rest I'm not sure what you mean, clicking on the icon should give message ?
EDIT2: Changed above for in another terminal, added action:.... (thanks for info below, step)

Fred
Last edited by fredx181 on Sat 26 Jan 2019, 13:17, edited 2 times in total.

step
Posts: 1349
Joined: Fri 04 May 2012, 11:20

#550 Post by step »


[url=http://murga-linux.com/puppy/viewtopic.php?t=117546]Fatdog64-810[/url]|[url=http://goo.gl/hqZtiB]+Packages[/url]|[url=http://goo.gl/6dbEzT]Kodi[/url]|[url=http://goo.gl/JQC4Vz]gtkmenuplus[/url]

User avatar
lamplinux
Posts: 31
Joined: Mon 21 Jan 2019, 06:05
Contact:

Is it possible to save Yad window size & position

#551 Post by lamplinux »

Is it possible to save to a file a Yad window size and position once it has been moved around and resized the way one wants it ?

User avatar
6502coder
Posts: 677
Joined: Mon 23 Mar 2009, 18:07
Location: Western United States

#552 Post by 6502coder »


User avatar
lamplinux
Posts: 31
Joined: Mon 21 Jan 2019, 06:05
Contact:

#553 Post by lamplinux »

@6502coder Thank You !! I'll try that code.

User avatar
lamplinux
Posts: 31
Joined: Mon 21 Jan 2019, 06:05
Contact:

Saving Yad Window size & position

#554 Post by lamplinux »

More Info: Saving Yad Window size & position to be redisplayed by user.

A different kind of ad stopper - wolrdwide web.

So we all see the ads on Facebook, Youtube, Yahoo, Downlaod.com, sourceforge, etc.

I want to "hide" (not block) the ads on all these popular websites using Yad Windows that stay on top and contained in the yad windows is piped information about Linux, Joomla, Yad, and other info from others who help makes this happen.

Its really above my head and I'd appreciate feedback on the pipe methods.
  • chat between 2 specific users PC <--> Webserver <--> PC
    Pictures and animated gif images can be displayed.
    rss text feed & notifications to a specific user.
    html page display.
What else can yad do (display in these Yad Cover Windows) ?

User avatar
lamplinux
Posts: 31
Joined: Mon 21 Jan 2019, 06:05
Contact:

#555 Post by lamplinux »

This is a demo of what I am suggesting "COVERING ADS" Feedback to Users. Users passing messages and data to each other off of spy platforms like Facebook.

https://www.youtube.com/watch?v=AIgLWNoo1Vg

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

#556 Post by vovchik »

Dear all,

Just a little demo utilizing techniques mention here https://iwf1.com/how-to-change-gtk-apps ... ound-color, with embedded svgs, so the script is self-contained.

With kind regards,
vovchik
Attachments
yadstyle-vov.tar.gz
(2.44 KiB) Downloaded 125 times


User avatar
lamplinux
Posts: 31
Joined: Mon 21 Jan 2019, 06:05
Contact:

Multiple filters in yad --filename window

#558 Post by lamplinux »

@MochiMoppel

I am using your below code and it works also for selecting and copying *.mp3 files. Thank You !!

Is it possible to have multiple filters in your code where the filters can be picked in drop down list (lower right) of Yad --filename window ?

Code: Select all

TARGET="/home/bobby/Music/favorites" 
CHECKED=$(yad --title="Please select (multiple) files" --file --geometry=700x500 --button="Copy to $TARGET":0 --button=Cancel:1 --file-filter=*.mp3 --file-filter*.desktop --multiple --filename=/home/bobby/Music/mp3-mew-rock-alt/* ) 
(($?)) && exit 
IFS=TMP IFS='|' 
cp -t "$TARGET" $CHECKED 
IFS=$TMP

User avatar
lamplinux
Posts: 31
Joined: Mon 21 Jan 2019, 06:05
Contact:

Using yad --entry and have it save to a file

#559 Post by lamplinux »

How would I use yad --entry to have user enter and save to file "title_names.source"

name of Window1, Window2, Window3, etc.

title_names.source (content)

$window1="Applications"
$window2="Favorites"
$window3="Yad Help"
$window4="Toms Window"

Then I can read the variable from this one file for each window.

yad --title="$window1"

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

Re: Multiple filters in yad --filename window

#560 Post by MochiMoppel »

lamplinux wrote:Is it possible to have multiple filters in your code where the filters can be picked in drop down list (lower right) of Yad --filename window ?
Yes. Use a --file-filter option for each file pattern. You can also give your filter a name that will appear in the drop-down list and - probably most important - you can also define a set of file patterns for a single filter option:

Code: Select all

--file-filter=*.mp3 --file-filter=*.ogg --file-filter="Audio files|*.mp3 *.ogg *.wav" --file-filter="All files|*"

Post Reply