Skip to content

Instantly share code, notes, and snippets.

Last active Jan 31, 2020
What would you like to do?
Use emblems in PCManFM for SliTaz

Emblem support in PCManFM

Emblem support was provided in commit Add emblem support by reading the "metadata::emblems" attribute provided by GFileInfo. and was included in the next libfm release, 1.3.0 dated 2018-04-21.

  1. Make sure you use PCManFM and LibFM not older than version 1.3.0.
  2. Put all the files from this gist in the file system. You will need root privileges to do this. Make sure the script in /usr/bin has execute permission.
  • gvfs-manage-emblems.desktop -> /usr/share/file-manager/actions/gvfs-manage-emblems.desktop
  • extended-menu.desktop -> /usr/share/file-manager/actions/extended-menu.desktop
  • gvfs-manage-emblems -> /usr/bin/gvfs-manage-emblems
  1. Make sure your icons theme contains emblems. For example, the Paper theme contains them in the /usr/share/icons/Paper/*/emblems/ folders, and the Faenza theme contains them in /usr/share/icons/Faenza/emblems/*/.
  2. Reload your PCManFM. If you do not know how to do this, restart the computer.
  3. Open PCManFM.
  4. Right click on any file or folder in file system (I repeat, this can be absolutely any file that you have access to, and even may not have write permissions).
  5. In the context menu locate the Extended Actions, and then click on Manage emblems.
  6. A dialog should open in which you can add and remove emblems for the selected file.
  7. Select the required emblems using checkboxes. Add any existing icon from the icon theme using its name by pressing "Add" button. Note, you can browse icon names using Icon Browser application. Click "Apply".
  8. Reload the folder in PCManFM (Ctrl+R). The emblems for the selected file or folder should be updated.
[Desktop Entry]
Tooltip=Extended Actions
Tooltip[ru]=Расширенные действия
# Manage file emblems
# Tool for use with PCManFM context menu in SliTaz Linux
# Aleksey Bobylev, 24 July 2019; 31 January 2020
# Input:
# $1 - mode: 'list' (default) or 'add' - used internally
# $2 - URI of the requested file (folder); it is may be prefixed
# by 'file://' protocol like 'file:///usr/bin' or with any other supported one
# (network file stores like smb://, etc.)
# Note, user can attach an emblems to any file or folder, for example to /bin/.
simpleURI="$(echo -n "$URI" | sed 's|file://||')"
# Semi-random list of available emblems since it's not standardized anywhere
AVAILABLE="emblem-default emblem-favorite emblem-important emblem-shared \
emblem-documents emblem-downloads emblem-music emblem-photos \
emblem-videos emblem-mail emblem-ok emblem-link emblem-symbolic-link \
emblem-generic emblem-new emblem-urgent emblem-web \
emblem-synchronizing emblem-system emblem-readonly emblem-unreadable"
# Get emblems from the requested file (folder).
# Responce of `gvfs-info -a 'metadata::emblems' /bin` looks like:
# uri: file:///bin <- can't switch off this line using gvfs-info attributes
# attributes: <- this too, and it's translatable
# metadata::emblems: [emblem-important, emblem-system] <- what we need
EMBLEMS=" $(gvfs-info -a 'metadata::emblems' $URI \
| sed -n '/metadata::emblems:/s|.*\[||;s|,||g;s|\]||p') "
# Result is " emblem-important emblem-system " (note all the spaces!)
#notify-send "mode=«$mode» URI=«$URI» simpleURI=«$simpleURI» EMBLEMS=«$EMBLEMS»"
# Auxiliary function for Yad: make the checkboxed list
# Find the rest of emblems to support any (already set) emblems not listed above
list_emblems() {
for i in $AVAILABLE; do
if [ "${EMBLEMS/$i /}" != "$EMBLEMS" ]; then
echo -n "true $i $i "
echo -n "false $i $i "
REST="${REST/$i /}"
for i in $REST; do
echo -n "true $i $i "
# Display Yad dialog
# Unfortunately, PCManFM don't redraw its window automatically, so to see
# updated emblems user need to refresh it manually (Ctrl+R or F5)
use_list() {
new_emblems=$(yad \
--mouse --width=300 --height=400 \
--window-icon=emblem-favorite \
--title="$simpleURI emblems" \
--image=emblem-favorite --image-on-top \
--text="Select the required emblems.
<i>Refresh the folder (Ctrl+R or F5) to update the view when done.</i>" \
--button='gtk-add:2' \
--button='gtk-cancel:1' \
--button='gtk-apply:0' \
--list \
--column='Select:CHK' \
--column='Icon:IMG' \
--column='Name:TEXT' \
--always-print-result --print-column='3' --separator='' \
--checklist \
$(list_emblems) \
case $code in
# Set the emblems
# New emblems should come as separate arguments, so $new_emblems isn't quoted here
# notify-send "gvfs-set-attribute \"$URI\" -t stringv metadata::emblems $new_emblems"
# URIsafe="$(echo "$URI" | sed 's|(|\\(|g;s|)|\\)|g')"
if [ -z $new_emblems ]; then
# remove all the emblems
gvfs-set-attribute $URI -t stringv metadata::emblems ''
gvfs-set-attribute $URI -t stringv metadata::emblems $new_emblems
$0 add "$URI"
# 1 = [Cancel], 252 = [Esc]
# Add arbitrary icon to the emblems
use_add() {
add_emblem=$(yad \
--mouse --width=300 --height=100 \
--window-icon=emblem-favorite \
--title="Add emblem" \
--image=emblem-favorite --image-on-top \
--text="Enter icon name you want to add to emblems.
Press the find icon to browse icons installed on your system, then close the icon browser and enter icon name manually." \
--button='gtk-cancel:1' \
--button='gtk-add:0' \
--entry \
--ricon='gtk-find' \
--ricon-action='yad-icon-browser &' \
case $code in
# Set the emblems
if [ -z $EMBLEMS -a -z $add_emblem ]; then
# remove all the emblems
gvfs-set-attribute $URI -t stringv metadata::emblems ''
gvfs-set-attribute $URI -t stringv metadata::emblems $EMBLEMS $add_emblem
# 1 = [Cancel], 252 = [Esc]
case $mode in
list) use_list;;
add) use_add;;
[Desktop Entry]
Name=Manage emblems
Name[ru]=Управление эмблемами
[X-Action-Profile gvfs-manage-emblems]
Exec=sh -c "gvfs-manage-emblems list %u 2>&1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment