2

So KDE's clipboard manager - klipper - allows one to write a script to be applied to clipboard contents matching regexp. Say, I want klipper to download an image through bash script.

Here's a klipper QRegExp:

^http://.*\.(png|svg|gif|jpg|jpeg)

I know that this regexp works - klipper notifies me every time I copy image URL to clipboard. Then, here's a bash script

#!/bin/bash
# let's name it clip.bash
name=`basename $1`
curl -o ~/Downloads/$name $1

I put this script to the PATH (I tried to feed this script with a image URL my self - it works), and finally I specify an action the following way:

clip.bash \%s

everything's fine and taken care about - but it doesn't work!

So my question is: "how to make klipper download an image through the bash script?"

Adobe
  • 12,967
  • 10
  • 85
  • 126

1 Answers1

2

First thoughts:

  1. Are you sure about the backslash before the '%'? I haven't access to KDE right now, but I'm not sure you need it.
  2. Are you sure that klipper "sees" your change to the PATH variable? You could try to use absolute path (something like "/home/../clip.bash")

If those don't work, you can try to log some debug info from your script. For example:

#!/bin/bash
name=`basename $1`
echo "curl -o ~/Downloads/$name $1" 1>&2

Run

tail ~/.xsession-errors

to see what command your script have just tried to execute.

Alexis
  • 4,317
  • 1
  • 25
  • 34
  • Using Your `tail ~/.xsession-errors` I found a series of mistakes. Them were: 1) klipper couldn't make use of .dbus. To fix that one should do: `chmod -R +rwx ~/.dbus` 2) to specify the full path to script in klipper, and make the call of the form: `/home/boris/scripts/clip.bash '%s'`. It's also proved very useful to toggle 'Output handling' to 'Add to clipboard' in klipper. Now it all works. Thanks for Your help. – Adobe Aug 10 '11 at 05:36