# useraction.xml

This appendix gives several examples of `useraction.xml` 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.

Please consider uploading your UserActions at &kde-files-url; as we are collecting them. If your UserAction is selected by us it will be shipped with &krusader; at the next release. We provide also an &useractionsforum-url;.

- Runs `uptime`

      <!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 same_as="tooltip" />
        <command executionmode="collect_output" >uptime</command>
        <defaultshortcut>Alt+Ctrl+U</defaultshortcut>
       </action>
      </KrusaderUserActions>

- Runs `ls -l`

      <!DOCTYPE KrusaderUserActions>
       <KrusaderUserActions>
        <action name="ls -l" >
        <title>ls -l in curremt dir</title>
        <description same_as="tooltip" />
        <command executionmode="collect_output" >ls -l %aPath% %oPath%</command>
       </action>
      </KrusaderUserActions>

- Echo Placeholder

      <!DOCTYPE KrusaderUserActions>
       <KrusaderUserActions>
        <action name="test_placeholder" >
        <title>Echo Placeholder</title>
        <tooltip>Echo's the placeholder values</tooltip>
        <category>Testing</category>
        <description same_as="tooltip" />
        <command executionmode="collect_output" onmultiplefiles="call_each" >echo -e "aPath %aPath()%  \naCurrent: %aCurrent()%"</command>
       </action>
      </KrusaderUserActions>

- This useraction copies current path and filename to clipboard:

      <!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>

- Selects `.diff` and `*.h` in the active panel:

      <!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>

- Active panel changes to `mnt/floppy` (bookmark):

      <!DOCTYPE KrusaderUserActions>
      <action name="mnt/floppy bookmark" >
        <title>Jump to /mnt/floppy</title>
        <category>Bookmarks</category>
        <command>%aGoto("/mnt/floppy", "yes")%</command>
       </action>
      </KrusaderUserActions>

- Select in the non-active panel, all filenames that are highlighted in the active panel:

      <!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

- Make a backup of the current file/folder to `foo.bak` into the current directory:

      <!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 same_as="tooltip" />
        <command>%_Copy("%aCurrent%", "%_Ask("new name", "%aCurrent%.bak")")%</command>
        <defaultshortcut>Shift+F5</defaultshortcut>
       </action>
      </KrusaderUserActions>

- Opens KruSearcher:

      <!DOCTYPE KrusaderUserActions>
      <KrusaderUserActions>
       <action name="search" >
        <title>Search Test</title>
        <command>%_NewSearch("Search 2")%</command>
       </action>
      </KrusaderUserActions>

- Sets the selected picture as wallpaper:

      <!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>

- This useraction edits a file with root permissions using `tdesu`:

      <!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>

- This useraction Add item(s) to Amarok playlist:

      <!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 same_as="tooltip" />
        <command>amarok --append %aList("Selected")%</command>
        <defaultshortcut>Win+A</defaultshortcut>
       </action>
      </KrusaderUserActions>

- Opens Synchronizer:

      <!DOCTYPE KrusaderUserActions>
      <KrusaderUserActions>
       <action name="synchronizer" >
        <title>Synchronizer</title>
        <command>%_Sync("Sync 2")%</command>
       </action>
      </KrusaderUserActions>