You are not logged in.
Pages: 1
Greetings to y'all!
There's been some chatter about Ubuntu adding file-"Favorites" to their Gnome-DE. Come to think of it, many years ago when I left windoz behind, what I missed most was windoz' GUI-way of gathering shortcuts to frequently-used files in custom "toolbars".
So Ubuntu's announcement of collecting links to frequently used files in a new "Favorites" folder prompted me to use xfce's flexibility and devise a functionally equivalent solution to Ubuntu's, or Mate's "drawers".
I'm sure that the setup for this could easily be scripted, but it is really quite simple to set up:
1) create a new "Favorites" folder in one's $HOME-folder.
2) create as many subfolders under "Favorites" as desired, ie "ToDo", "Later", "WiP" etc.
3) add a new "custom action" to thunar, with the command line as follows, below ...
targetfolder=$(yad --title "Select target folder" --center --file-selection --directory --filename=$HOME/Favorites/*) && ln -s -t $targetfolder %F %N
4) add a "Directory Menu" plugin/button to the panel and point its "Base Directtory" to the new "Favorites" folder.
Done. So from now on, whenever I try to organize my downloads, or prioritze my work-in-progress docs, all I need to do is to invoke my new custom action and set up a link under "Favorites" to the file. This could easily be extended with other functions, ie to move or copy the files to their new target folder(s). But the new shortcuts work for me just fine.
PS: Because i could not get this to work right with "zenity", I installed "yad" from the repository and finished this project.
Linux Mint 21.3 -- xfce 4.18 ... Apple iMAC -- Lenovo, Dell, HP Desktops and Laptops -- Family & Community Support
Offline
Thanks for sharing. An interesting way to track. categorize and manage frequently used files.
Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki | Community | Contribute ---
Offline
I've been searching for months for a way to implement something like this.
I even started my own method to achieve something similar, using Thunar's "sendto" menu.
* Created some emblems for colors with this template (just change the fill color):
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="16" height="16">
<circle r="8" cx="8" cy="8" style="fill:blue"/>
</svg>
* Copy the created color emblems to say: $HOME/.icons/hicolor/scalable/emblems to ensure they will be available
* Create a .desktop template file for any color previously created (xdotool is needed to refresh Thunar's window):
[Desktop Entry]
Version=1.0
Name=Label Yellow
Comment=Tag Yellow
Exec=sh -c "gio set -t stringv %F metadata::emblems emblem-yellow;xdotool key F5"
Terminal=false
Icon=emblem-yellow
Type=Application
Next step would be to symlink the source files to the belonging colornamed folder. Something like $HOME/Favorites/yellow, but I can't get it to work together in the above Exec line.
Also a method to switch back (unemblem & remove symlinks files) will be needed to automate things. (gio set %F -t unset metadata::emblems ... or similar)
Any thoughts?
Thanks @mint4all for sharing this!
Last edited by MusXfceer (2021-09-08 09:39:58)
Offline
So, I've come to a partial solution
This will
* Create 8 color emblems
* Create companion color folders under $HOME/Favorites
* Create a side-panel bookmark named Favorites and
* Create the necessary .desktop actions under Thunar>SendTo menu
#!/bin/bash
emblems="$HOME/.icons/hicolor/scalable/emblems"
sendto="$HOME/.local/share/Thunar/sendto"
[ ! -d "$emblems" ] && mkdir -p "$emblems"
[ ! -d "$sendto" ] && mkdir -p "$sendto"
[ -d "$HOME"/Favorites ] || mkdir -p "$HOME"/Favorites
cd "$emblems" || exit
for color in blue green magenta orange purple red skyblue yellow; do
mkdir -p "$HOME"/Favorites/$color
cat > emblem-color-$color.svg<<EOF
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="16" height="16">
<circle r="8" cx="8" cy="8" style="fill:$color"/>
</svg>
EOF
cat > "$sendto"/label-$color.desktop<<EOF
[Desktop Entry]
Version=1.0
Name=Label $color
Comment=Tag $color
Exec=sh -c "for file in %F; do gio set -t stringv "\$file" metadata::emblems emblem-color-$color; touch -c -r "\$file" "\$file"; ln -sf "\$file" "\$HOME"/Favorites/$color/%N; done"
Terminal=false
Icon=emblem-color-$color
Type=Application
EOF
done
echo file://`echo $HOME`/Favorites >> $HOME/.config/gtk-3.0/bookmarks
What's left:
* Can't set various color emblems for one file. I.e. setting one color emblem will reset another.
* Add option to unlabel too. Maybe:
[[ "$(gio info -a metadata::emblems $file)" =~ emblem-color ]] && gio set "\$file" -t unset metadata::emblems; gio trash "\$file"
Can anyone test and give feedback?
Thanks so much in advance!
Last edited by MusXfceer (2021-09-10 18:14:06)
Offline
Just tested this and it works well.
* Can't set various color emblems for one file. I.e. setting one color emblem will reset another.
I'm pretty sure the system can only support one emblem at a time.
Add option to unlabel too
Agreed. There should be an option to "unfavorite" as well.
Other suggestions:
- your set up script should probably also have an "undo" or "uninstall" option that removes all the changes you've made
- when removing the favourite, you might want to consider processing the request based on either clicking on file itself, or the linked file in the favorites folder.
Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki | Community | Contribute ---
Offline
Just tested this and it works well.
Thanks for trying!
I'm pretty sure the system can only support one emblem at a time.
However this can be achieved by rightclick on file/folder --> properties --> emblems tab. You can check more than one emblem.
Agreed. There should be an option to "unfavorite" as well.
Was working on this, but the Exec line gets far more complicated for me... I'm not used to the Desktop Entry Spec. (and certainly not a coder)
Sample (not working) for label-yellow.desktop
Exec=sh -c "for file in %F;do if [ "$\(gio info -a metadata::emblems "$file" | grep yellow\)" ]; then gio set "$file" -t unset metadata::emblems; gio trash "$HOME"/Favorites/yellow/"$file"; else gio set -t stringv "$file" metadata::emblems emblem-color-yellow; touch -c -r "$file" "$file"; ln -sf "$file" "$HOME"/Favorites/yellow/%N;fi;done"
your set up script should probably also have an "undo" or "uninstall" option that removes all the changes you've made
Will work on this. Hope to get it done soon.
- when removing the favourite, you might want to consider processing the request based on either clicking on file itself, or the linked file in the favorites folder.
The idea is to send the symlink to the trash and remove the emblem of the original file.
Thanks!
Offline
You are right - depending on the size of the icon it can support up to 4 emblems. It looks like they are stored as an array:
metadata::emblems: [emblem-color-magenta, emblem-color-orange, emblem-color-purple, emblem-color-red, emblem-color-green]
Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki | Community | Contribute ---
Offline
As suggested, I've written the uninstall script:
#!/bin/bash
echo "This will uninstall color emblems from your system. "; tput setaf 3; tput bold
echo "***Warning*** this will permanently DELETE your "$HOME/Favorites" folder"; tput sgr0
read -p "Are you sure? (y/*) " -r
if [[ ! $REPLY =~ ^[Yy]$ ]]; then exit 1; fi
[[ -d $HOME/Favorites ]] && rm -rf "$HOME/Favorites"
sed -i '/Favorites/d' "$HOME/.config/gtk-3.0/bookmarks"
for color in blue green magenta orange purple red skyblue yellow
do
rm "$HOME/.icons/hicolor/scalable/emblems/emblem-color-$color.svg" 2>/dev/null
rm "$HOME/.local/share/Thunar/sendto/label-$color.desktop" 2>/dev/null
done
Also, updated the install script with some minor changes
Last edited by MusXfceer (2021-09-10 18:08:38)
Offline
Finally got it working.
Updated script (adds white emblem to untag action in Thunar's sendto menu). Also fixed bug and now allows files with spaces in their name:
#!/bin/bash
# Tag by colors in Thunar
#
emblems="$HOME/.icons/hicolor/scalable/emblems"
sendto="$HOME/.local/share/Thunar/sendto"
[ ! -d $emblems ] && mkdir -p $emblems
[ ! -d "$sendto" ] && mkdir -p "$sendto"
### from here to the end of the script, change Favorites to your preferred folder name (Spotlight, Starred, Scattergories... )
[ -d "$HOME"/Favorites ] || mkdir -p "$HOME"/Favorites
cd $emblems || exit
cat > emblem-color-white.svg<<EOF
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="16" height="16">
<ellipse cx="8" cy="8" rx="7.8" ry="7.8" fill="#f0f0f0" stroke="#000" stroke-width=".4"/>
</svg>
EOF
for color in blue green magenta orange purple red skyblue yellow; do
mkdir -p "$HOME"/Favorites/$color
cat > emblem-color-$color.svg<<EOF
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="16" height="16">
<circle r="8" cx="8" cy="8" style="fill:$color"/>
</svg>
EOF
cat > "$sendto"/label-$color.desktop<<EOF
[Desktop Entry]
Version=1.0
Name=Label $color
Comment=Tag $color
Exec=sh -c "for file in %F; do gio set -t stringv \"\$file\" metadata::emblems emblem-color-\$color; touch -c -r \"\$file\" \"\$file\"; ln -sf \"\$file\" \"\$HOME\"/Favorites/$color/%N; done"
Terminal=false
Icon=emblem-color-$color
Type=Application
EOF
done
echo file://`echo "$HOME"`/Favorites >> $HOME/.config/gtk-3.0/bookmarks
untag-color script: (chmod +x untag-color and copy it under /usr/local/bin or somewhere in your path, but keep in mind the .desktop file must follow the saved path)
#!/bin/sh
for file in "$@"
do
COLOR="$(gio info -a metadata::emblems "${file}" | grep 'metadata::emblems')"; COLOR="${COLOR##*-}"; COLOR="${COLOR%%]*}"
if [ ! -z $COLOR ]; then
gio set -t unset "${file}" metadata::emblems
touch -c -r "${file}" "${file}"
rm "$HOME/Favorites/$COLOR/${file##*/}"
fi
done
Untag color.desktop (Put it in your $HOME/.local/share/Thunar/sendto folder):
[Desktop Entry]
Name=Untag color
Comment=Remove color tag
#Exec=/home/<YOUR USER HERE>/.local/bin/untag-color %F
Exec=/usr/local/bin/untag-color %F
Terminal=false
Icon=emblem-color-white
Type=Application
This should solve also this question.
Cheers!
Offline
Pages: 1
[ Generated in 0.011 seconds, 7 queries executed - Memory usage: 597.29 KiB (Peak: 614.13 KiB) ]