[root] Create Thunar custom actions

Thunar file manager - and maybe others too - allows the user to create custom actions.

Long time ago I created a guide on how to create custom actions along with some examples.


All custom actions are defined using the Configure custom actions… dialog in Thunar. It is found in the Edit menu.

All examples will follow the pattern

  • Navigate the Edit menu
  • Click Configure custom actions…
  • Click + to add an action
  • Configure the action
  • Save the action

Only the first example will detail the action of opening the Configure custom action dialog

Write ISO to USB

For ISO writing I have a preference for Mint stick. I am thinking it is because it does 2 two things and does it well. There is several benefits using Mint stick

  • Mint stick only allows USB devices
  • USB device formatting
  • USB image writing

Build mintstick package

  • Using makepkg

    git clone https://aur.archlinux.org/mintstick.git
    cd mintstick
    makepkg -is
  • Using yay

    yay -S mintstick

Open Thunar and navigate to EditConfigure custom actions…

  • Click the + add an action

    • Name: Write to USB
    • Description: Write selected ISO to USB
    • Command: mintstick -m iso -i %f
  • Select a nice icon by clicking the icon e.g.

    • from the Device icons dropdown locate the media-flash-memory-stick icon.
  • Click the Appearance Conditions tab

    • File patter: *.iso
    • Select only the Other Files option
    • Shortcut: Click and press e.g. F7
      Click OK and close the window.

Test it by navigating to a folder containing an ISO. Then right click the ISO and select the new Write to USB option.

Close Mint stick and test selected shortcut e.g. F7.

Open terminal here

Opening a terminal in a folder is probably one of the most useful features of the file manager. You can use a named terminal or you can use the exo-open app to launch the system’s terminal defined by Preferred applications. To be able to use this you need the package exo installed. You can check if it is installed using which exo-open.

Click + in the custom actions dialog to configure a new action

  • Name: Open Terminal Here
  • Description: Open terminal in current folder

How do we get it to open in the folder currently open in Thunar?
At the bottom of the Basics tab is a list of parameters you can use when executing a command.

In this case we want the current folder to be the location opened in the terminal.

We look at the list and fine the %d parameter

%d    directory containing the file that is passed in %f

Another parameter is referenced %f and this is exactly what we need

%f    the path to the first selected file or directory

So our command will be

  • Command: exo-open --launch TerminalEmulator %d

Next is shortcut

  • Keyboard Shortcut: F4

And icon

  • Select a suitable icon - a terminal

Now move to the Appearance Conditions tab

  • File Pattern: *
  • Select only the Directories option

Save the action by clicking OK

Launch Thunar as root

Click + in the custom actions dialog to configure a new action

  • Name: Open Thunar as ROOT
  • Description: Open Thunar as ROOT
  • Command: thunar admin:%d

The admin: is a protocol which allows for tasks to be launched with administrative privileges. We are again using the %d parameter to use the current folder for root actions.

  • Keyboard Shortcut: CtrlF8

And icon

  • Select a suitable icon - red folder as a consequence alert

Now move to the Appearance Conditions tab

  • File Pattern: *
  • Select Directories, Text Files and Other Files option

Save the action by clicking OK

Edit config as root using GUI

Click + in the custom actions dialog to configure a new action

  • Name: Edit file as ROOT
  • Description: Edit file as ROOT
  • Command: xed admin:%f

The command should be an editor supporting the admin protocol. This is true for xed and gedit. We use the %f parameter to pass the full path of the selected file to the editor

  • Keyboard Shortcut: None

And icon

  • Select a suitable icon - something signifying the consequence of the action

Now move to the Appearance Conditions tab

  • File Pattern: *
  • Select only the Text Files option

Save the action by clicking OK

Shred files or folders

Some time ago I answered a question on how to implement a custom shred action to Thunar.

That sent me on a search and I found a very nice solution on github

Recreate on other systems

Creating the actions from scratch is a tedious task - if you have many. The easy way is to copy this file to another system.



Interesting variations here - thanks for posting. I’ve only just edited items into uca.xml directly - never knew of the alternative!

Some things are a bit different for me - I use ‘pkexec thunar’ for open as root, and once it’s open, right-clicking a file allow editing as root from there.

How does one find out which editors are a ‘admin’ friendly? I’ve been using leafpad or featherpad so far - but I’ve seen others suggested!

Thanks - knowledge is a wonderful thing… :postal_horn:

I have been using the trial-n-error approach :slight_smile:

And yes pkexec is supposed to be the successor of various ways of executing graphical applications as root. The reason being the giant security hole from running xorg with root permissions.

That discussion is very heated and opinionated and nothing I will go into. An example is the discussion when KDE removed the ability to use kate to edit a file as root. What a hell that broke loose :grin:

The thing with pkexec - is the requirement of an application to have polkit rules defined - and in reality very few GUI applications needs to be run as root.

1 Like