4

I'm trying to make a submenu entry on a .desktop application file that launches a youtube address with mpv. The youtube url is copied from the clipboard. Inside gnome-terminal this works fine:

xclip -o | xargs mpv

But if I make a .desktop action like this:

[Desktop Action mpv]
Name=mpv clipboard
Comment=Play the url on the clipboard with mpv
Exec=xclip -o | xargs mpv

It doesn't work. I have tried putting gnome-terminal -x before it, but it still doesn't work. How can it be done?

B Jog
  • 43
  • 4

1 Answers1

3

A pipeline is a shell feature, and .desktop launching does not involve a shell. You can use something like:

Exec=sh -c 'xclip -o | xargs mpv'

Or (depending on what's in the clipboard):

Exec=sh -c 'mpv "$(xclip -o)"'

Or put the command in an executable script file somewhere and use Exec=/path/to/script.

muru
  • 193,181
  • 53
  • 473
  • 722
  • Great! I assigned a keyboard shortcut to `mpv "$xclip -o"` in Kubuntu 18.04. No need for a .desktop file. – DK Bose Jun 24 '18 at 16:01