You are not logged in.

#161 2020-03-31 02:49:57

damo
....moderator....
Registered: 2015-08-20
Posts: 6,734

Re: The great yad hacking thread

Are you aware of yad-icon-browser? Or is this just a personal project/exercise?


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

#162 2020-03-31 02:56:54

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

Re: The great yad hacking thread

It is a personal project. I don't know the yad-icon-browser yet. Where can I watch it?

Offline

#163 2020-03-31 03:40:33

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

Re: The great yad hacking thread

Thanks for the tip, I found the yad-icon browser. However, I find the "iconfind.sh" project even more comfortable. Therefore I would be very grateful for a support.

Last edited by achim (2020-03-31 03:50:00)

Offline

#164 2020-03-31 12:11:33

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

Re: The great yad hacking thread

Dear misko_2083, thank you for the quick help. I couldn't have done it without her. I have been observing for a long time that they always help users in the development of their projects in several forums (including Puppy Linux). I find this very remarkable, so I would like to expressly express my praise for it. For me, they are therefore explicitly "Mr. YAD". Finally two questions: Did you actually participate in the development of yad? Second, is it generally possible to influence the column widths in yad? This option would be particularly appropriate for "iconfind.sh".

Achimovski, (so you say in their homeland) wink

P.S. "But some icons are very big in the first column."

That is surely due to the icon size 256. I could also accept that I could exclude it from the search. Unfortunately, I don't know how to do that.

Last edited by achim (2020-03-31 12:19:31)

Offline

#165 2020-04-01 17:06:50

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

Re: The great yad hacking thread

With that I have come a lot further. Thanks a lot for this. In my opinion I have now reached the final phase, the script works very satisfactorily for me. If someone has suggestions for improvement, they are welcome to contribute them here. At this point, however, I would like once again misko_2083's willingness to help, but also the moderator damo, both of whom helped me with their excellent knowledge. This is not a matter of course. Maybe I can return the favor in some form.

Achim Achimovski wink

#!/bin/bash
# Name:iconfind.sh
# benötigt: sudo apt install rox-filer + sudo apt-get install libimage-exiftool-perl perl-doc 
#
function close_exit(){
    kill -s SIGUSR1 $YAD_PID
}
export -f close_exit
#
export fd=/home/achim/bin/icons
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 
exiftool $IMGPATH > /tmp/meta.txt 
GTK_THEME="gtk-3.0" yad --text-info --center --title=" Detailinformationen" --width=850 --height=600 \
--borders=15 --fixed --window-icon=$fd/Gnome-Dialog-Information-16.png --back=gainsboro \
--fore=black < /tmp/meta.txt fontname="Monospace 12" --button=" Schließen!$fd/Gnome-Process-Stop-32.png":1
}
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=";"

for f in /usr/share/icons/*/*/*/*.png; do     
     size=$(grep  -o "[0-9]\+x[0-9]\+" <<<"${f}")
     if [[ "$size" == "" ]]
     then
                   continue
     fi
#
     if [[ "$size" == "256" ]]
     then
                   continue
     fi
#
     if [[ "$size" == "512" ]]
     then
                   continue
     fi
#
     if [[ "$size" == "256x256" ]]
     then
                   continue
     fi
#
     if [[ "$size" == "512x512" ]]
     then
                   continue
     fi
#

printf "%s\n%s\n%s\n%s\n" "$f" "${f##*/}" "${size##*'x'}" "$f"
done | GTK_THEME="gtk-3.0" yad --list --geometry=1500x500 \
--wrap-width=300 \
--wrap-height=36 \
--window-icon="$fd/Gnome-System-Search-32.png" \
--title="  Icon-Finder" --center --borders=15 --fixed \
--select-action='bash -c "savevalues %s"' \
--column=icon:IMG \
--column=name \
--column=size: \
--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/Gnome-Process-Stop-32.png":1

	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

Last edited by achim (2020-04-01 17:09:29)

Offline

#166 2020-04-03 20:57:42

ohnonot
...again
Registered: 2015-09-29
Posts: 5,592

Re: The great yad hacking thread

Is it possible to (ab)use yad as an image viewer?

Is it possible to use keyboard shortcuts (e.g. spacebar for next image) in yad?

I had a look at the docs, the answer would seem to be no - or?

Offline

#167 2020-04-03 22:18:22

damo
....moderator....
Registered: 2015-08-20
Posts: 6,734

Re: The great yad hacking thread

ohnonot wrote:

Is it possible to (ab)use yad as an image viewer?

Is it possible to use keyboard shortcuts (e.g. spacebar for next image) in yad?

I had a look at the docs, the answer would seem to be no - or?

Kind of... Add the images to an array, then use --image=$IMAGE to display them (but they need to be scaled first to fit the yad window). Each image would need its own yad window, so the dialog needs to be in a while loop - see the bl tint2 and conky chooser scripts for examples of replacing yad windows with a loop.

I imagine xdotool could be used to simulate a button press to show the next image dialog.

Much easier to use feh (theme) though wink


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

#168 2020-04-05 08:48:52

ohnonot
...again
Registered: 2015-09-29
Posts: 5,592

Re: The great yad hacking thread

Thanks damo & misko.

damo wrote:

Add the images to an array, then use --image=$IMAGE to display them (but they need to be scaled first to fit the yad window). Each image would need its own yad window, so the dialog needs to be in a while loop - see the bl tint2 and conky chooser scripts for examples of replacing yad windows with a loop.

I imagine xdotool could be used to simulate a button press to show the next image dialog.

So each time I click the according button in the yad window it would advance in the array and display the next image?
I just tried the bl conky chooser, it does not even respond to e.g. Alt-c for close or Alt-a for apply.
I'm guessing yad is not very keyboard-friendly?

The reason I'm asking is because I want to loop through a directory with images and apply some simple modifications with imagemagick, if the user chooses so, and the option to save good-looking results as a new image.

Doesn't have to be yad.
I'm currently achieving this with a terminal script (utilizing w3mimgdisplay) but a GUI solution would be nicer.
However, spacebar for next image is the essential bare minimum keyboard functionality.

Offline

#169 2020-04-07 05:09:00

ohnonot
...again
Registered: 2015-09-29
Posts: 5,592

Re: The great yad hacking thread

^ Amazing!
Thanks for that information and the links.
It will take a little time to work through it, but gtkdialog is installed already (since bash is the default on ArchLinux I probably won't be needing gtkwialog).

Offline

#170 2020-06-15 21:23:37

Naik
Member
From: the edge of insanity
Registered: 2015-10-03
Posts: 328

Re: The great yad hacking thread

Hey there,

I recently added this to my prepend.csv for starting/stopping kali-anonsurf via jgmenu

^tag(anonsurf)
Back,^back()
Start,x-terminal-emulator -T 'AnonSurf' -r 'popterm' -c 'popterm' -p 'lithium' --geometry=420x123+430+340 -e "sudo anonsurf start; sleep 27s; exit"
Stopp,x-terminal-emulator -T 'AnonSurf' -r 'popterm' -c 'popterm' -p 'lithium' --geometry='420x123+430+340' -e "sudo anonsurf stop; sleep 27s; exit"

It works so far, only that the placing and geometry is not working and for the overall consitency of look and feel, I'd like to raise it with yad now.
My problems are:

1. anonsurf won't work when invoked with pkexec which would be need as I suggest and
2. I can't find a way to pipe stdout to yad to see what is happening.

Does any of you have an idea how to get around this?
Thanks for your help.

naik --greetz


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

Offline

#171 2020-06-16 01:42:56

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 12,560
Website

Re: The great yad hacking thread

The only options guaranteed to be supported by x-terminal-emulator are -T and -e.
https://www.debian.org/doc/debian-polic … l-emulator
Others you have used above ( -r -c  -p and --geometry ) depend on the terminal currently acting as x-terminal-emulator. If you need them to work you'll have to call that specific terminal instead.

Then, calling yad, getting a sudo password etc etc would probably be easier to handle if you put it all in a separate script (give it --start and --stop options), and called that from jgmenu.

You can get a password to run sudo with something like:

yad <options> --entry --hide-text | sudo -S <command>

Last edited by johnraff (2020-06-16 01:44:01)


...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 )

Introduction to the Bunsenlabs Boron Desktop

Offline

#172 2020-06-16 10:52:34

Naik
Member
From: the edge of insanity
Registered: 2015-10-03
Posts: 328

Re: The great yad hacking thread

Thanks for the quick reply!

johnraff wrote:

The only options guaranteed to be supported by x-terminal-emulator are -T and -e.
https://www.debian.org/doc/debian-polic … l-emulator
Others you have used above ( -r -c  -p and --geometry ) depend on the terminal currently acting as x-terminal-emulator. If you need them to work you'll have to call that specific terminal instead.

I tried that, but when I try calling terminator directly nothing happens at all, as if jgmenu refuses to cooperate with it (terminator == x-terminal-emulator BTW).

So you are saying I could come up with a little ~/bin/anonsurf-helper.sh
and call it like this in jgmenu:

yad <options> --entry --hide-text | sudo -S $HOME/bin/anonsurf-helper.sh

Sounds easy, but I guess I would not be able to see any of the output this script (or the comand invoked by it) is writing to stdout, right?

Is there any option to do so, other than piping it to a temporary logfile and opening another dialogue afterwards to print it?

naik --greetz


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

Offline

#173 2020-06-16 12:05:39

damo
....moderator....
Registered: 2015-08-20
Posts: 6,734

Re: The great yad hacking thread

Naik wrote:

...

Sounds easy, but I guess I would not be able to see any of the output this script (or the comand invoked by it) is writing to stdout, right?

Is there any option to do so, other than piping it to a temporary logfile and opening another dialogue afterwards to print it?

naik --greetz

Use tee and pipe it to a terminal?


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

#174 2020-06-17 01:25:55

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 12,560
Website

Re: The great yad hacking thread

Naik wrote:

So you are saying I could come up with a little ~/bin/anonsurf-helper.sh
and call it like this in jgmenu:

yad <options> --entry --hide-text | sudo -S $HOME/bin/anonsurf-helper.sh

Well, more like this, in prepend.csv:

^tag(anonsurf)
Back,^back()
Start,x-terminal-emulator -T 'AnonSurf' -e anonsurf-helper.sh --start
Stop,x-terminal-emulator -T 'AnonSurf' -e anonsurf-helper.sh --stop

I guess I would not be able to see any of the output this script (or the comand invoked by it) is writing to stdout, right?

If like above, then you'd open a terminal and then run the helper script in it, so you'd see the output. Also, if you're running the script in a terminal, you can use sudo as normal, no need for yad.


...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 )

Introduction to the Bunsenlabs Boron Desktop

Offline

#175 2020-06-17 20:07:45

Naik
Member
From: the edge of insanity
Registered: 2015-10-03
Posts: 328

Re: The great yad hacking thread

johnraff wrote:
Naik wrote:

So you are saying I could come up with a little ~/bin/anonsurf-helper.sh
and call it like this in jgmenu:

yad <options> --entry --hide-text | sudo -S $HOME/bin/anonsurf-helper.sh

Well, more like this, in prepend.csv:

^tag(anonsurf)
Back,^back()
Start,x-terminal-emulator -T 'AnonSurf' -e anonsurf-helper.sh --start
Stop,x-terminal-emulator -T 'AnonSurf' -e anonsurf-helper.sh --stop

I guess I would not be able to see any of the output this script (or the comand invoked by it) is writing to stdout, right?

If like above, then you'd open a terminal and then run the helper script in it, so you'd see the output. Also, if you're running the script in a terminal, you can use sudo as normal, no need for yad.

Running a terminal was exactly what I did at first but didn't find satisfying.
That's when I started thinking about yad in the first place.

With your patient help I put togther this little
anonsurf_helper

#!/bin/bash
#
# kali-anonsurf helper script
# provid a simple YAD-Interface for running Kali-Anonsurf
# provided under
# GNU General Public License v3.0 
# like https://github.com/Und3rf10w/kali-anonsurf itself
# by Naik <naik@nachtlicht.one>
# 
########################################################################

### Help message
function print_help {
		echo "AnonSurf_Helper"
		echo ""
		echo "Usage: anonsurf_help [command] [logfile]"
		echo ""
		echo "[Command] could be one of the following"
		echo "--help		Show this help"
		echo "--start	Start system-wide anonymous"
		echo	"			tunneling under TOR proxy through iptables"		
		echo "--stop 	Reset original iptables settings"
		echo "			and return to clear navigation"
		echo "--restart	Combines \"stop\" and \"start\" options"
		echo "--change	Changes identity restarting TOR"
		echo "--status	Check if AnonSurf is working properly"
		echo "--myip		Show your current IP address"
		echo ""
		echo "If run without arguments, one can be chosen from a yad dialogue later."
		echo "All output will be written to a single logfile [logfile]."
		echo "If none is specified its default is /tmp/anonsurf_helper.log"
		echo ""
		echo "GNU General Public License v3.0 like https://github.com/Und3rf10w/kali-anonsurf itself"
	exit
}
### Choose action via GUI
function choose_action {
	action=$(yad ---title="Anonsurf Helper" --window-icon="/home/naik/.local/share/icons/anon.png" --width=294 --posx=548 --height=184 --posy=133 --entry --button="gtk-ok:0" --button="gtk-close:1" --text "Was willst Du tun?:" --entry-text "Start" "Stop" "Change" "Restart" "Status" "MyIp")	
	echo $action
}

### check if /path/to/logfile is provided as second argument
### otherwise set default logfile to $HOME/tmp/anonsurf_helper.log
LOGFILE="/tmp/anonsurf_helper.log"
if touch $2; then
	LOGFILE=$2
    echo "Log will be written to "$LOGFILE"."
elif [ -f != $LOGFILE ]; then
	touch $LOGFILE
	echo "Log will be written to "$LOGFILE"." 
fi
### choose action
if [ -z "$1" ]; then
	choose_action
else
	action=$1
fi

case $action in

  --start|Start)
    yad --title="Anonsurf Helper" --window-icon="/home/naik/.local/share/icons/anon.png" --width=294 --posx=548 --height=84 --posy=333 --entry --hide-text | sudo -S anonsurf start > $LOGFILE 2>&1
    yad --notification --image="/home/naik/.local/share/icons/anon.png" --text="You are under AnonSurf tunnel." --listen --command="bash -c anonsurf_helper" &
    ;;
  --stop|Stop)
    yad --title="Anonsurf Helper" --window-icon="/home/naik/.local/share/icons/anon.png" --width=294 --height=84 --posx=548 --posy=333 --entry --hide-text | sudo -S anonsurf stop > $LOGFILE 2>&1 && 
    killall yad 2>/dev/null
    ;;
  --restart|Restart)
    yad --title="Anonsurf Helper" --window-icon="/home/naik/.local/share/icons/anon.png" --width=294 --height=84 --posx=548 --posy=333 --entry --hide-text | sudo -S anonsurf restart > $LOGFILE 2>&1
    ;;
  --change|Change)
    yad --title="Anonsurf Helper" --window-icon="/home/naik/.local/share/icons/anon.png" --width=294 --height=84 --posx=548 --posy=333 --entry --hide-text | sudo -S anonsurf change > $LOGFILE 2>&1
    ;;
  --status|Status)
    anonsurf status > $LOGFILE 2>&1
    ;;
  --myip|MyIP)
    anonsurf myip > $LOGFILE 2>&1
    ;;
  *)
    print_help
    ;;
esac
LOG=$( cat $LOGFILE| sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g" )
yad --title="Anonsurf Helper" --window-icon="/home/naik/.local/share/icons/anon.png" --width=420 --posx=430 --height=230 --posy=190 --text="$LOG"
exit

It is simply called from jgmenu like

^tag(anonsurf)
Back,^back()
Start,anonsurf_helper --start
Stop,anonsurf_helper --stop
Choose,anonsurf_helper

I really thank you!
The next thing for me is to provide a dialogue for choosing the action to take thus making $1 obsolete and figure out how to invoke a little systray icon together with the start command and kill it with the stop command, but this won't be done with yad I guess.

EDIT: It has been done and the script has been updated. I might take the time to make it click-able, but we will see.

EDIT2: Removed some unnecessary privilege escalations.

EDIT3: All TODOS have been done and the script has been Updated.
It now can be run without arguments directly from jgmenu and the choice will be made via YAD-dialogue. I only ask myself whether it would be better to clean up on exit with a trap. Usually I like clean stuff but there wouldn't be any log left for debugging...
Anyway, I'd say I'm happy for now!

Thanks again @jhonraff and all the others from whom I boroughed some snippet here and there.

naik --greetz

Last edited by Naik (2020-06-18 10:56:36)


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

Offline

#176 2020-08-04 07:42:05

yadbash
Member
From: Nevada, USA
Registered: 2017-12-27
Posts: 7
Website

Re: The great yad hacking thread

Hello all, I have not been on here for quite sometime as I have been focusing my work on a new easy Remaster process that only requires Gparted (or parted), rsync and dd commands. I am looking for some guidance as I want to build a YAD GUI / bash interface that will automate the manual process that I am using. Should I use a very large one file program where I can import source from config files like this:

. /file01.source

Or, should I call sub yad / bash files for the various steps ?

Here are the steps I take to remaster any Debian Based system that uses Grub Boot Loader.


The Process in detail copy using either rsync or dd with partitioning resizing using Gparted. Then syncing uuid=number in /etc/fstab & /etc/initramfs-tools/conf.d/resume files. then updating initramfs & updating /boot/grub/grub.cfg using sudo commands.

boot to 2nd partition
mount partition to be Re-spinned.

Copy from hard drive to hard drive (partition file system copy) using rsync (For example: sda2 --> sdb1)
NOTE: Shrink source partition using Gparted (rsync copy) or Fdisk to find byte sector count number (dd count=number)

sudo rsync -qaHAXS --progress /media/mounted-partition/ /media/target-partition/

dd command can be used to create a img file and it can be compressed with gzip for maximum compression:

sudo dd if=/dev/sdxX of=./dd-image-file-of-custom-build-partiton.img bs=4M status=progress && sync

dd img file can then be compressed for maximum comp[/ression. (Example 5GB --> 1.4GB)

gzip -k -9 ./dd-image-file-of-custom-build-partition.img

resulting file is: dd-image-file-of-custom-build-partition.img.gz

To decompress file:

gzip -d ./dd-image-file-of-custom-build-partition.img

Using dd command to copy custom build respin img file to hard drive or USB Stick partition:

sudo dd if=./dd-image-file-of-custom-build-partition.img of=/dev/sdxX bs=4M status=progress && sync

Note: When copying a partition it retains same uuid=number as source partition and this can not occur on same computer. The uuid=number needs to be changed in fstab & resume file. Then needs to be update in grub.cfg file:

Find correct uuid=number

sudo blkid

Hard Drive:
Insert correct uuid=number in the new target partition /etc/fstab & /etc/initiramfs-tools/conf.d/resume files

USB Stick - Change uuid=number using Gparted (also do swap partition if applicable)
Insert correct uuid=number in the new target partition /etc/fstab & /etc/initiramfs-tools/conf.d/resume files

Run Grub update on 2nd partition on hard drive & Reboot

Highlight new partition sdxX Grub Menu & Press "e" key. Verify the last uuid=number is same as other top uuid=number. Press "F10" key.

When booted in to new partiton: (dev/sdxX = new partitoin)

sudo update-initramfs -u && sudo grub-install /dev/sdxX && sudo update-grub

DONE !

NOTE: Special configuration for USB Stick.

I use a prebuilt USB Stick build from a 1 Megabyte dd img file that has MBR, Grub, 12GB ext4 & 3GB+ linux-swap partitions.

I suggest using Gparted and Grub commands to build a base bootable USB Stick. For exmaple on a 16GB USB Stick
12GB ext4 root partition & 3GB+ linux-swap partition.

Then use dd command to place your custom Q4OS Build image .img file in the root partition on USB Stick. /dev/sdxX   (not /dev/sdb)

Or the 1MB image and detailed instructions are here: https://github.com/godistros/GoDistrOS

Offline

#177 2020-08-04 13:31:30

damo
....moderator....
Registered: 2015-08-20
Posts: 6,734

Re: The great yad hacking thread

^ This sounds like a topic for a thread all on its own in eg Help & Support (Other).

And it sounds like a great project 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

#178 2020-08-05 06:39:11

ohnonot
...again
Registered: 2015-09-29
Posts: 5,592

Re: The great yad hacking thread

Since you want this to work for (all) Debain based ditros you'll be busy ironing out the functionality and making it more robust for the next year or so.
Asuming a yad-driven GUI means more work, I'd focus on CLI functionality first, and write it in a way that a gui "frontend" can be created for it evtl.

All in all, yes, this should be a thread all on its own.

Offline

#179 2020-08-05 07:03:00

Grover
New Member
Registered: 2020-08-03
Posts: 4

Re: The great yad hacking thread

>debian ISO remaster script Tomas Matejicek no need reinvent wheel

Offline

#180 2020-08-05 07:22:58

ohnonot
...again
Registered: 2015-09-29
Posts: 5,592

Re: The great yad hacking thread

Grover wrote:

>debian ISO remaster script Tomas Matejicek no need reinvent wheel

But there is a need to add links to your statements.
I guess you mean this but I could not find that script as a separate application.

Offline

Board footer

Powered by FluxBB