Thunderbird links to VLC / Opening clipboard in VLC

I am using VLC to play Youtube videos for various reasons. Links in a browser can just be dragged and dropped to the vlc launcher. However, when managing Youtube rss feeds in Thunderbird, the links can not be dragged and dropped, so usually you have to copy and paste them to vlc (Media – Open url from clipboard or Ctrl+V). I would like to streamline this process.

1. Open link in VLC on click

This would be the preferred behaviour. I can think of two staring points for this:

  1. Have Thunderbird directly open the URL in VLC
  2. Have Firefox (or other browser) automatically open Youtube URLs to VLC

I have not been able to accomplish a) without affecting all links in Thunderbird. For b), one could start by looking at this Firefox addon and automating the process. But even that behaviour might not be desirable in general.

2. Copy link to Clipboard and make VLC open clipboard contents on launch

This is the workaround I have come up with. Using the following three steps, you can set up your VLC launcher to automatically open the contents of the clipboard whenever you run VLC.

i. Accessing the clipboard via command line

Install xsel (thread with alternatives), from the repositories by running

sudo apt-get install xsel

in a terminal. (Now the command xsel --clipboard will output the clipboard.)

ii. Creating a context sensitive script

We want our script to pass the clipboard as an argument if no arguments are present, but still use arguments if present (e.g. when you open a file from your file browser): Copy the following into your favourite text editor:


if [ "$#" -eq 0 ]; then
CLIP=$(xsel --clipboard)
vlc $CLIP
/usr/bin/vlc --started-from-file "$@"

and save it e.g. to ~/.local/share/bin/ To make our script executable use your file managers properties dialogue or the command

sudo chmod +x ~/.local/share/bin/

in a terminal (adjusting the path to your script file if necessary).

iii. Editing the VLC launcher

Copy the starter /usr/share/applications/vlc.desktop to ~/.local/share/applications and edit the file there (or edit the file directly with su privileges to make it apply to all users, but in this case your script file should probably not be in your home folder).

Change the line starting with Exec to

Exec=bash /home/USERNAME/.local/bin/

(adjusting the path to point to your script file).

Now vlc will try to open any path in your clipboard, whenever you run it from the launcher or middle click on the launcher if VLC is already running.

Room for improvements

  1. If there is incompatible data in the clipboard, vlc will start with an error message and a playlist of defective items. This doesn’t bother me much. However, depending on the exact contents of the clipboard in rare cases, unwanted arguments could be passed to vlc and cause unwanted behaviour.
  2. The most tedious part of the process remains copying links from RSS feeds in Thunderbird, as there is no shortcut (known to me) to do so.


  1. Instead of the above, you can obviously use other means to make your script readily available:
    1. Create a keyboard shortcut.
    2. Create a quicklist item in the launcher’s right click menu, e.g. with Ubuntu tweak or by hand (latest .desktop launcher file specs).
    3. Create a separate launcher (place in /.local/share/applications or use a tool like this).

    Option c) saves a right click compared to option b), (if VLC is already running, you can use middle click on launcher icon). However, depending on whether or not you launch vlc from the original launcher or this one, you might end up with two vlc launcher icons, which is why I chose the solution described above.

  2. I first tried a way to open piped input in vlc (see also this wiki page), namely
    vlc -

    and opening the clipboard in VLC via

    xsel --clipboard | vlc -

    however, the vlc - command does not seem to work if vlc is set to allow one running instance only and is already running.

EDIT: Rearranged and improved.

Posted in media | Tagged , , , | Leave a comment


I do a lot of work (and non-work) on my computer and I like to fiddle with options and configurations to make those things easier and more convenient. I am sure I would save a lot of time by just leaving things as they are unless they are completely broken, but that is just not me, I like to fiddle around a lot. It is fun and it is satisfying when you get something done, but sometimes you just cannot figure something out, so finding someone that solved a similar problem and wrote about it online is a great help.

Therefore, I decided to start this blog to share my problems and solutions with people dealing with similar problems and possibly get some advice myself if I get stuck.

In the near future, topics on this blog will likely be Ubuntu, LaTeX, Rockbox, multimedia and occasional hardware struggles. It’s the digital life of hife.

Cheers >=]

Posted in introduction | Tagged , , | 1 Comment