<appendix id= "useraction_xml">
<!-- **********************************************************************
installation.docbook
++++++++++++++++++++++++++
copyright : (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006
Rafi Yanai, Shie Erlich, Frank Schoolmeesters
& the Krusader Krew
e-mail : krusader@users.sourceforge.net
web site : http://www.krusader.org
description : a Krusader Documentation File
***************************************************************************
* Permission is granted to copy, distribute and/or modify this *
* document under the terms of the GNU Free Documentation License, *
* Version 1.1 or any later version published by the Free Software *
* Foundation; with no Invariant Sections, no Front-Cover Texts and *
* no Back-Cover Texts. A copy of the license is available on the *
* GNU site http://www.gnu.org/licenses/fdl.html or by writing to: *
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, *
* MA 02110-1301, USA. *
*********************************************************************** -->
<title
>useraction.xml</title>
<para
>This appendix gives several examples of <filename
>useraction.xml</filename
> files. With this you can begin to discover the power of the &useractions_lnk; and start learning how to use them. Once you understand how to write UserActions you will find that &krusader; is an even more powerful, customizable tool. </para>
<para
>Please consider to upload your UserActions at &kde_files_url;. We are collecting UserActions, if your UserAction is selected by us it will be shipped with &krusader; at the next release. We provide also an &useractionsforum_url;. </para>
<itemizedlist>
<listitem
><para
>Runs <command
>uptime</command
> <programlisting
><?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE KrusaderUserActions>
<KrusaderUserActions>
<action name="uptime" >
<title>Up-time</title>
<tooltip>tells how long since the computer has been booted</tooltip>
<icon>clock</icon>
<category>information</category>
<description>tells how long since the computer has been booted</description>
<command executionmode="collect_output" >uptime</command>
<defaultshortcut>Alt+Ctrl+U</defaultshortcut>
</action>
</KrusaderUserActions></programlisting>
</para
></listitem>
<listitem
><para
>Runs <command
>ls -l</command
> <programlisting
><?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE KrusaderUserActions>
<KrusaderUserActions>
<action name="ls -l" >
<title>ls -l in current dir</title>
<description>Runs ls -l in current dir</description>
<command executionmode="collect_output" >ls -l %aPath% %oPath%</command>
</action>
</KrusaderUserActions></programlisting>
</para
></listitem>
<listitem
><para
>Echo Placeholder <programlisting
><?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE KrusaderUserActions>
<KrusaderUserActions>
<action name="test_placeholder" >
<title>Echo Placeholder</title>
<tooltip>Echo's the placeholder values</tooltip>
<category>Testing</category>
<description>Echo's the placeholder values</description>
<command executionmode="collect_output" onmultiplefiles="call_each" >echo -e "aPath %aPath()% \naCurrent: %aCurrent()%"</command>
</action>
</KrusaderUserActions></programlisting>
</para
></listitem>
<listitem
><para
>This useraction copies current path and filename to clipboard: <programlisting
><?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE KrusaderUserActions>
<KrusaderUserActions>
<action name="clipboard current" >
<title>Copy to Clipboard</title>
<tooltip>Copy to clipboard</tooltip>
<icon>klipper</icon>
<category>System</category>
<description>Copy current path and filename to clipboard</description>
<command>%_Clipboard("%aCurrent%")%</command>
<defaultshortcut>Win+C</defaultshortcut>
</action>
</KrusaderUserActions></programlisting>
</para
></listitem>
<listitem
><para
>Selects <literal role="extension"
>.diff</literal
> and <literal role="extension"
>*.h</literal
> in the active panel: <programlisting
><?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE KrusaderUserActions>
<KrusaderUserActions>
<action name="test_select" >
<title>Add selection *.diff and *.h</title>
<category>Selection</category>
<command>%aSelect("*.diff", "add")% %aSelect("*.h", "add")%</command>
</action>
</KrusaderUserActions></programlisting>
</para
></listitem>
<listitem
><para
>Active panel changes to <filename
>mnt/floppy</filename
> (bookmark): <programlisting
><?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE KrusaderUserActions>
<action name="mnt/floppy bookmark" >
<title>Jump to /mnt/floppy</title>
<category>Bookmarks</category>
<command>%aGoto("/mnt/floppy", "yes")%</command>
</action>
</KrusaderUserActions></programlisting>
</para
></listitem>
<listitem
><para
>Select in the non-active panel, all filenames that are highlighted in the active panel: <programlisting
><?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE KrusaderUserActions>
<action name="asdfasdf" >
<title>Select in Other Panel</title>
<category>Selection</category>
<description>Select all filenames that are selected in the active panel, also in the non-active panel</description>
<command>%oSelect("%aList("selected", " ", "Yes")%")%</command>
</action>
</KrusaderUserActions</programlisting>
</para
></listitem>
<listitem
><para
>Make a backup of the current file/folder to <filename
>foo.bak</filename
> into the current directory: <programlisting
><?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE KrusaderUserActions>
<KrusaderUserActions>
<action name="backup current" >
<title>Backup in Current Directory</title>
<tooltip>Backup in current directory</tooltip>
<icon>filesaveas</icon>
<category>System</category>
<description>Backup in current directory</description>
<command>%_Copy("%aCurrent%", "%_Ask("new name", "%aCurrent%.bak")")%</command>
<defaultshortcut>Shift+F5</defaultshortcut>
</action>
</KrusaderUserActions></programlisting>
</para
></listitem>
<listitem
><para
>Opens <link linkend="krusearcher"
>KruSearcher</link
>: <programlisting
><?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE KrusaderUserActions>
<KrusaderUserActions>
<action name="search" >
<title>Search Test</title>
<command>%_NewSearch("Search 2")%</command>
</action>
</KrusaderUserActions></programlisting>
</para
></listitem>
<listitem
><para
>Sets the selected picture as wallpaper: <programlisting
><?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE KrusaderUserActions>
<KrusaderUserActions>
<action name="set wallpaper" >
<title>Set as Wallpaper</title>
<tooltip>Set as wallpaper</tooltip>
<icon>image</icon>
<category>Service Menu</category>
<description>Set as wallpaper (scaled)</description>
<command>dcop kdesktop KBackgroundIface setWallpaper "%aCurrent%" 6</command>
<defaultshortcut>Win+W</defaultshortcut>
</action>
</KrusaderUserActions></programlisting>
</para
></listitem>
<listitem
><para
>This useraction edits a file with root permissions using <command
>tdesu</command
>: <programlisting
><?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE KrusaderUserActions>
<KrusaderUserActions>
<action name="edit as root" >
<title>Edit as Root</title>
<tooltip>Edit as root</tooltip>
<icon>kwrite</icon>
<category>System</category>
<description>Edit a file with root permissions using tdesu</description>
<command>tdesu kedit %aCurrent%</command>
<defaultshortcut>Win+F4</defaultshortcut>
</action>
</KrusaderUserActions></programlisting>
</para
></listitem>
<listitem
><para
>This useraction Add item(s) to Amarok playlist: <programlisting
><?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE KrusaderUserActions>
<KrusaderUserActions>
<action name="amarok enqueue" >
<title>Enqueue in Amarok</title>
<tooltip>Append selected item(s) to Amarok playlist</tooltip>
<icon>amarok</icon>
<category>Multimedia</category>
<description>Append selected item(s) to Amarok playlist</description>
<command>amarok --append %aList("Selected")%</command>
<defaultshortcut>Win+A</defaultshortcut>
</action>
</KrusaderUserActions></programlisting>
</para
></listitem>
<listitem
><para
>Opens &synchronizer_lnk;: <programlisting
><?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE KrusaderUserActions>
<KrusaderUserActions>
<action name="synchronizer" >
<title>Synchronizer</title>
<command>%_Sync("Sync 2")%</command>
</action>
</KrusaderUserActions></programlisting>
</para
></listitem>
<listitem
><para
>Copy selected files & directories with root privileges (also inside archives): <programlisting
><?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE KrusaderUserActions>
<KrusaderUserActions>
<action name="root_copy" >
<title>Copy as "root"</title>
<tooltip>Copy as "root"</tooltip>
<icon>editcopy</icon>
<category>Selection</category>
<description>Copy selected files & directories with root privileges, also inside archives!</description>
<command run_as="root" accept="url">kfmclient copy %aList("Selected", " ", "No")% %oPath%</command>
</action>
</KrusaderUserActions></programlisting>
</para
></listitem>
<listitem
><para
>Search and replace a strings and regular expressions in textfiles using <command
>sed</command
>: <programlisting
><?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE KrusaderUserActions>
<KrusaderUserActions>
<action name="search_replace" >
<title>Simple Search and Replace</title>
<tooltip>Search and replace a string/regex in textfiles</tooltip>
<icon>tdecachegrind</icon>
<category>Samples</category>
<description>This UA uses the UNIX standard-tool sed (the stream-editor) so perform search and replace operations in all selected files It is possible to give a regular expression for both strings. Please note: The sed-command is "s/search/repleace/", so you have to escape the slash when you need it!</description>
<command>sed -i -e 's/%_Ask("Search for:")%/%_Ask("Replace with:")%/' %aList("Selected")%</command>
</action>
</KrusaderUserActions></programlisting>
</para
></listitem>
<listitem
><para
>Converts content of selected text-files from ISO-8859-15 to UTF8 and vice versa using <command
>iconv</command
> (also inside archives): <programlisting
><?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE KrusaderUserActions>
<KrusaderUserActions>
<action name="iso8859-15_to_utf8" >
<title>ISO 8859-15 => UTF8</title>
<tooltip>convert characterset</tooltip>
<icon>editcopy</icon>
<category>Selection</category>
<description>Converts content of selected text-files from ISO-8859-15 to UTF8</description>
<command>sh -c 'cd %aPath%; for i in %aList("Selected", " ", "Yes")% ; do iconv -f iso8859-15 -t utf-8 "$i" -o %oPath%"$i"; done '</command>
</action>
<action name="utf8_to_iso8859-15" >
<title>UTF8 => ISO 8859-15</title>
<tooltip>convert characterset</tooltip>
<icon>editcopy</icon>
<category>Selection</category>
<description>Converts content of selected text-files from UTF8 to ISO-8859-15</description>
<command>sh -c 'cd %aPath%; for i in %aList("Selected", " ", "Yes")% ; do iconv -f utf-8 -t iso8859-15 "$i" -o %oPath%"$i"; done '</command>
</action>
</KrusaderUserActions></programlisting>
</para
></listitem>
</itemizedlist>
</appendix>