KDE: klipper action script

筅森魡賤 提交于 2019-12-22 16:40:00

问题


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?"


回答1:


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.



来源:https://stackoverflow.com/questions/6664336/kde-klipper-action-script

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!