Yad File Browser

Moderator: Forum moderators

Post Reply
User avatar
stemsee
Posts: 726
Joined: Sun Jul 26, 2020 8:11 am
Location: lattitude 8
Has thanked: 177 times
Been thanked: 117 times

Yad File Browser

Post by stemsee »

Yad --icon --read-dir presents desktop files in a directory. If every file and every directory had a .desktop file representing it then that would make for a rudimentary file navigator, with executable functionality and higher levels of custom actionability per file or per dir. This makes for advanced customised security. So my experiment so far was to make a desktop file with the contents.

Code: Select all

[Desktop Entry]
Encoding=UTF-8
Name=root
GenericName=root
Icon=dir.png
Comment=directory
Exec=yad --icons --read-dir=/root
Terminal=false
Type=Application
Categories=File

and yes, it opens up a yad --icons --read-dir instance for /root. However i presently don't have .desktop files in /root representing files and dirs that are there. Of course creating them automatically would be trivial. Each would have an icon corresponding to a limited number of (mime) types. All dirs to any depth can be visible on the top plane, like a flattened tree. Files only get represented on opening a dir.desktop file. The Exec= string can be set automatically or manually. Just a simple backup file system navigator. I wonder how practical it would be?

Code: Select all

#!/bin/bash
for i in $(ls /)
do
echo "[Desktop Entry]
Encoding=UTF-8
Name=$i
GenericName=$i
Icon=dir.png
Comment=$i
Exec=yad --icons --read-dir=/$i
Terminal=false
Type=Application
Categories=File" > /tmp/$i.desktop
done

or better with find -max-depth -exec yfm.sh {} ... etc

Last edited by stemsee on Thu Jun 01, 2023 5:23 pm, edited 1 time in total.
User avatar
stemsee
Posts: 726
Joined: Sun Jul 26, 2020 8:11 am
Location: lattitude 8
Has thanked: 177 times
Been thanked: 117 times

Re: Yad File Manager

Post by stemsee »

Yes! It works as expected.

The best thing is to create directory desktop files next to the represented directory and link all directory desktop files to /tmp. Files get created next to the represented file, and are created according to case statements for appropriate Exec= strings according to file type, mostly text/doc file or executable. Fully working!

EDIT: there are a hell of a lot of desktop files all over the place, so I realise now that they should be moved into their own 'file system structure' in /tmp or /root. Even better made into a system sfs and loaded when required.

User avatar
stemsee
Posts: 726
Joined: Sun Jul 26, 2020 8:11 am
Location: lattitude 8
Has thanked: 177 times
Been thanked: 117 times

Re: Yad File Manager

Post by stemsee »

Here is a proof of concept. Needs some refinement.

Code: Select all

#!/bin/sh
# Copyright (C) 2023  stemsee
# gpl v3.0
#
function dirfn {
X="$(echo $@ | sed -e "s/.\///")"
 echo "[Desktop Entry]
Encoding=UTF-8
Name=$@
GenericName=$@
Icon=folder.png
Comment=$@
Exec=yad --icons --read-dir=$X --width=400 --height=400 --monitor
Terminal=false
Type=Application
Categories=File" >  /tmp/yfm/"$X".desktop
}; export -f dirfn
function crdesktop {
	X="$(echo $@ | sed -e "s/.\///")"
	case "$X" in
		*.sfs|*.squashfs) app='load_sfs.sh'
		Icon="squashfs-image48.png";;
	    http://*|https://*|*.webm|*.m4a|*.mp3|*.mp4|*.ogg|*.aac|*.flac|*.wav|*.wav64|*.mov|*.mpg|*.mpeg|*.vob|*.avi|*.flv*|*.webv*|*.mkv*) app='ffplay'
		Icon="audio48.png";;
		*.epub) app='cr3'
		Icon="cr3.png";;
		*.exe|*.msi) app='wine'
		Icon="wine.png";;
		*.png|*.xpm|*.svg|*.icn|*.ico|*.bmp|*.gif|*.jpg|*.webp) app='feh --scale-down'
		Icon="paint48.png";;
		*.odt|*.odf|*.odg|*.doc*|*.xlm|*.ppt*|*.xls|*.xls*) app='libreoffice'
		Icon="word48.png";;
		*.pdf) app='evince'
		Icon="evince.png";;
	    *.sh|*.py|*.scene) app='eval exec'
		Icon="xterm.png";;
		*.lst|*.txt|*.cfg|*.conf|*.log|*.info) app='geany'
		Icon="edit48.png";;
esac
echo "[Desktop Entry]
Encoding=UTF-8
Name=$X
GenericName=$X
Icon=/usr/local/lib/X11/pixmaps/$Icon
Comment=$X
Exec=$app $X
Terminal=false
Type=Application
Categories=File"  >  /tmp/yfm/"$X".desktop
}; export -f crdesktop
cd ../
find .  -maxdepth 4 -type d -exec mkdir -p '/tmp/yfm/{}' \; -exec bash -c 'dirfn "$@"' bash {}  \; 
find . -maxdepth 5 -type f -exec bash -c 'crdesktop "$@"' bash {}  \; 
for dir in dev proc sys run tmp  lib lib64  usr/lib usr/lib64 usr/include usr/src usr/libexec usr/mkspecs usr/man usr/doc usr/info 
do
rm -rf /tmp/yfm/*$dir
rm -f /tmp/yfm/*$dir.desktop
done
mksquashfs /tmp/ymf /tmp/yfm.sfs -comp xz
sleep 4
load_sfs.sh --quiet --load /tmp/yfm.sfs

User avatar
stemsee
Posts: 726
Joined: Sun Jul 26, 2020 8:11 am
Location: lattitude 8
Has thanked: 177 times
Been thanked: 117 times

Re: Yad as File Browser

Post by stemsee »

Yad File Browser is a simple file explorer which creates .desktop files with
execute string, icon and information.

Executing this script create a yfb directory in /tmp which is then populated with the
system's functional directories, no virtuals like /proc or /sys.
Then for each directory it creates a $dir.desktop file.
After this file.desktop files are created one for one with the running system.
When the creation processes have finished an yfb.sfs filesystem module is created
from the /tmp/yfb directory. Load this sfs and click on the desktop files
to browse directories and activate files. So far the number of files that can be
activated is not very extensive. Extensions can be added to the case statements
in the cdrdesktop function, along with execute strings and icons. Its use is
presently read only.

It uses yad --icons --read-dir="$dir-path" --monitor.

I may develope this further adding a list view navigator in yad paned mode.
The list view would give many more file manipulation possibilities including a popup menu.

Code: Select all

#!/bin/sh
# Copyright (C) 2023  stemsee
# gpl v3.0 for personal use
#  
function dirfn {

 echo "[Desktop Entry]
Encoding=UTF-8
Name=$@
GenericName=$@
Icon=folder48.png
Comment=$@
Exec=yad --title=\"yfb\" --window-icon=\"folder48.png\" --icons --read-dir=\"$@\" --width=400 --height=400 --monitor
Terminal=false
Type=Application
Categories=File" >  /tmp/yfb/"$@".desktop

}; export -f dirfn

function crdesktop {
	case "$@" in
		*.sfs|*.squashfs) app='load_sfs.sh --quiet --load'
		Icon="squashfs-image48.png";;
	    http://*|https://*|*.webm|*.m4a|*.mp3|*.mp4|*.ogg|*.aac|*.flac|*.wav|*.wav64|*.mov|*.mpg|*.mpeg|*.vob|*.avi|*.flv*|*.webv*|*.mkv*) app='ffplay'
		Icon="audio48.png";;
		*.epub) app='cr3'
		Icon="cr3.png";;
		*.exe|*.msi) app='wine'
		Icon="wine.png";;
		*.png|*.xpm|*.svg|*.icn|*.ico|*.bmp|*.gif|*.jpg|*.webp) app='feh --scale-down'
		Icon="paint48.png";;
		*.odt|*.odf|*.odg|*.doc*|*.xlm|*.ppt*|*.xls|*.xls*) app='libreoffice'
		Icon="word48.png";;
		*.pdf) app='evince'
		Icon="evince.png";;
	    *.sh|*.py|*.scene) app=''
		Icon="xterm.png";;
		*.lst|*.txt|*.cfg|*.conf|*.log|*.info) app='geany'
		Icon="edit48.png";;
esac
X=$(echo $@ | cut -c2-$$)
echo "[Desktop Entry]
Encoding=UTF-8
Name=$@
GenericName=$X
Icon=/usr/local/lib/X11/pixmaps/$Icon
Comment=$@
Exec=$app $@
Terminal=false
Type=Application
Categories=File"  >  /tmp/yfb/"$@".desktop

}; export -f crdesktop
mkdir -p /tmp/yfb
for i in /usr /home /root /opt /etc /mnt /bin /sbin /var
do
find $i -maxdepth 6 -type d  -exec mkdir -p '/tmp/yfb/{}' \;  -exec bash -c 'dirfn "$@"' bash {}  \;
done
for i in /usr /home /root /opt /etc /mnt /bin /sbin /var
do
find $i -maxdepth 7 -type f  -exec bash -c 'crdesktop "$@"' bash {}  \; 
done
mksquashfs /tmp/yfb /tmp/yfb.sfs -comp xz
sleep 4
load_sfs.sh --quiet --load /tmp/yfb.sfs
User avatar
stemsee
Posts: 726
Joined: Sun Jul 26, 2020 8:11 am
Location: lattitude 8
Has thanked: 177 times
Been thanked: 117 times

Re: Yad File Browser

Post by stemsee »

I need to research how to re-use the mime functions of the system instead or creating case statements for every type of extension.

vektor_alian
Posts: 48
Joined: Thu Apr 01, 2021 12:36 am
Been thanked: 12 times

Re: Yad File Browser

Post by vektor_alian »

Hi stemsee

A year has gone by and I am curious as to the status of your project.

I find the idea very interesting.

Vektor

User avatar
mikewalsh
Moderator
Posts: 6031
Joined: Tue Dec 03, 2019 1:40 pm
Location: King's Lynn, UK
Has thanked: 736 times
Been thanked: 1899 times

Re: Yad File Browser

Post by mikewalsh »

vektor_alian wrote: Tue Jul 23, 2024 1:54 pm

Hi stemsee

A year has gone by and I am curious as to the status of your project.

I find the idea very interesting.

Vektor

@vektor_alian :-

TBH, I'm really not sure if we'll see stemsee on the forums again. There was something of a bust-up recently, and stemsee insisted he wanted his a/c deleted.

He hasn't been back since then.

Mike. :|

vektor_alian
Posts: 48
Joined: Thu Apr 01, 2021 12:36 am
Been thanked: 12 times

Re: Yad File Browser

Post by vektor_alian »

Thanks for the sad news. All that knowledge.

Vektor

User avatar
stemsee
Posts: 726
Joined: Sun Jul 26, 2020 8:11 am
Location: lattitude 8
Has thanked: 177 times
Been thanked: 117 times

Re: Yad File Browser

Post by stemsee »

@vektor_alianThanks for your interest in YFB.

Improvements to make are to properly implement xdg --open
Also to programatically expand the yfb.sfs to /tmp and update desktop files, add remove, regularly etc
YFB.desktop files needs integrating with System Nonsuch App for a more practical experience.

Hi Mike, I am either fluctuating between standpoints or am in a superposition. :lol:

Post Reply

Return to “Desktop”