1

With xfce4-terminal (on Manjaro): Running chromium "$(xclip -o)" will open the Chromium web browser and visit the content of the clipboard (which is assumed to be a single URL).

I want a desktop launcher to do exactly this. Creating a new launcher (right click on the desktop > create launcher) with the above command in the command field won't work: Chromium is opened, but the address bar says %24%28xclip%20-o%29. What is happening? The tiny bit of bash knowledge I have tells me that I need to escape some characters -- which ones? I tried different things like chromium \"$(xclip -o)\" and chromium "\$\(xclip -o\)", which produce similar outcomes, but I can't figure it out.

I found this specification of launcher items, but I seemingly fail to understand it well enough to apply it to my problem. Or am I completely on the wrong track?

Another application would be this: xfce4-screenshooter -f -s "$(date +screenshot_%Y-%m-%d_%T.png)" takes a screenshot and names the resulting file with a time stamp. It works being directly run in the terminal, but not when configured as an application shortcut in the keyboard settings. Analogously, the file is named $(date +screenshot_%Y-%d_%m-%T.png).

Fred
  • 13
  • 3

1 Answers1

0

Try:

bash -c "chromium $(xclip -o)"

in your command field. That worked for me at least. (Also using Manjaro XFCE)

  • Great, that works! Can anyone explain what the launcher is doing with the `command` string or provide a resource where I could look this up (possibly something more comprehensible than the link I posted above)? I find this confusing. – Fred Feb 09 '21 at 20:19
  • Sorry, I was working off intuition more than anything. The "bash -c" wrapper is basically equivalent to running it as an external script (as someone else suggested). It "contains" it all under bash. It looked like chromium was trying to process the subshell output (maybe due to the command substitution writing to a pipe). Browsers escape spaces, and that is what I was seeing happen when testing. I found this useful: https://unix.stackexchange.com/questions/442692/is-a-subshell Look at the description of "command substitution" - it outputs to a pipe. – PendragonsFolly Feb 10 '21 at 16:50
  • So TL;DR from my above comment, I think the command substitution was being piped to chromium rather than passed as a parameter. – PendragonsFolly Feb 10 '21 at 16:54