Thunar Custom Action For Dropbox Public URL

by Paul Arnote (parnote)

Dropbox users on KDE can right click on a file in their Dropbox/Public folder in Dolphin or Konqueror and get the URL of the file to share with others. Dropbox users on Gnome can right click on a file in their Dropbox/Public folder in Nautilus and get the file to share with others. However, users of Xfce’s Thunar file manager had to resort to logging into their Dropbox account, via their web browser, and obtaining the URL of a file in their Dropbox/Public folder by right clicking on the file, then selecting to copy the URL to their clipboard. In fact, any user can do that on any desktop, but it’s a much slower process with many more steps.

Until now.

I recently made a Package Request in the PCLinuxOS forum for a command line utility we didn’t have in the PCLinuxOS repository. Now that the new command line utility has been graciously provided by our packagers, it’s possible to create a Custom Action in Thunar that gives Xfce users the same ability as their KDE and Gnome brethren. The packager who packaged the utility seemed to be a bit puzzled by my request, and about why I wanted it. Now that the cat is out of the bag, let me show you how to do it.

Step One

Open Synaptic, and make sure you are fully updated. Then, search for and install the “xclip” command line utility. Don’t worry. It’s a relatively small utility and it won’t take up much space on your system. The xclip utility copies information from the command line to your desktop clipboard. That information can be whatever textual data you obtain from the command line, or it could be entire files. It’s a handy little utility that I’m sure you can find other uses for. Check out the xclip man page for a full description of its capabilities.

Step Two

Now, you will need to install the Dropbox command line utility, called simply Being a Python script with no external dependencies, it won’t mess up your system. Follow this link and download it to the Downloads folder on your computer. The file is only 91 KiB in size.

On my computer, I went to the hidden .local folder in my /home directory, and created a new folder there called “dropbox-script.” I placed a copy of inside that new directory. I then set the file as executable in the “Permissions” tab of the file’s property settings.

Step Three

Next, we’ll make a small custom bash script to handle the calls to the script. Here’s the bash script that I wrote:

#! /bin/bash

s=`~/.local/dropbox-script/ puburl "$1"`

zenity --info --text="$s" && echo "$s" | xclip -selection c

I got my inspiration for this script from a Nautilus script that I found. As far as I know, Thunar can’t just use Nautilus scripts without alteration. So, I set out to alter the original Nautilus script so that I could use it with Thunar.

Of course, the first line identifies the script as a bash file. The second line feeds the results of the call to into the variable named “s.” Notice that I have pointed the bash script to the folder where I stored a copy of The third line displays the result of the call to in a Zenity dialog box, and then uses xclip to copy that result to your desktop clipboard.

I stored the bash script as in my /usr/bin directory. Don’t forget that you can only write files to the /usr/bin directory as the root user. (Hint: save a copy somewhere in your /home directory, then copy the file to your /usr/bin directory as root). Don’t forget to set the file as executable in the “Permissions” tab of the file’s property settings.

Step Four

Now we need to set up the Thunar custom action. If you’ve never created a Custom Action in Thunar, never fear – it’s relatively easy. Here’s a quick review. First, select the “Edit > Configure custom actions...” menu in Thunar. This will display the dialog box below.

Of course, you can see that I already have the Dropbox URL custom action set up. You will need to select the “+” button at the top of the row of buttons on the right to create a new custom action in Thunar. This will bring up a dialog box similar to the one below.

Fill in the fields as I have done in the image above. On the top line, type in a brief name for your new custom action. This is the text that will show up in the Thunar context menu. On the second line, type in a more descriptive phrase for your custom action. On the third line, type in the command you want to run. Notice that we are passing the Thunar command parameter “%f” as part of the command we want to run. The parameters are listed in the bottom half of the dialog box. Finally, click on the icon and select your own custom icon for the new custom action. DO NOT click on OK – yet. You now need to click on the “Appearance Conditions” tab at the top of the dialog box.

In the “File Pattern” line, type a single asterisk (“*”). Then, click on each of the check boxes to place a checkmark in every one of the appearance conditions. NOW you can click on the “OK” button. You will be taken back to the first dialog box. Select the “Close” button. Your new custom action will now appear at the bottom of the context menu when you right click on a file in Thunar.

Putting It To Use

Thanks to the script, it knows if you are in Dropbox’s Public folder or not. If you click on a file NOT in your Dropbox/Public folder, you will receive the Zenity dialog box below.

However, if you click on a file that IS in your Dropbox/Public folder, the public URL for that file will be displayed in the Zenity dialog box.

In either case, the text displayed in the Zenity dialog box is copied to your desktop clipboard when you select the “OK” button. I suppose the script could be enhanced to not copy the error message to the clipboard, but it works well enough for me, as is. I tend to subscribe to the K.I.S.S. principle – Keep It Super Simple.

Now, all that’s left is to paste the URL to your file in the Dropbox/Public directory from your clipboard into your email, chat client or instant messenger window to share the file.

Too Good To Be True?

Unfortunately, it was recently announced that new accounts created after July 31, 2012 will no longer have a “Public” folder. While you could create a new folder in your Dropbox folder called “Public,” it won’t have the same functionality as the Public folder created by the Dropbox installation. I first discovered this news from this entry on the Scripting News website. I confirmed it by checking at the Dropbox help site. No reasons or explanation for the change has been offered, and there’s only speculation as to the reason for the change at the Scripting News website. Current users will be allowed to retain their “Public” folders and all the functionality it now possesses – for now.

The resulting change will allow users to share links to any file in any of your Dropbox folders – even links to entire folders. However, the script, as it’s currently written, will only work with the Dropbox/Public folder as it is created by and setup by the current Dropbox installation.

Hopefully, someone will update the script to support the new change that allows users to obtain a link to any file in any of your Dropbox folders. Once that happens, the script will have even greater appeal and functionality. Until then, you can still use the laborious method of logging into the Dropbox website and right clicking on files in “other” directories to obtain the URL of a particular file or directory to share with others. It may take a while for the to be updated, since someone will have to figure out how to calculate the hash values that Dropbox applies to the files and folders when creating the link URLs.

Fortunately, this custom action – as well as the right click context menu items in KDE and Gnome – will continue to work with the Dropbox/Public folder, just so long as you are either a current Dropbox user, or just so long as you sign up for your Dropbox account before July 31, 2012. Again, for the time being, the functionality of the Dropbox/Public folder will remain intact for the aforementioned users.


Now, thanks to this relatively simple Thunar custom action addition, Xfce users can enjoy the same convenience feature as their KDE and Gnome cousins. Of course, the whole thing is possible, thanks to the xclip utility. It allows us an exceptionally easy way to get the necessary information to our desktop clipboard.