1

I'm trying to figure out if it's possible to create a something.desktop file in ~/.local/share/applications that successfully executes the command chromium --user-data-dir=$(mktemp -d) every time

The relevant line in the .desktop file is the Exec entry in the following example:

$ cat ~/.local/share/applications/something.desktop
[Desktop Entry]
Name=chromecognito
Exec=chromium --user-data-dir\=\$\(mktemp -d\)
Icon=chromecognito
Type=Application
Categories=GTK;GNOME;Utility;

I've seen this question, which references this document and tried various combinations of escapes of $, (, ), =, ", etc. in the Exec line, as well as working with single quotes, but haven't been able to get it to use a new temp directory every time the program is started from the "start menu"

As a side note, using the line Exec=/home/myuser/bin/chromecognito where /home/myuser/bin/chromecognito looks like this:

$ cat /home/myuser/bin/chromecognito
#! /usr/bin/env bash

(chromium --user-data-dir=$(mktemp -d) &)

works, although I haven't even successfully been able to use a tilde like ~/bin/chromecognito for the Exec entry in the .desktop file. Maybe that's is a good starting point.

Community
  • 1
  • 1
flooose
  • 499
  • 8
  • 25

1 Answers1

1
Exec=sh -c "chromium --user-data-dir=$(mktemp -d)"

Please note that both $(cmd) and ~ would be interpreted by the shell, so you must call a shell first to make those symbols work.

Karata
  • 1,079
  • 8
  • 16
  • That's it! Interestingly, I didn't need to escape the `$` or anything else, which, based on the above linked question and xdg-specification, I wouldn't have expected. – flooose Jul 31 '14 at 05:12