0

I start music or video with right click and "open with" in Thunar (Xfce). For every entry, there is a *.desktop file in ~/.local/share/applications or /usr/share/applications. I want to start an application with a pipe and save the output in a file.

This works in terminal:

mpv file.mp4 > log 2>&1 

But that doesn't work when I add the same line to the desktop file:

Exec=mpv file.mp4 > log 2>&1 

The file is started, but there is no output. How can I do this? Is there something special when using desktop files? also starting with terminal=true, but that didn't work.

3
  • 2
    Try Exec=sh -c "mpv file.mp4 > log 2>&1" Commented Aug 13, 2024 at 21:30
  • @ G-Man Thats it, thanks. Commented Aug 14, 2024 at 12:10
  • @G-ManSays'ReinstateMonica' surprisingly this doesn't seem to have been answered before (at least, I couldn't find a convincing duplicate) - please consider turning your comment into an answer Commented Aug 14, 2024 at 13:10

1 Answer 1

0

Apparently Thunar (or whatever tool parses the desktop files) doesn’t understand shell syntax like > and 2>&1.  So the standard solution is to explicitly invoke a shell to handle the command, like this:

Exec=sh -c "mpv file.mp4 > log 2>&1" 

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.