Go to file
2026-01-31 17:44:21 +00:00
copy_filename.py Initial commit for thunar-copy-button 2026-01-31 17:44:21 +00:00
install.sh Initial commit for thunar-copy-button 2026-01-31 17:44:21 +00:00
LICENSE Initial commit for thunar-copy-button 2026-01-31 17:44:21 +00:00
README.md Initial commit for thunar-copy-button 2026-01-31 17:44:21 +00:00

Thunar "Copy Filename" Custom Action

A simple Thunar Custom Action that adds a "Copy Filename" option to the right-click menu, allowing you to copy the full filename and extension of one or more selected files.

This implementation uses a very simple Python script (~600 bytes) with GTK3 to handle the clipboard, making it compatible with systems that don't have xclip or xsel installed.

Where is Thunar located?

  • Binary: The Thunar executable is usually at /usr/bin/thunar.
  • Configuration: Custom actions are stored in your user profile at ~/.config/Thunar/uca.xml.
  • System Actions: System-wide defaults are located at /etc/xdg/Thunar/uca.xml.

This tool installs to your user configuration (~/.config/Thunar/uca.xml), which is where other custom actions are stored. To add other custom actions, you can either edit the XML or head to Edit --> Configure custom actions.

Installation Guide (Automatic)

The easiest way to install or update the action is to use the provided install.sh script:

cd ~/path-to-program
chmod +x install.sh
./install.sh

Installation Guide (Manual)

1. Prerequisites

Ensure you have Python 3 and the GObject Introspection libraries for GTK3 installed. On most Debian/Ubuntu-based systems, you can install them with:

sudo apt update
sudo apt install python3 python3-gi gir1.2-gtk-3.0

These dependencies are usually installed by default on your system.

2. Download/Place the Script

Create a directory for the script and place copy_filename.py inside it.

mkdir -p ~/.config/Thunar/
# Move the script to this directory

3. Make the Script Executable

Ensure the script has execution permissions:

chmod +x ~/.config/Thunar/copy_filename.py

4. Add the Custom Action to Thunar (Manual)

  1. Open Thunar.
  2. Go to Edit -> Configure custom actions....
  3. Click the + (plus) button to add a new action.
  4. Fill in the Basic tab:
    • Name: Copy Filename
    • Description: Copy the filename and extension to clipboard
    • Command: /home/your-username/.config/Thunar/copy_filename.py %N (Note: Replace your-username with your actual username)
    • Icon: edit-copy (or any icon you prefer)
  5. Fill in the Appearance Conditions tab:
    • File Pattern: *
    • Check all the boxes (Directories, Audio files, Image files, etc.) to ensure it appears everywhere.
  6. Click OK and then Close.

5. Restart Thunar

You have to restart Thunar to get the action to appear:

thunar -q

How It Works

The copy_filename.py script takes the filenames passed by Thunar (via %N), joins them with newlines if multiple files are selected, and uses Gtk.Clipboard to store the text in the system clipboard.