KSnapshot can be scripted using its DCOP interface. This chapter explains the various DCOP calls that you can use, and provides some examples of how you can use them.
As with all DCOP calls, you need to specify the application
you want to interface with, and the particular interface. With KSnapshot
you need to identify which particular application, which is
ksnapshot-
followed by the process number.
To start KSnapshot and obtain the right argument, use
dcopstart ksnapshot, which returns the
argument (such as ksnapshot-20594
) on
standard output.
You can get a list of the available DCOP interfaces, use the right arguments, as shown in this example:
$
dcop `dcopstart ksnapshot` interfaceQCStringList interfaces() QCStringList functions() TQString url() void slotGrab() void slotPrint() void slotSave() bool save(TQString filename) void slotSaveAs() void slotCopy() void setTime(int newTime) int timeout() void setURL(TQString newURL) void setGrabMode(int grab) int grabMode() void slotMovePointer(int x,int y) void exit()
In the examples following, the process is always
ksnapshot-23151
.
For each of the settings that you can control with the GUI, you can both obtain the current status of that setting, and modify the setting, using DCOP.
You can obtain the current capture mode using
grabMode
, as shown below:
$
dcop ksnapshot-23151 interface grabMode
This will return 0
for full-screen capture,
1
for window capture, and 2
for region capture.
You can set the capture mode using setGrabMode
,
which requires an argument to identify the mode required (as for grabMode
).
So you can set window capture mode (1), using:
$
dcop ksnapshot-23151 interface setGrabMode 1
You can obtain the current timeout setting (the Snapshot delay:
GUI item) using timeout
, as shown below:
$
dcop ksnapshot-23151 interface timeout
This will return the timeout setting in seconds, or zero if there is no delay
(capture on click).
You can set the timeout using setTime
,
which requires an argument to identify the timeout duration. So you can
set a delay of 4 seconds using:
$
dcop ksnapshot-23151 interface setTime 4
You can obtain the path that the snapshot will be saved to using
url
, as shown below:
$
dcop ksnapshot-23151 interface url
This will return the filename, as a URL (eg as
file:///home/bradh/test2.png
).
You can set the path using setURL
,
which requires a string argument to identify the new path. So you can
set the path to file:///home/bradh/snapshot.jpg
using:
$
dcop ksnapshot-23151 interface setURL file:///home/bradh/snapshot.jpg
Would you like to comment or contribute an update to this page?
Send feedback to the TDE Development Team