You are not logged in.
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
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 Codeberg
Offline
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
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
[...]
@ 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 Codeberg
Offline
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
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/decrypteddone
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
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/decrypteddone
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
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
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
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
general recommendation for yad users:
https://sourceforge.net/p/yad-dialog/wiki/browse_pages/
Offline
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
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
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
Gute Besserung
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
I changed the code under # 200 a bit and translated the important parts into English.
Greetings,
Achim
PS. @secureIT, please contact me via pm.
Last edited by achim (2020-01-02 18:46:26)
Offline
^ @misko, you know of course that BL already ships a conky mover that does save the position?
Preferences > Conky > Move a Conky
(The script is quite a bit longer than yours though.)
...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )
Offline
Off Topic
Mine is shorter: [Alt]+[Click-n-Hold] a conky and move it.
Debian 12 Beardog, SoxDog and still a Conky 1.9er
Offline
Hello everyone, I hope everyone is fine and nobody has contracted this dangerous virus. I am currently distracting myself and modifying various yad scripts. However, I now have a problem with this icon finder and need help. The script works with the commented out find command in line without problems, but my variant "for f in do" finds more icons from lines 21 to 23, although I am limited to "png". The results are redirected to a text file, but so far I have not been able to read them formatted with yad.
Does anyone have any idea how it could work?
Stay healthy, achim
#!/bin/bash
# Name:iconfind.sh
# benötigt: sudo apt install rox-filer + sudo apt install gxmessage
#
XMESSAGE=$(which gxmessage) || XMESSAGE=xmessage
fd="/home/achim/bin/icons"
function close_exit(){
kill -s SIGUSR1 $YAD_PID
}
export -f close_exit
#
export TMPFILE=/tmp/yadvalues
function savevalues { echo -e "IMGNAME=\"$2\"\nIMGSIZE=$3\nIMGPATH=\"$4\"" > $TMPFILE ;} ; export -f savevalues
function showinfo { source $TMPFILE ; exiv2 "$IMGPATH" 2>/dev/null | xmessage -file -c -geometry 400x300 -f monospace ;} ; export -f showinfo
function showinrox { source $TMPFILE ; rox -s "$IMGPATH" ;} ; export -f showinrox
function copypath { source $TMPFILE ; echo -n "$IMGPATH" | xclip -i -selection clipboard ;} ; export -f copypath
SEP=";"
# FOUND=$(find -L /usr/share/icons/Mint-Y/actions/22 -regextype gnu-awk -iregex ".*\.(svg|png|jpg|gif|xpm)$" -printf "%p${SEP}%f${SEP}%s${SEP}%p${SEP}")
for f in /usr/share/icons/*/*/*/*.png; do
echo "$f" >> /tmp/test.txt
done
exit
IFS=$SEP
GTK_THEME="gtk-3.0" yad --list --geometry=1500x500 \
--window-icon="$fd/Gnome-System-Search-32.png" \
--title=" Icon-Finder" --center \
--select-action='bash -c "savevalues %s"' \
--column=icon:IMG \
--column=name \
--column=size:NUM \
--column=path \
--button=" Info!$fd/Gnome-Dialog-Information-32.png":'bash -c "showinfo"' \
--button=" Zeige Standort!$fd/locale32.png":'bash -c "showinrox"' \
--button=" Pfad kopieren!$fd/copy32.png":'bash -c "copypath"' \
--button=" Beenden!$fd/close-program-32.png":1
<< /tmp/test.txt
ac=$(echo $?) # Exit-Code auswerten
if [[ $ac == 1 ]] || [[ $ac == 9 ]] || [[ $ac == 252 ]]; then # Taste Abbrechen gedrückt || Skript-Ende mit [X] || Skript-Ende mit [Esc]
bash -c close_exit &>/dev/null
exit
fi
exit
Text that has to be colorized
Offline