I'm having a weird problem and was hoping maybe someone out there might be able to give me some insight. Kind of at a loss.

On Linux Mint using Nemo which has a tendency to crash every once in a while with the annoying side-effect of shifting a bunch of my desktop icons. I thought I'd just write a quick script that would dump the locations of all my icons to a text file once a day, and then another to reposition them back where they are supposed to be.

It works perfectly when I run it manually, but not when it runs through cron.

I have figured out that the problem comes down to gvfs-info. Basically, I use the command:

gvfs-info -a 'metadata::nemo-icon-position' /path/to/file

which will produce:

metadata::nemo-icon-position: 220,682

in the output.

gvfs-info, however, needs to communicate with the dbus-daemon to get the metadata because it's actually stored in ~/.local/share/gvfs-metadata/. It can't access the dbus-daemon when it's being spawned from cron (or sudo or ssh for that matter)—a fact I discovered here and here which proposes a possible solution.

Following that solution, I can successfully execute from the terminal:

dbus-launch --exit-with-session /path/to/myscript.sh

and it works as expected. However it still produces the same output without the metadata. I've tried a lot of permutations of where I called dbus-launch and in combinations with 'su user' to ensure it's actually running as my user, but I guess I just don't understand what's going on here very well.

Anyone have any thoughts?


@steeldriver's comment was exactly what I needed (Thank you!).

I lifted the below from How to change Gsettings via remote shell and it was exactly what I needed!

PID=$(pidof -s nemo)
QUERY_ENVIRON="$(tr '\0' '\n' < /proc/${PID}/environ | grep "DBUS_SESSION_BUS_ADDRESS" | cut -d "=" -f 2-)"

I used 'nemo' because I know it would be running in my desktop environment.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.