clipboard 0.1

clipboard is a little script for KDE that allows you to save things in your path.
clipboard is a little script for KDE that allows you to save things in your path and do stuff like:

1. paste current clipboard into file
2. clipboard > "some_file"
3. copy some file into clipboard
4. cat "some_file" > clipboard


Actually I find it rather useful so I thought I will have to share it.

Since KDE4 D-BUS is used throughout KDE and thus in Klipper as well. IMO they should really rework the output of dbus-send or add some more flags (what about --quiet). Well that's the reason why the script below is somewhat long. But nothing a little bit of bash+awk magic couldn't cope with:

#!/bin/bash

# check for stdin
# since we don't want to wait endlessly we set a timeout
# a pity `read` only supports seconds and no fractions...
read -t 1 stdin
if [[ "$stdin" != "" ]]; then
# get the rest of stdin
stdin=$stdin$(cat)
# oh, nice - user input! we set that as current
# clipboard content
dbus-send --type=method_call --dest=org.kde.klipper
/klipper org.kde.klipper.klipper.setClipboardContents
string:"$stdin"
exit
fi

# if we reach this point no user input was given and we
# print out the current contents of the clipboard
# note: I hate the output of dbus, dcop was much easier in that regard!
dbus-send --print-reply --dest=org.kde.klipper /klipper
org.kde.klipper.klipper.getClipboardContents | awk '
BEGIN { output = ""; }
{
if ( NR > 1 ) {
output = output $0 "n";
}
}
END {
print substr(output, 12, length(output) - 13);
}'


Requirements:

· running KDE4 session with Klipper
· bash
· awk

last updated on:
August 14th, 2008, 9:33 GMT
price:
FREE!
developed by:
Milian Wolff
homepage:
milianw.de
license type:
GPL (GNU General Public License) 
category:
ROOT \ Desktop Environment \ Tools

FREE!

In a hurry? Add it to your Download Basket!

user rating 5

3.0/5
 

0/5

Rate it!

Add your review!

SUBMIT