| copy_filename.py | ||
| COPYING | ||
| install.sh | ||
| README.md | ||
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)
- Open Thunar.
- Go to Edit -> Configure custom actions....
- Click the + (plus) button to add a new action.
- 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: Replaceyour-usernamewith your actual username) - Icon:
edit-copy(or any icon you prefer)
- Fill in the Appearance Conditions tab:
- File Pattern:
* - Check all the boxes (Directories, Audio files, Image files, etc.) to ensure it appears everywhere.
- File Pattern:
- 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.