Xfce Forum

Sub domains
 

You are not logged in.

#1 2025-07-13 00:45:55

dbaser
Member
From: Toronto, Canada
Registered: 2025-02-09
Posts: 35
LinuxFirefox 140.0

Bash script to set custom Thunar icon works everywhere but Desktop

I'm running Linux Mint 22.1 with XFCE and I've been having a good time theme-ing it. I have this bash script (found some variation of it on a forum) that sets a custom icon for a directory in Thunar:

#!/bin/bash
#
# This script supports several different names (zfolder, zcover) for a custom image file used as a folder icon, and includes the functionality to remove it if no longer needed

covers=("$2"/{.,}{zfolder,zcover}.{jpg,jpeg,png})
for f in "${covers[@]}"; do
  [ -f "$f" ] && {
    cover=$f
    break
  }
done
 
if [ -z "$cover" ] || ! convert -thumbnail "$1" "$cover" "$3"; then
  gdbus call --session --dest=org.freedesktop.thumbnails.Cache1 --object-path /org/freedesktop/thumbnails/Cache1 \
             --method org.freedesktop.thumbnails.Cache1.Delete "['$4']" >/dev/null
fi

Then I would drop an icon in the directory and name it `zcover.png` or `zcover.svg` and the icon is displayed in Thunar.

This works everywhere, including `~/Desktop`, meaning that if I open a Thunar window and navigate to the `home/user/` directory, I see the icon displayed for the `Desktop` directory.

However, the only place the icon does not display is on the actual Desktop itself (where you would see Home, Trash, and whatever other icons you have).

Just wondering if anyone knows why this would happen?


Linux Mint 22.1 XFCE 4.18

Offline

#2 2025-07-13 09:30:45

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 12,194
LinuxFirefox 140.0

Re: Bash script to set custom Thunar icon works everywhere but Desktop

I assume you also have an accompanying thumbnailer desktop file for this script?

Try refreshing (click somewhere on the desktop and press Ctrl+R) or restarting xfdesktop.

What version of xfdesktop does Mint 22.1 run?

Last edited by ToZ (2025-07-13 09:31:43)


Mark solved threads as [SOLVED] to make it easier for others to find solutions.
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#3 2025-07-14 04:31:42

dbaser
Member
From: Toronto, Canada
Registered: 2025-02-09
Posts: 35
LinuxFirefox 140.0

Re: Bash script to set custom Thunar icon works everywhere but Desktop

ToZ wrote:

I assume you also have an accompanying thumbnailer desktop file for this script?

I don't think so? What is a thumbnailer desktop file exactly? I think I'm just using the default thumbnailer.

ToZ wrote:

Try refreshing (click somewhere on the desktop and press Ctrl+R) or restarting xfdesktop.

Oh yeah, I should have mentioned that, I've tried many times with both Ctrl+R, F5, and reloading xfdesktop. It works everywhere else except for on the Desktop.

ToZ wrote:

What version of xfdesktop does Mint 22.1 run?

Mine shows 4.18.1 when checking from the command line:

$ xfdesktop -V
This is xfdesktop version 4.18.1, running on Xfce 4.18.
Built with GTK+ 3.24.41, linked with GTK+ 3.24.41.
Build options:
    Desktop Menu:        enabled
    Desktop Icons:       enabled
    Desktop File Icons:  enabled

Linux Mint 22.1 XFCE 4.18

Offline

#4 2025-07-14 09:47:36

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 12,194
LinuxFirefox 140.0

Re: Bash script to set custom Thunar icon works everywhere but Desktop

dbaser wrote:

ToZ wrote:

    I assume you also have an accompanying thumbnailer desktop file for this script?

I don't think so? What is a thumbnailer desktop file exactly? I think I'm just using the default thumbnailer.

The script you are using comes from the customized thumbnailer for folders and has an accompanying thumbnailer desktop file so tumbler can take care of the thumbnailing process automatically. If you are not using tumbler for this, how are you running the script?

Edit: just checked out Mint 22.1. xfdesktop 4.18 had code to do the thumbnailing built in to. I created a folder on the desktop, adding a jpg file into the folder and renamed it "folder.jpg", pressed Ctrl +R on the desktop and it displayed. Can you try this approach?

Last edited by ToZ (2025-07-14 15:16:35)


Mark solved threads as [SOLVED] to make it easier for others to find solutions.
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#5 2025-07-14 19:55:27

dbaser
Member
From: Toronto, Canada
Registered: 2025-02-09
Posts: 35
LinuxFirefox 140.0

Re: Bash script to set custom Thunar icon works everywhere but Desktop

ToZ wrote:

The script you are using comes from the customized thumbnailer for folders and has an accompanying thumbnailer desktop file so tumbler can take care of the thumbnailing process automatically. If you are not using tumbler for this, how are you running the script?

My bad, I do have one of those files:

$ cat ~/.local/share/thumbnailers/folder.thumbnailer 
[Thumbnailer Entry]
Version=1.0
Encoding=UTF-8
Type=X-Thumbnailer
Name=Folder Thumbnailer
MimeType=inode/directory;
Exec=sh -c '~/bash-scripts/folder-thumbnailer "$@"' _ %s %i %o %u

Crazy that you found the script! You're good!  lol

ToZ wrote:

Edit: just checked out Mint 22.1. xfdesktop 4.18 had code to do the thumbnailing built in to. I created a folder on the desktop, adding a jpg file into the folder and renamed it "folder.jpg", pressed Ctrl +R on the desktop and it displayed. Can you try this approach?

Sure, I tried it but no luck. Here are some screenshots to illustrate:

jpg-desktop-test-01-CROPPED.png

jpg-desktop-test-02-CROPPED.png

Last edited by dbaser (2025-07-14 19:58:52)


Linux Mint 22.1 XFCE 4.18

Offline

#6 2025-07-14 23:28:02

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 12,194
LinuxFirefox 140.0

Re: Bash script to set custom Thunar icon works everywhere but Desktop

Do you have a "~/bash-scripts/folder-thumbnailer" file?

As a test, can you try deleting the ~/.local/share/thumbnailers/folder.thumbnailer file? Log out and back in again and see if it works (the reason being that xfdesktop version 4.18 had built-in folder thumbnailing).


Mark solved threads as [SOLVED] to make it easier for others to find solutions.
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#7 2025-07-16 03:23:55

dbaser
Member
From: Toronto, Canada
Registered: 2025-02-09
Posts: 35
LinuxFirefox 140.0

Re: Bash script to set custom Thunar icon works everywhere but Desktop

ToZ wrote:

Do you have a "~/bash-scripts/folder-thumbnailer" file?

Yes that is the script I posted in my original post:

#!/bin/bash
#
# This script supports several different names (zfolder, zcover) for a custom image file used as a folder icon, and includes the functionality to remove it if no longer needed

covers=("$2"/{.,}{zfolder,zcover}.{jpg,jpeg,png})
for f in "${covers[@]}"; do
  [ -f "$f" ] && {
    cover=$f
    break
  }
done
 
if [ -z "$cover" ] || ! convert -thumbnail "$1" "$cover" "$3"; then
  gdbus call --session --dest=org.freedesktop.thumbnails.Cache1 --object-path /org/freedesktop/thumbnails/Cache1 \
             --method org.freedesktop.thumbnails.Cache1.Delete "['$4']" >/dev/null
fi

-

ToZ wrote:

As a test, can you try deleting the ~/.local/share/thumbnailers/folder.thumbnailer file? Log out and back in again and see if it works (the reason being that xfdesktop version 4.18 had built-in folder thumbnailing).

Just tried it but when logged back in, everything is the same. I can see it from within the home folder in Thunar but not on the actual Desktop.


Linux Mint 22.1 XFCE 4.18

Offline

#8 2025-07-16 10:02:59

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 12,194
LinuxFirefox 140.0

Re: Bash script to set custom Thunar icon works everywhere but Desktop

Can you post back:

ps -ef | grep -i desktop

Mark solved threads as [SOLVED] to make it easier for others to find solutions.
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#9 2025-07-16 21:35:45

dbaser
Member
From: Toronto, Canada
Registered: 2025-02-09
Posts: 35
LinuxFirefox 140.0

Re: Bash script to set custom Thunar icon works everywhere but Desktop

Sure here you go:

$ ps -ef | grep -i desktop
dbaser      2203    1909  0 Jul15 ?        00:00:00 /usr/libexec/xdg-desktop-portal
dbaser      2242    1909  0 Jul15 ?        00:00:00 /usr/libexec/xdg-desktop-portal-xapp
dbaser      8480    6334  0 Jul15 ?        00:00:02 xfdesktop --display :0.0 --sm-client-id 29f1a8d71-20fc-454c-93f9-a41c452a3596
dbaser     69670   69242  0 17:35 pts/1    00:00:00 grep --color=always -i desktop

Linux Mint 22.1 XFCE 4.18

Offline

#10 2025-07-16 21:39:37

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 12,194
LinuxFirefox 140.0

Re: Bash script to set custom Thunar icon works everywhere but Desktop

Hmmm.

Can you create a secondary account and try to see if it works without any additional scripts or anything? It should work right out of the box.


Mark solved threads as [SOLVED] to make it easier for others to find solutions.
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#11 2025-07-17 17:55:33

dbaser
Member
From: Toronto, Canada
Registered: 2025-02-09
Posts: 35
LinuxFirefox 140.0

Re: Bash script to set custom Thunar icon works everywhere but Desktop

Still nothing. I used the Users & Groups GUI tool to create a new user, logged out, then logged in with the new account. I grabbed a pic from '/usr/share/backgrounds/' and renamed it to 'zcover.png', tried to refresh with F5 and Ctrl-R and also tried logging out and back in with the new user, but it still does not show as an icon.


Linux Mint 22.1 XFCE 4.18

Offline

#12 2025-07-17 22:36:52

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 12,194
LinuxFirefox 140.0

Re: Bash script to set custom Thunar icon works everywhere but Desktop

dbaser wrote:

renamed it to 'zcover.png

Convert and rename it to folder.jpg to see if that works.


Mark solved threads as [SOLVED] to make it easier for others to find solutions.
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#13 2025-07-19 00:53:20

dbaser
Member
From: Toronto, Canada
Registered: 2025-02-09
Posts: 35
LinuxFirefox 140.0

Re: Bash script to set custom Thunar icon works everywhere but Desktop

ToZ wrote:

Convert and rename it to folder.jpg to see if that works.

Well this is interesting. I verified quickly on my last post, was on my way out the door. But on this second try I noticed that not only does the icon not show up on the Desktop, it does not show up within Thunar either. I tried zcover.jpeg, zcover.jpg, zcover.svg all with the same results. This is with the newly created account.

Nice! Thank you!

I tried again with Ctrl-R to refresh and got it working with 'folder.jpeg' with the newly created account. Logged into my real account, converted and changed to 'zfolder.jpg' to simply 'folder.jpg' and that also worked!

So weird, I wonder if it was the filename or the fact that it was PNG.

Last edited by dbaser (2025-07-19 01:49:44)


Linux Mint 22.1 XFCE 4.18

Offline

#14 2025-07-27 20:19:43

dbaser
Member
From: Toronto, Canada
Registered: 2025-02-09
Posts: 35
LinuxFirefox 141.0

Re: Bash script to set custom Thunar icon works everywhere but Desktop

Ok sorry to bug you again, but ever since I deleted my script, now the Desktop is the ONLY place this works. I used to have custom icons all over XFCE and now none of them work?!

It also does not work if I convert them to jpg and rename them to "folder.jpg"

Can you tell me what you meant by "xfdesktop has the code to do this" like what code and where is it? I was trying to figure this out but I can't. Why the hell is this so complicated???

Last edited by dbaser (2025-07-27 20:20:37)


Linux Mint 22.1 XFCE 4.18

Offline

#15 2025-07-27 20:34:44

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 12,194
LinuxFirefox 141.0

Re: Bash script to set custom Thunar icon works everywhere but Desktop

The version of xfdesktop that you have (4.18), had thumbnailing built-in. It was removed for 4.20 and now relies on tumbler for all thumbnailing (to make it less complicated).

Try re-adding your script so you can get thumbnails in thunar, but replace "zfolder,zcover" with just "folder,cover" so it aligns with what xfdesktop is doing - and rename your folder icons to match. Maybe this will solve your problem.


Mark solved threads as [SOLVED] to make it easier for others to find solutions.
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#16 2025-07-29 04:26:19

dbaser
Member
From: Toronto, Canada
Registered: 2025-02-09
Posts: 35
LinuxFirefox 141.0

Re: Bash script to set custom Thunar icon works everywhere but Desktop

ToZ wrote:

Try re-adding your script so you can get thumbnails in thunar, but replace "zfolder,zcover" with just "folder,cover" so it aligns with what xfdesktop is doing - and rename your folder icons to match. Maybe this will solve your problem.

I did this and at first it didn't work, so I went to the link you provided in post #4 and re-did everything to make sure it matched the examples.

While doing this I realized that I had the file `~/.local/share/thumbnailers/folder.thumbnailer` named `folder-thumbnailer` instead. I changed that and now everything works, including PNG files and naming it 'zfolder' like I wanted originally.

Thanks again!

Last edited by dbaser (2025-07-29 04:26:37)


Linux Mint 22.1 XFCE 4.18

Offline

Registered users online in this topic: 0, guests: 1
[Bot] ClaudeBot

Board footer

Powered by FluxBB
Modified by Visman

[ Generated in 0.012 seconds, 7 queries executed - Memory usage: 647.59 KiB (Peak: 680.43 KiB) ]