Thunar custom actions

Post your tutorials and howtos here.
User avatar
ilu
Posts: 2016
Joined: 09 Oct 2013 12:45

Thunar custom actions

Postby ilu » 15 Mar 2018 06:02

I don't like Thunar as a file manager since I prefer having two panes but custom actions are really useful. SolydX already comes with these: Open Terminal, Open Folder as root, Open file as root, Create symlink, GTK Hash, Mount/Unmount ISO, Burn ISO, Print File, Search, Install .ttf font, Rotate clockwise and Rotate counter-clockwise. I have some more and I'm always looking for suggestions. Sadly you can't just copy this code into your ~/.config/Thunar/uca.xml since it has unique-id tags (which I removed). You'll have to create the custom action (with the id) by giving it a name via the GUI. Now close all Thunar windows! You can then edit ~/.config/Thunar/uca.xml and copy-paste the rest. If you want to enter the commands posted here into the GUI you need to convert " to " and ' to '.

1. This one is really a must-have if you work with media files, Dependencies: mediainfo, zenity. The same functionality would be possible with ffmpeg/avconv but more complicated.

Code: Select all

<action>
	<icon>mediainfo</icon>
	<name>Media File Metadata</name>
	<command>mediainfo %N | zenity --text-info --title="Media Info" --width=600 --height=2000</command>
	<description>Grabs info from a media (audio/video) file using ffmpeg</description>
	<patterns>*</patterns>
	<audio-files/>
	<image-files/>
	<other-files/>
	<video-files/>
</action>
2. This helps to save storage space if you are not interested in the video part of a music video. Dependency: ffmpeg, but avconv should also work.

Code: Select all

<action>
	<icon>audio-card-symbolic</icon>
	<name>Extract M4A Audio</name>
	<command>bash -c &apos;ffmpeg -i "$0" -map 0:1 -c:a copy "${0%%.*}".m4a&apos; %F</command>
	<description>Extract as m4a</description>
	<patterns>*.flv;*.mp4</patterns>
	<video-files/>
</action>
3. Samba stuff - I'm not sure where I got these from and I don't use them :?

Code: Select all

<action>
	<icon>folder-remote</icon>
	<name>Samba public read-only</name>
	<command>net usershare add %n %f "" Everyone:R guest_ok=y</command>
	<description>Create a public read only samba share</description>
	<patterns>*</patterns>
	<directories/>
</action>
<action>
	<icon>folder-remote</icon>
	<name>Samba public writeable</name>
	<command>net usershare add %n %f "" Everyone:F guest_ok=y && chmod 777 %f</command>
	<description>Create a public writeable samba share</description>
	<patterns>*</patterns>
	<directories/>
</action>
<action>
	<icon>folder-remote</icon>
	<name>Samba remove share</name>
	<command>net usershare delete %n && chmod 755 %f</command>
	<description>Remove a samba share</description>
	<patterns>*</patterns>
	<directories/>
</action>
4. Stripping PDF meta data before publishing them is a must but difficult. This will purge the regular metadata but be aware that some applications might hide more metadata in the file (f.e. in embedded images). Dependencies: exiftool, qpdf.

Code: Select all

<action>
	<icon>application-pdf</icon>
	<name>Show PDF metadata</name>
	<command>pdftk %N dump_data  | zenity --text-info --title="PDF Toolkit" --width=600 --height=2000</command>
	<description>Show PDF metadata</description>
	<patterns>*.pdf</patterns>
	<other-files/>
</action>
<action>
	<icon>xpdf</icon>
	<name>Strip PDF</name>
	<command>exiftool -all:all=  -overwrite_original %f && qpdf --linearize %f stripped.pdf</command>
	<description>Permanently strip PDF metadata</description>
	<patterns>*.pdf</patterns>
	<other-files/>
</action>
It would be nice to replace "out.pdf" with some combination of the original filename and a number but I haven't figured out how.

I'd like to insert a new title and author tag with these ones, but sadly the input from zenity into the tag doesn't work. I'd need to get the zenity input into a variable and fill the tag from there ... can anybody help?

Code: Select all

<action>
	<icon>xpdf</icon>
	<name>PDF Title Tag</name>
	<command>exiftool -Title=" " %N | zenity --entry --title="Change title tag" --text="New title:" --entry-text=" "</command>
	<description>Enter a new title tag in PDF metadata</description>
	<patterns>*.pdf</patterns>
	<other-files/>
</action>
<action>
	<icon></icon>
	<name>PDF author</name>
	<command>exiftool -Author=" " %N | zenity --entry --title="Change author tag" --text="New author:" --entry-text=" "</command>
	<description>Edit PDF author tag</description>
	<patterns>*.pdf</patterns>
	<other-files/>
</action>
5. No idea if anybody else finds these two useful, I needed them:

Code: Select all

<action>
	<icon>arrow-right-double</icon>
	<name>ImgMergeHor</name>
	<command>convert +append %F joined-horizontal.png</command>
	<description>Glue images horizontally</description>
	<patterns>*</patterns>
	<image-files/>
</action>
<action>
	<icon>arrow-down-double</icon>
	<name>ImgMergeVer</name>
	<command>convert -append %F joined-vertical.png</command>
	<description>Glue images vertically</description>
	<patterns>*</patterns>
	<image-files/>
</action>
Does anybody have more suggestions for custom actions?

kurotsugi
Posts: 2098
Joined: 09 Jan 2014 00:17

Re: Thunar custom actions

Postby kurotsugi » 15 Mar 2018 08:56

interesting. I already use ffmpeg for converting the video stuff into mp3 for quite a long time. though, I tend to use higher bitrate to avoid missing stuffs on the compression stage.

User avatar
ilu
Posts: 2016
Joined: 09 Oct 2013 12:45

Re: Thunar custom actions

Postby ilu » 15 Mar 2018 17:31

Bitrate won't help you much with bits that are not there to begin with ... I use m4a because I want to keep original AAC encoding from the mp4 video. It's supposed to be just cutting out the audio without change. No re-encoding into mp3 means best possible quality. I haven't tested much but it seems to work. Feedback on quality welcome.

kurotsugi
Posts: 2098
Joined: 09 Jan 2014 00:17

Re: Thunar custom actions

Postby kurotsugi » 15 Mar 2018 22:47

I'm afraid not. AFAIK the process involves re-encoding regardless the output. the audio bits are streamed out then decoded into desired format. using m4a means that we will use aac compression instead of mp3. using aac indeed has some merits but in my experience the default setting simply doesn't cut for several kind of music. my personal reference for mp3 are : 128 is for speech and old music, 192 is for most modern music, 225 is for complex music, 320 is overkill.

if you doesn't want to do re-encoding, the solution would be downloading the audio straight from the source. for an example, youtube actually separated their audio and video stuff. you can use youtube-dl to only download the audio streaming. "youtube-dl -F" should gives you all the available formats.


Return to “Tutorials”

Who is online

Users browsing this forum: No registered users and 1 guest