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=`basena开发者_如何学JAVAme $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?"
First thoughts:
- Are you sure about the backslash before the '%'? I haven't access to KDE right now, but I'm not sure you need it.
- 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.
精彩评论