Discussion:
[Thunar-dev] Using %-style formatting in Thunar custom actions
fliehen
2017-06-09 12:15:37 UTC
Permalink
Good day everyone,

I've got a quick question regarding Thunar's custom actions!
I've made an action to split audio files using shnsplit -- pretty easy:

shnsplit -f %f -t "%n. %t" -o flac %d/$(basename %f .cue).flac

However, the formatting following the -t option is meant for shnsplit, not Thunar! Which means %n gets expanded into the file name.
I've also tried using just %t, which is not used by Thunar, and that also breaks it. Perhaps it gets expanded into nothing.

Is it impossible to give certain programs %-style formatting via custom actions?
I've tried escaping using "\", to no avail.

Thank you very much,
--
fliehen <***@posteo.net>
Mathias Brodala
2017-06-09 20:15:26 UTC
Permalink
Hi,
Post by fliehen
shnsplit -f %f -t "%n. %t" -o flac %d/$(basename %f .cue).flac
However, the formatting following the -t option is meant for
shnsplit, not Thunar! Which means %n gets expanded into the file
name. I've also tried using just %t, which is not used by Thunar, and
that also breaks it. Perhaps it gets expanded into nothing.
Is it impossible to give certain programs %-style formatting via
custom actions? I've tried escaping using "\", to no avail.
You should be escape the "%" via a 2nd "%", thus:

shnsplit -f %f -t "%%n. %%t" -o flac %d/$(basename %f .cue).flac

See source:
https://github.com/xfce-mirror/thunar/blob/a763a7f965b467c5e2dc504493fcbdef9b30209b/plugins/thunar-uca/thunar-uca-model.c#L1667-L1668

Regards, Mathias
fliehen
2017-06-09 21:05:23 UTC
Permalink
On Fri, 9 Jun 2017 22:15:26 +0200
Post by Mathias Brodala
You should be escape the "%" via a 2nd "%"
Ah, excellent! Thank you!
I'll be sure to check out the source code more often when the documentation is lacking. In fact, I think this deserves being added to the wiki page for Thunar actions, or perhaps even to the dialog itself!
--
fliehen <***@posteo.net>
Mathias Brodala
2017-06-09 22:45:42 UTC
Permalink
Hi,
Post by Mathias Brodala
You should be escape the "%" via a 2nd "%"
Ah, excellent! Thank you! I'll be sure to check out the source code
more often when the documentation is lacking. In fact, I think this
deserves being added to the wiki page for Thunar actions, or perhaps
even to the dialog itself!
I totally agree. Unfortunately I cannot find a way to log into
docs.xfce.org to edit the page, so if you can, go ahead. You might also
want to check Bugzilla if you'd like to see this mentioned in the
dialog, too.

Regards, Mathias

Loading...