Author |
Message |
vovchik

Joined: 23 Oct 2006 Posts: 1478 Location: Ukraine
|
Posted: Sun 03 Feb 2019, 18:50 Post subject:
|
|
Dear all,
Just a little demo utilizing techniques mention here https://iwf1.com/how-to-change-gtk-apps-tooltips-text-and-background-color, with embedded svgs, so the script is self-contained.
With kind regards,
vovchik
Description |
|

Download |
Filename |
yadstyle-vov.tar.gz |
Filesize |
2.44 KB |
Downloaded |
20 Time(s) |
|
Back to top
|
|
 |
lamplinux

Joined: 21 Jan 2019 Posts: 24
|
Posted: Mon 04 Feb 2019, 13:09 Post subject:
Yad Pad Docker |
|
https://www.youtube.com/watch?v=T9Wz_lwyeok
|
Back to top
|
|
 |
lamplinux

Joined: 21 Jan 2019 Posts: 24
|
Posted: Tue 05 Feb 2019, 22:21 Post subject:
Multiple filters in yad --filename window |
|
@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: |
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
|
|
Back to top
|
|
 |
lamplinux

Joined: 21 Jan 2019 Posts: 24
|
Posted: Tue 05 Feb 2019, 22:36 Post subject:
Using yad --entry and have it save to a file |
|
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"
|
Back to top
|
|
 |
MochiMoppel

Joined: 26 Jan 2011 Posts: 1768 Location: Japan
|
Posted: Tue 05 Feb 2019, 23:38 Post subject:
Re: Multiple filters in yad --filename window |
|
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: | --file-filter=*.mp3 --file-filter=*.ogg --file-filter="Audio files|*.mp3 *.ogg *.wav" --file-filter="All files|*" |
|
Back to top
|
|
 |
lamplinux

Joined: 21 Jan 2019 Posts: 24
|
Posted: Wed 06 Feb 2019, 00:03 Post subject:
|
|
@MochiMoppel -- Thank you again !!
|
Back to top
|
|
 |
lamplinux

Joined: 21 Jan 2019 Posts: 24
|
Posted: Thu 07 Feb 2019, 02:07 Post subject:
Multiple yad --entry write to separate files |
|
Is it possible for yad --entry to have several entry boxes in same window and then write each entry box input to a separate file ?
Code: | dock1_name=$(yad --entry --title="Change Dock1 Window Name" --text="Enter New Dock1 name") && echo $dock1_name > /home/bobby/yadbash/beta/code/dock1name.file |
Code: | cd /home/bobby/yadbash/beta/code
dock1_name=$(head -n 1 dock1name.file)
yad --icons --read-dir=/usr/share/applications --monitor --single-click --item-width=70 --sort-by-name\
--geometry="1244x153+1+592" --on-top --vscroll-policy=auto --undecorated \
--title="YadBash Simple Coding" --text="$dock1_name" --window-icon=/usr/share/icons/sparky/about/sparky48.png \
--no-buttons --skip-taskbar |
|
Back to top
|
|
 |
misko_2083

Joined: 08 Nov 2016 Posts: 64
|
Posted: Thu 07 Feb 2019, 21:12 Post subject:
Re: Multiple yad --entry write to separate files |
|
lamplinux wrote: | Is it possible for yad --entry to have several entry boxes in same window and then write each entry box input to a separate file ?
Code: | dock1_name=$(yad --entry --title="Change Dock1 Window Name" --text="Enter New Dock1 name") && echo $dock1_name > /home/bobby/yadbash/beta/code/dock1name.file |
Code: | cd /home/bobby/yadbash/beta/code
dock1_name=$(head -n 1 dock1name.file)
yad --icons --read-dir=/usr/share/applications --monitor --single-click --item-width=70 --sort-by-name\
--geometry="1244x153+1+592" --on-top --vscroll-policy=auto --undecorated \
--title="YadBash Simple Coding" --text="$dock1_name" --window-icon=/usr/share/icons/sparky/about/sparky48.png \
--no-buttons --skip-taskbar |
|
Well you can use the array
The trick is to use the quoted output and remove it later with xargs.
Also the internal field separator must be set for the array.
In this case newline character.
Code: | #!/bin/bash
# backup IFS
OIFS=$IFS
# set IFS to newline char
IFS=$'\n'
res=($(yad --form --quoted-output --separator="\n" \
--field=1 --field=2 \
--field=3 --field=4 \
--field=5))
# get exit status
out=$?
# Restore IFS
IFS=$OIFS
# OK (0), canceled (1) or closed dialog (252)
[ $out -ne 0 ] && exit 1
# for looping trough array
for i in {0..4}; do
# write each element 0-4 into field-1 to field-5
# xargs removes outer quotes
echo "${res[$i]}" | xargs > /tmp/field-$((i+1))
done |
Btw this is a form dialog,
|
Back to top
|
|
 |
lamplinux

Joined: 21 Jan 2019 Posts: 24
|
Posted: Thu 07 Feb 2019, 22:36 Post subject:
--form multiple records written to many files. |
|
@misko, That works great - as always. Thank You !!!!
May I ask for another option to your array output ? Then I'll be able to output and read all night long.
Can the output of the array be written to the same line number of each of the "field-$" files ?
For example, Form data output is written to line 3 of each "field-$" file. So, not to over write the file, just update Line 3 of each file. I hope I'm asking this well enough.
I'm trying to use sed to accomplish this with your array but, don't fully understand what I m doing (learning though).
Bobby's attempt:
Code: | # Using sed to update file - line 3 looping trough array
for i in {0..4}; do
sed '3 c\ > echo "${res[$i]}"' | xargs > /tmp/field-$((i+1)) |
|
Back to top
|
|
 |
MochiMoppel

Joined: 26 Jan 2011 Posts: 1768 Location: Japan
|
Posted: Fri 08 Feb 2019, 00:08 Post subject:
|
|
Instead of
Code: | echo "${res[$i]}" | xargs > /tmp/field-$((i+1)) |
try
Quote: | new=$(echo "${res[$i]}" | xargs)
sed -i "3s/.*/$new/" /tmp/field-$((i+1)) |
This assumes that the target file has a line 3, which sed will then replace with the field content.
|
Back to top
|
|
 |
lamplinux

Joined: 21 Jan 2019 Posts: 24
|
Posted: Fri 08 Feb 2019, 16:53 Post subject:
|
|
Quote: | new=$(echo "${res[$i]}" | xargs)
sed -i "3s/.*/$new/" /tmp/field-$((i+1)) |
This assumes that the target file has a line 3, which sed will then replace with the field content.[/quote]
I tried code as written but, no file writing. 5 files with words on lines 1 through 4.
I will see if I can make some (roll of the dice mod" to your code and see what I get as output.
I appreciate your help as it gets me to research what the code is doing and learn from that.
|
Back to top
|
|
 |
misko_2083

Joined: 08 Nov 2016 Posts: 64
|
Posted: Fri 08 Feb 2019, 18:58 Post subject:
|
|
Bobby, Mochi's line should work, unless you are entering special characters in yad fields that mess up regular expressions or delimiter with sed later.
So you will want to escape them first.
Code: | for i in {0..4}; do
new="$(echo "${res[$i]}" | xargs -I {} echo "{}" | sed -e 's/[]\/&$*.^[]/\\&/g')"
sed -i "3s/.*/$new/" /tmp/field-$((i+1))
done |
|
Back to top
|
|
 |
MochiMoppel

Joined: 26 Jan 2011 Posts: 1768 Location: Japan
|
Posted: Fri 08 Feb 2019, 21:25 Post subject:
|
|
- removed -
(was not directly related to lamplinux's issue)
Last edited by MochiMoppel on Sat 09 Feb 2019, 10:22; edited 1 time in total
|
Back to top
|
|
 |
lamplinux

Joined: 21 Jan 2019 Posts: 24
|
Posted: Fri 08 Feb 2019, 23:26 Post subject:
My Life is now complete. Thank You :) |
|
@MochiMoppel @misko, I had to remove the backslashs between --field-1, --filed-2, etc. to get it to work. But, Dang it !!!! IT NOW WORKS !!! Whoo Whoo , Thank You Both !!!!!!!!!!!
Now its time to take over the world (or maybe not) but, lots of hours of fun time creating all kinds of fully user customizable Yad powered Launching and Bash Command solutions.
Have a Great Weekend ! I am very Happy !! All Thanks to you both. Cheers !!!!!!
|
Back to top
|
|
 |
lamplinux

Joined: 21 Jan 2019 Posts: 24
|
Posted: Tue 12 Feb 2019, 22:57 Post subject:
Focus - Automatic each --form --field user entry box |
|
I discovered that I can read current data to each field to a form entry box but, if user does not change the data, it is written back to the file as - blank space.
But, if I click in each field entry box, the read data then becomes an entry and saved properly back to same file.
?? Is there a way in Yad (or bash) to emulate a user clicking a box "like auto focus" for all --field boxes in a script - automatically ?
Last edited by lamplinux on Wed 13 Feb 2019, 02:37; edited 1 time in total
|
Back to top
|
|
 |
|