You are not logged in.

#176 2019-12-01 21:37:11

damo
....moderator....
Registered: 2015-08-20
Posts: 5,967

Re: The great yad hacking thread

From

man lpstat
...
-p [printer(s)]
            Shows  the  printers  and  whether they are enabled for printing.  If no printers are specified
            then all printers are listed.

This gives output such as

lpstat -p "Brother"
printer Brother is idle.  enabled since Thu 19 Sep 2019 08:32:47 BST

So use a test for the output

if lpstat -p "Brother" | grep -q 'enabled';then echo 'true'; else echo 'false'; fi

You could add something to the name in $LIST eg

for ((j=0; j<${#arrP[*]}; j++));do
    p="${arrP[$j]}"
    [[ "$p" == "reason" ]] && continue
    if lpstat -p "$p" | grep -q 'enabled';then
        p="$p ACTIVE"
    fi
    LIST="${LIST}FALSE $p "
done

NB Untested!


Be Excellent to Each Other...
The Bunsenlabs Lithium Desktop » Here
FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt  «» BunsenLabs on DeviantArt

Offline

#177 2019-12-02 15:36:41

achim
Member
Registered: 2019-08-23
Posts: 35

Re: The great yad hacking thread

@damo

I believe that I mispronounced myself in my post # 175. The variable "sprint" already corresponds exactly to the printer "EPSON_WF-3520_Series". When the YAD code is called, this printer is already set as the default. In the YAD window, however, all printers are displayed as "False". EPSON_WF-3520_Series True, but false for all others?
I had a test, because with --column "record number" and --hide-column = 2 two additional columns were inserted. These controlled the display of True and False. Unfortunately, the code did not work.

Achim

Offline

#178 2019-12-02 18:56:43

damo
....moderator....
Registered: 2015-08-20
Posts: 5,967

Re: The great yad hacking thread

Without seeing your code it seems pointless trying to troubleshoot it!


Be Excellent to Each Other...
The Bunsenlabs Lithium Desktop » Here
FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt  «» BunsenLabs on DeviantArt

Offline

#179 2019-12-02 19:09:21

achim
Member
Registered: 2019-08-23
Posts: 35

Re: The great yad hacking thread

sorry...

stdr () {
lpstat -d > /tmp/sdr
 sdrucker=$(cat /tmp/sdr)
 sdrucker=${sdrucker%*:}
 sdrucker=${sdrucker#*:}
 echo $sdrucker
 }; export -f stdr

arrP=($(lpstat -a | awk '{print $1}'))

LIST=""

for ((j=0; j<${#arrP[*]}; j++));do
    p="${arrP[$j]}"
    [[ "$p" == "reason" ]] && continue
    LIST="${LIST}FALSE $p "
done

stdr
#if lpstat -p = $(cat /tmp/sdr) | grep -q 'enabled';then echo 'true'; else echo 'false'; fi

RET=$(yad --list --center --fixed --title="Drucker" --window-icon="gtk-print" --text='<span foreground="blue" font="12">Aktuell ist "$sdrucker". Zur Auswahl stehen die folgenden Geräte:</span>' \
    --radiolist --width=550 --height=350 --column "Select" --column="Druckername" $LIST --separator=":" \
    --button=gtk-cancel:1 --button=gtk-ok:0
    )
dvar=$(echo $?)										# Exit-Code auswerten
	
if [[ $dvar == 1 ]] || [[ $dvar == 70 ]] || [[ $dvar == 252 ]]; then	# Taste Abbrechen gedrückt || Skript-Ende mit [X] || Skript-Ende mit [Esc]
exit
else
PRINTER=${RET%*:}
PRINTER=${PRINTER#*:}
fi
exit

Last edited by achim (2019-12-02 19:16:09)

Offline

#180 2019-12-02 19:57:28

damo
....moderator....
Registered: 2015-08-20
Posts: 5,967

Re: The great yad hacking thread

I don't see a variable called "sprint" ??


Be Excellent to Each Other...
The Bunsenlabs Lithium Desktop » Here
FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt  «» BunsenLabs on DeviantArt

Offline

#181 2019-12-02 21:00:34

achim
Member
Registered: 2019-08-23
Posts: 35

Re: The great yad hacking thread

Oh, Variable "sprint" = Variable "sdrucker". "sprint" is old.

Last edited by achim (2019-12-03 10:02:51)

Offline

#182 2019-12-04 10:23:12

damo
....moderator....
Registered: 2015-08-20
Posts: 5,967

Re: The great yad hacking thread

My TRUE/FALSE test was failing at first because $sdrucker was saved with a leading whitespace.

I don't see any need to export a function result, and have a tempfile.

#!/bin/bash
##
## yad-printer.sh

arrP=($(lpstat -a | awk '{print $1}'))

sdrucker="$(lpstat -d)"
sdrucker="${sdrucker##* }"   # get string after last whitespace

LIST=""

for ((j=0; j<${#arrP[*]}; j++));do
    p="${arrP[$j]}"
    [[ "$p" == "reason" ]] && continue
    if [[ "$p" == "$sdrucker" ]];then
        LIST="${LIST}TRUE $p "    
    else
        LIST="${LIST}FALSE $p "
    fi
done

RET=$(yad --list --center --fixed --title="Drucker" --window-icon="gtk-print" \
--text='<span foreground="blue" font="12">Aktuell ist "$sdrucker". Zur Auswahl stehen die folgenden Geräte:</span>' \
    --radiolist --width=550 --height=350 --column "Select" --column="Druckername" $LIST --separator=":" \
    --button=gtk-cancel:1 --button=gtk-ok:0
    )
dvar=$(echo $?)										# Exit-Code auswerten
	
if [[ $dvar == 1 ]] || [[ $dvar == 70 ]] || [[ $dvar == 252 ]]; then	# Taste Abbrechen gedrückt || Skript-Ende mit [X] || Skript-Ende mit [Esc]
    exit
else
    PRINTER=${RET%*:}
    PRINTER=${PRINTER#*:}
fi
echo "Chosen PRINTER= $PRINTER"
exit

Be Excellent to Each Other...
The Bunsenlabs Lithium Desktop » Here
FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt  «» BunsenLabs on DeviantArt

Offline

#183 2019-12-04 14:02:42

Anton
Member
From: СПб, Россия
Registered: 2019-04-11
Posts: 9

Re: The great yad hacking thread

misko_2083 wrote:

Relax, I'm only messing with you. :-D

I like the way you write the scripts.
They are readable. You have an eye for that.

Я тебя понял.
Спасибо Мишко. wink

Offline

#184 2019-12-04 15:36:02

achim
Member
Registered: 2019-08-23
Posts: 35

Re: The great yad hacking thread

@damo

Fantastic, it works. Sometimes the problem is so close you just can not recognize it. I spent a lot of time searching. Thanks again, I hope I can return the favor smile

achim

Offline

#185 2019-12-04 20:00:26

damo
....moderator....
Registered: 2015-08-20
Posts: 5,967

Re: The great yad hacking thread

smile


Be Excellent to Each Other...
The Bunsenlabs Lithium Desktop » Here
FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt  «» BunsenLabs on DeviantArt

Offline

#186 2019-12-05 10:52:10

misko_2083
Member
Registered: 2016-05-24
Posts: 342

Re: The great yad hacking thread

Anton wrote:
misko_2083 wrote:

Relax, I'm only messing with you. :-D

I like the way you write the scripts.
They are readable. You have an eye for that.

Я тебя понял.
Спасибо Мишко. wink

Нема на чему Борисе.
Мој Мишко је геније за вожњу.* wink
https://www.youtube.com/watch?v=krxD25ZNFs4
*Реченица из филма "Ко то тамо пева (1980)"


Што ни оштровиди ум сагледати не може - љубав превазилази.

Offline

#187 2019-12-09 08:44:15

Naik
Member
From: Lipsia
Registered: 2015-10-03
Posts: 216

Re: The great yad hacking thread

hey there!

I found it nice to make a little script which helps me to clean up my download folder as ClusterF suggested:

#!/usr/bin/env bash
# sort the download folder usin rsync
# inspired by ClusterF

# filetypes to sort
arr=( *.doc *.docx *.ebook *.log *.md *.msg *.odt *.org *.pages *.pdf *.rtf *.rst *.tex *.txt *.wpd *.wps ) 
arr1=( *.aac *.aiff *.ape *.au *.flac *.gsm *.it *.m3u *.m4a *.mid *.mod *.mp3 *.mpa *.pls *.ra *.s3m *.sid *.wav *.wma *.xm *.ogg )
arr2=( *.jpg *.JPG *.jpeg *.png *.xfc *.bmp *.gif )


# change this to use it to sort any folder you like
dls () {
        cd $HOME/Downloads
}

# how to process and where to put the various filetypes
docs () {
        rsync -bvh --progress --remove-source-files ${arr[@]} $HOME/Documents 2> /dev/null
}

music () {
        rsync -bvh --progress --remove-source-files -b ${arr1[@]} $HOME/Music 2> /dev/null
}

iso () {
		rsync -bvh --progress --remove-source-files -b *.iso $HOME/Downloads/iso 2> /dev/null
}

mc () {
		rsync -bvh --progress --remove-source-files -b *.jar $HOME/.minecraft/mods 2> /dev/null
}

pix () {
		rsync -bvh --progress --remove-source-files -b ${arr2[@]} $HOME/Pictures/unsorted/ 2> /dev/null
}

deb () {
		rsync -bvh --progress --remove-source-files -b *.deb $HOME/bin 2> /dev/null
}

# insert funky yad dialog for selecting filetypes here

# ..and go
if      dls; then
        docs
        music
        iso
        mc
        pix
        deb
fi
        exit 1

and as you can see I have room to fill with a yad-dialog to select which file types should be processed, but i cant seem to be figuring out how to create one. I would be able to create a radio-list but multiple choices have to be possible and then i just don't understand how the choice will be passed back to the script to work with.

thanks guys!

naik --greetz


"Kaum macht [Mensch]* es richtig, funktioniert es sofort!"
BL-Kitchen on GitHub

Offline

#188 2019-12-09 09:52:52

damo
....moderator....
Registered: 2015-08-20
Posts: 5,967

Re: The great yad hacking thread

i just don't understand how the choice will be passed back to the script to work with.

man yad is very comprehensive, but a bit dense. Basically, the return is a pipe-separated string (or you can set a different separator), which you then parse to get the fields. Eg:

DLG=$(yad ...<parameters>...)

echo "${DLG}"
string_1|string_2|string_3|

val_1="$(echo "${DLG}" | awk -F '|' '{print $1}')"

Be Excellent to Each Other...
The Bunsenlabs Lithium Desktop » Here
FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt  «» BunsenLabs on DeviantArt

Offline

#189 2019-12-09 11:42:22

clusterF
Member
Registered: 2019-05-07
Posts: 539

Re: The great yad hacking thread

Ive little to no experience with yad, im currently playing around with gxmessage though it doesnt have as much functionality than yad does of course.

@ Naik, the only sort of functionality i could see in using a gui would be to pick the sort source folder.

example would to maybe have a list of common user directories to choose from in a list yad box, then have a sort button and a cancel button.

i can possibly see maybe having a choice of what extensions to process from the arrays, so maybe it could be a button to just process all text files and a button to just process all music files and so on. Way beyond my level of scripting though.

Last edited by clusterF (2019-12-09 11:46:00)

Offline

#190 2019-12-13 15:40:00

Naik
Member
From: Lipsia
Registered: 2015-10-03
Posts: 216

Re: The great yad hacking thread

clusterF wrote:

[...]
@ Naik, [...]

i can possibly see maybe having a choice of what extensions to process from the arrays, so maybe it could be a button to just process all text files and a button to just process all music files and so on. Way beyond my level of scripting though.

that is what i have had in mind: showing some tick-boxes or radio-buttons to select which extension to sort and then proceed...

naik --greetz


"Kaum macht [Mensch]* es richtig, funktioniert es sofort!"
BL-Kitchen on GitHub

Offline

#191 2019-12-18 13:51:42

clusterF
Member
Registered: 2019-05-07
Posts: 539

Re: The great yad hacking thread

I was trying to figure out how to use yad and shell commands but ive no clue, how would i put these together for a simple dialog yad box that asks for a password and then completes the commands?

1. yad --entry --text="Password" --hide-text
2. mkdir /tmp/decrypted
3. gocryptfs encrypted /tmp/decrypted

done

Any ideas?

Im thinking that asking for sensitive info like passwords through the yad gui might not be a wise idea without some sort of shell password control mechanism like ssh_askpass or something similar.

Last edited by clusterF (2019-12-18 13:56:56)

Offline

#192 2019-12-18 14:24:51

damo
....moderator....
Registered: 2015-08-20
Posts: 5,967

Re: The great yad hacking thread

clusterF wrote:

I was trying to figure out how to use yad and shell commands but ive no clue, how would i put these together for a simple dialog yad box that asks for a password and then completes the commands?

1. yad --entry --text="Password" --hide-text
2. mkdir /tmp/decrypted
3. gocryptfs encrypted /tmp/decrypted

done

Any ideas?

Im thinking that asking for sensitive info like passwords through the yad gui might not be a wise idea without some sort of shell password control mechanism like ssh_askpass or something similar.

DLG=$(yad --entry --text="Password" --hide-text)

RET=$?

if (( $RET == 0 ));then
    PASS="$DLG"
    echo "PASS= $PASS" # do what you want with the password
fi

Look for examples using YAD (there are loads on github). And this looks like a good (salutory) read: https://www.ict.griffith.edu.au/anthony … _input.txt


Be Excellent to Each Other...
The Bunsenlabs Lithium Desktop » Here
FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt  «» BunsenLabs on DeviantArt

Offline

#193 2019-12-19 07:52:07

clusterF
Member
Registered: 2019-05-07
Posts: 539

Re: The great yad hacking thread

damo wrote:
clusterF wrote:

I was trying to figure out how to use yad and shell commands but ive no clue, how would i put these together for a simple dialog yad box that asks for a password and then completes the commands?

1. yad --entry --text="Password" --hide-text
2. mkdir /tmp/decrypted
3. gocryptfs encrypted /tmp/decrypted

done

Any ideas?

Im thinking that asking for sensitive info like passwords through the yad gui might not be a wise idea without some sort of shell password control mechanism like ssh_askpass or something similar.

DLG=$(yad --entry --text="Password" --hide-text)

RET=$?

if (( $RET == 0 ));then
    PASS="$DLG"
    echo "PASS= $PASS" # do what you want with the password
fi

Look for examples using YAD (there are loads on github). And this looks like a good (salutory) read: https://www.ict.griffith.edu.au/anthony … _input.txt

Thanks i will look into it.

when the command

 gocryptfs encrypted /tmp/decrypted 

is run on the commandline this asks for a password , so the ask pass portion is inside gocryptfs so i dont know how this would match up to yad.
Im probably asking for an impossible situation given gocryptfs code perhaps.

Offline

#194 2019-12-19 08:18:04

damo
....moderator....
Registered: 2015-08-20
Posts: 5,967

Re: The great yad hacking thread

If gocryptfs asks for a password anyway why do you have a need for a YAD dialog? Or do you want the whole thing to run as a GUI?


Be Excellent to Each Other...
The Bunsenlabs Lithium Desktop » Here
FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt  «» BunsenLabs on DeviantArt

Offline

#195 2019-12-19 08:59:04

clusterF
Member
Registered: 2019-05-07
Posts: 539

Re: The great yad hacking thread

damo wrote:

If gocryptfs asks for a password anyway why do you have a need for a YAD dialog? Or do you want the whole thing to run as a GUI?

No need for one, was just seeing if it was possible. I wouldnt have the skills to put a gui front end on gocryptfs, my idea was to facilitate an already functioning gocryptfs user setting whereby all the user need do is enter a password and the the decryption is done and ready.

Last edited by clusterF (2019-12-19 08:59:31)

Offline

#196 2019-12-19 14:20:12

clusterF
Member
Registered: 2019-05-07
Posts: 539

Re: The great yad hacking thread

Have another question regarding yad.

I run dwm with a systray patch, it would be nice to be able to have a yad notification tooltip display a command, would that be possible? Looks like it can only handle text input but i was maybe thinking some sort of script could echo tzdata somehow for the tooltip.

I have this command below running as a notification icon calandar in dwm statusbar, but would be nice to have a mouse over event in maybe a tooltip that could display a date in another time zone perhaps.

yad --notification --image="$HOME/.icons/default/calendar.png" --text "Yad_Calendar" --tooltip --command "yad
--mouse --title "Yad_Calendar" --calendar"

Offline

#197 2019-12-20 05:36:41

ohnonot
...again
Registered: 2015-09-29
Posts: 4,510
Website

Re: The great yad hacking thread

general recommendation for yad users:
https://sourceforge.net/p/yad-dialog/wiki/browse_pages/


BL quote proposals to this thread please.
how to ask smart questions | my repos / my repos | my blog
---
Thank you for posting direct image links!

Offline

#198 2019-12-26 02:54:39

achim
Member
Registered: 2019-08-23
Posts: 35

Re: The great yad hacking thread

Hello everyone, I wish everyone a Merry Christmas!
After a "find" or "grep search" without result, I get the info in the terminal instead "(yad: 7899): GLib-CRITICAL **: g_source_remove: assertion 'tag> 0' failed".
How can I use this message and display it via a yad window "Search term not found?"
PS. If "find" or "grep" find the search term, there is no error message.

achim

Last edited by achim (2019-12-26 03:08:55)

Offline

#199 2019-12-26 04:28:47

damo
....moderator....
Registered: 2015-08-20
Posts: 5,967

Re: The great yad hacking thread

That is a common error message with dialogs, which you can suppress using "2>/dev/null".

You should be able to do something like

<command> && var="found" || var="not found"
message="$var"

If you are searching using a YAD dialog, then you can put your command in a function and run it from a '--button'. Eg

function find_stuff(){
...
}

export find_stuff

yad --button="Search":"/bin/bash -c 'find_stuff'" 2>/dev/null

Or

yad --button="Search":"/bin/bash -c '<command>'" 2>/dev/null

Using the second method it is difficult to pass variables in due to the single quoting though.


Be Excellent to Each Other...
The Bunsenlabs Lithium Desktop » Here
FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt  «» BunsenLabs on DeviantArt

Offline

#200 2019-12-28 12:53:34

achim
Member
Registered: 2019-08-23
Posts: 35

Re: The great yad hacking thread

Hello damo, I found a solution. Hir is the complete script:

#! /bin/bash
#
# requires pdftk and Cups-PDF from the package sources
# Full text search in files
# check if yad is installed
gui=$(which yad)
if [[ ! -x "$gui" ]];
then
    echo "yad is required: 'install with: sudo apt-get install yad"
    exit 0
fi
# prüfen ob pdftk installiert ist
gui=$(which pdftk)
if [[ ! -x "$gui" ]];
then
    echo "pdftk is required: 'install with: sudo apt-get install pdftk"
    exit 0
fi
#
# Schließen und Beenden
function close_exit()
{
    echo "close and exit"
    kill -s SIGUSR1 $YAD_PID
}
export -f close_exit
#
# Fehler auffangen
function fehler1()
{
	yad --center --title=" error!" --width=530 --borders=15 --fixed --window-icon="gtk-dialog-error" --text='<span color=\"blue\" font= "14" >\n  Program break - you have the search without \n\n  Reasons given ended prematurely.  \n\n  - Try again!  \n</span>' --button="gtk-close:1"
	bash -c close_exit &>/dev/null
    exit 0 
}
export -f fehler1
#
function fehler2()
{
	yad --center --title=" error!" --width=530 --borders=15 --fixed --window-icon="gtk-dialog-error" --text='<span color=\"blue\" font= "14" >\n  Program break - No directory was created  \n\n  selected to narrow the search.  \n\n  - Try again!  \n</span>' --button="gtk-close:1"
	bash -c close_exit &>/dev/null
    exit 0 
}
export -f fehler2
#
function fehler3()
{
	yad --center --title=" error!" --width=530 --borders=15 --fixed --window-icon="gtk-dialog-error" --text='<span color=\"blue\" font= "14" >\n  Program break - The search string was able to  \n\n  intensive search can not be found.  \n\n  - Try again!  \n</span>' --button="gtk-close:1"
	bash -c close_exit &>/dev/null
    exit 0 
}
export -f fehler3
#
# nach dem Suchbegriff fragen
function such0()
{
SEARCHSTRING=$(yad --entry --text " Search query - is searched for\n\n Files in the directory  \n\n '$dirname'\n\n with the following content: " \
--window-icon="gtk-find" --title "  Search string" --borders=25 --width="400" --height="350") 2>/tmp/yad-errors.out
    if [[ -z "${SEARCHSTRING}" ]]; then
        fehler2 
    fi
# Exit-Code auswerten
exit_status=$?
# Taste Beenden gedrückt || Skript-Ende mit [Esc] || Skript-Ende mit [X]
	if [[ $exit_status -eq 1 ]] || [[ $exit_status -eq 70 ]] || [[ $exit_status -eq 252 ]]; then
        bash -c close_exit &>/dev/null
        exit 0
    fi

no_found
}
export -f such0
#
# Suchbegriff nicht gefunden
function no_found()
{
me=$(pidof grep)
searchfile="/tmp/search0.txt"
touch $searchfile
echo -e "Achim's search program for file contents \n\n\n  - a search was made in the directory $dirname \n\n  - after "$SEARCHSTRING"\n\n  - with the following results:\n\n\n " >> $searchfile
grep -rnwi $dirname -e $SEARCHSTRING | tee -a /tmp/search1.txt &>/dev/null
grep -c $SEARCHSTRING /tmp/search1.txt
gefunden=$(grep -c $SEARCHSTRING /tmp/search1.txt)
    if [[ $gefunden -gt 1 ]]; then
        echo "were found: " $gefunden
        rm -r /tmp/search1.txt
        ende0
    fi
#
    if [[ $gefunden -le 1 ]]; then
        echo "were found: " $gefunden
        rm -r /tmp/search1.txt
        rm -r /tmp/search0.txt
        fehler3
    fi
}
export -f no_found
#
# Ergebnis auflisten
function ergeb0()
{
yad --text-info --center --title "  Search results for '$SEARCHSTRING' " --borders=10 --width=800 \
--height=500 --window-icon="gtk-find" --button="Print":0 --button="Exit":1
# Exit-Code auswerten
exit_status=$?
# Taste Beenden gedrückt || Skript-Ende mit [Esc] || Skript-Ende mit [X]
	if [[ $exit_status -eq 1 ]] || [[ $exit_status -eq 70 ]] || [[ $exit_status -eq 252 ]]; then
        kill $(pidof $me) &>/dev/null
        rm -r $searchfile &>/dev/null
        rm -r /tmp/search9.txt &>/dev/null
	    bash -c close_exit &>/dev/null
        exit 0
    fi   
#       
    if [[ $exit_status -eq 0 ]]; then
        kill $(pidof $me) &>/dev/null
        print0
    fi
#
}
export -f ergeb0
#
function mix0()
{
while read line 
do
echo "$line" | tee -a /tmp/search0.txt &>/dev/null
echo -en "\n" >> /tmp/search0.txt
echo -en "\n" >> /tmp/search0.txt
done < /tmp/search9.txt
sleep 0.7
}
export -f mix0
#
function print0()
{
mix0
# lp -d PDF -o media=a4 -o page-left=36 -o page-top=36 -o page-right=36 -o page-botton=36 $searchfile
lp -d PDF -o media=a4 -o landscape -o page-left=18 -o page-top=36 -o page-right=10 -o page-botton=36 $searchfile
sleep 0.7
mv $HOME/PDF/search0.pdf $HOME/PDF/Suchergebnisse/$SEARCHSTRING.pdf
pdftk $HOME/PDF/Suchergebnisse/$SEARCHSTRING.pdf cat 1-endeast output $HOME/PDF/Suchergebnisse/$SEARCHSTRING-90.pdf
xdg-open $HOME/PDF/Suchergebnisse/$SEARCHSTRING-90.pdf
# xdg-open $HOME/PDF/Suchergebnisse/$SEARCHSTRING.pdf
rm -r $searchfile
rm -r /tmp/search9.txt
bash -c close_exit &>/dev/null
exit 0
}
export -f print0
#
function ende0()
{
touch /tmp/search9.txt
grep -rnwi $dirname -e $SEARCHSTRING | tee -a /tmp/search9.txt | tee >(sleep 0.5; if ! yad --progress --pulsate \
--progress-text="" --borders=15 --width=300 --height=200 --center --undecorated --text='Searching...' --auto-close \
--button="Cancel:1"; then killall $(basename $0) &>/dev/null; kill $(pidof $me) &>/dev/null; bash -c close_exit; exit 0; fi) | ergeb0
}
export -f ende0
#
# Startseite
cd /home/achim/.cinnamon
TITLE="  Search text string in files"
TEXT='<span color=\"blue\" font="Verdana bold 18" >\n		    Please select any directory and continue with 'OK'!   </span>
<span color=\"red\" font="Verdana 14" >\n (Attention: the directories images, documents, downloads, \n Select music, PDF and videos only from the right window!)
</span> '
dirname=$(yad --file --directory --sort-by-name --ascending --center --fixed --borders=10 --width=1500 --height=600 \
--window-icon="gtk-sort-ascending" --title="$TITLE" --text="$TEXT")
# Exit-Code auswerten
exit_status=$?
# Taste Beenden gedrückt || Skript-Ende mit [Esc] || Skript-Ende mit [X]
	if [[ $exit_status -eq 1 ]] || [[ $exit_status -eq 70 ]] || [[ $exit_status -eq 252 ]]; then
		bash -c close_exit &>/dev/null
        exit 0
	fi
# 		
    if [[ ! -d "${dirname}" ]]; then
    fehler1
    fi
# 
cd $dirname
#
such0
#
# EOF

Unfortunately, I am lying sick in bed at the moment. Therefore, there was no time to translate the code into English.

Regards

Achim

Last edited by achim (2020-01-02 18:39:22)

Offline

Board footer

Powered by FluxBB