You are not logged in.
In some folders I have many files that I read /process in no particular order (not according to alphabet or modification time).
I'd like to mark them, e.g. with colors (like "unread", "todo first", "do later" etc.)
Modern Thunar allows to "highlight" files in folder views with different colors for foreground and background.
It could be a very useful feature if it could be done fast, like:
right-click -> select menu option. Or
select file -> press hotkey
But currently it's a long process that partly defies the purpose of facilitating work:
right-click
select Properties
move the mouse to target "Highlight" tab and click it
select color
click Set Foreground or Set Background
click Apply
click Close
It's kinda tedious to perform all these seven operations just to mark a file, if I want to do that a dozen times a day.
So I'm thinking, is there a way to mark a file that way from CLI?
Then I could make a script and use it with a hotkey or two, or with "Thunar's custom actions".
Last edited by chang-zhao (2024-01-16 02:46:39)
Offline
Thunar uses gio metadata to store this info.
To set a highlight color:
gio set FOLDER metadata::thunar-highlight-color-background "rgb(x,x,x)"
...and to remove the highlight:
gio set -t unset FOLDER metadata::thunar-highlight-color-background
*Important to note that you have manually refresh the thunar screen for the change to happen visually.
Here is a script I wrote a while back as a proof of concept that you may find helpful:
#!/bin/bash
# $1 can be a color or "unset"
COLOR=$1
case $COLOR in
red) COL="rgb(255,0,0)" ;;
green) COL="rgb(0,255,0)" ;;
blue) COL="rgb(0,0,255)" ;;
esac
# shift to next set of parameters - the folders to affect
shift
# if unset was passed, then remove all highlighting
if [ "$COLOR" == "unset" ]
then
for FOLDER in $@
do
gio set -t unset "$FOLDER" metadata::thunar-highlight-color-background
done
# otherwise highlight the folders
else
for FOLDER in $@
do
gio set "$FOLDER" metadata::thunar-highlight-color-background "$COL"
done
fi
# refresh the thunar window
xdotool key F5
For the custom actions, create them like this:
- Name = Highlight Red
- Submenu = Highlight
- Command = /path/to/script red %F
- Appearance = Directories only
...create one for every color you want and make sure you define the color in the case statement at the top of the script.
And to unset the highlight:
- Name = Unset Highlight
- Submenu = Highlight
- Command = /path/to/script unset %F
- Appearance = Directories only
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
Thank you!
I added `"` around arguments, to process file names with spaces; and set colors and their codes to highlight a few "roles":
unread,
later,
todo.
Script:
#!/bin/bash
# $1 is a coloring code or "unset"
COLOR="$1"
case "$COLOR" in
todo) COL="rgb(255,230,200)" ;;
later) COL="rgb(220,220,220)" ;;
unread) COL="rgb(220,255,220)" ;;
esac
# shift to next set of parameters - the files to affect
shift
# if unset was passed, then remove all highlighting
if [ "$COLOR" == "unset" ]
then
for DO_FILE in "$@"
do
gio set -t unset "$DO_FILE" metadata::thunar-highlight-color-background
done
# otherwise highlight the files
else
for DO_FILE in "$@"
do
gio set "$DO_FILE" metadata::thunar-highlight-color-background "$COL"
done
fi
# refresh the thunar window
xdotool key F5
Last edited by chang-zhao (2024-01-16 04:46:27)
Offline
[ Generated in 0.008 seconds, 7 queries executed - Memory usage: 534.8 KiB (Peak: 535.64 KiB) ]