<h2>Basic commands</h2>


<p>Type the words "foo bar" with <code>xvkbd</code>:</p>
	<blockquote>
		<code>xvkbd -xsendevent -secure -text &#39;foo bar&#39;</code> 
	</blockquote>

<p>Types out the entire contents of the file "foobar.txt" with <code>xvkbd</code>:</p>
	<blockquote>
		<code>xvkbd -xsendevent -secure -file &quot;foobar.txt&quot;</code>
	</blockquote>

<p>Send text to the clipboard:</p>

	<blockquote>
		<code>xclip -i</code>
	</blockquote>

<p>Send clipboard contents to standard output:</p>

	<blockquote>
		<code>xclip -o</code>
	</blockquote>

<p>Do virtual <code>Ctrl+C</code> key combination with <code>xdotool</code>:</p>

	<blockquote>
		<code>xdotool key Control+c</code>
	</blockquote>

<p>Save this complicated command as an environment variable&mdash;then the variable "$KEYPRESS" expands to this command.</p>

	<blockquote>
		<code>export KEYPRESS=&quot;xvkbd -xsendevent -secure -text&quot;</code>
	</blockquote>

<h2>Examples</h2>

<p>With virtual keystrokes and CLI access to the clipboard, you're limited only by your imagination and scripting ability. Here are some examples of how I use them, both for the manipulation of text and for navigation. The words in bold-face are the voice commands I use to launch the written commands. </p>

<p><strong>Capitalize this</strong>. Copies selected text to the clipboard, pipes it through <code>sed</code> and back into the clipboard, then types fixed text back into my document:</p>

<blockquote><pre>
xdotool key Control+c &amp;&amp; xclip -o \<br/>| sed 's/\(.*\)/\L\1/' \<br/>| sed -r 's/\&lt;./\U&amp;/g' \<br/>| xclip -i &amp;&amp; $KEYPRESS &quot;$(xclip -o)&quot; <br/>
</pre>
</blockquote>

<p><strong>Go to grades</strong>. This example takes advantage of Firefox "quick search." I start with a single quote to match the linked text "grades" and press the Return key (<code>\r</code>) to follow the link:</p>

<blockquote>
<pre><code>$KEYPRESS &quot;'grades\r&quot;</code></pre>
</blockquote>

<p><strong>First Inbox</strong>. From any location within Thunderbird I can run this command and it executes the keystrokes to take me to the first inbox and put focus on the first message:</p>

<blockquote><code>xdotool key Control+k &amp;&amp; $KEYPRESS &quot;\[Tab]\[Home]\[Left]\[Right]\[Down]&quot; &amp;&amp; sleep .2 &amp;&amp; xdotool key Tab</code>
</blockquote>

<p><strong>single ex staff</strong>. Type out an entire Lilypond template into an empty text editor window:</p>

<blockquote><code>xvkbd -xsendevent -secure -file &quot;/path/to/single_ex_staff.ly&quot;</code>
</blockquote>

<p><strong>Paragraph Tags</strong>. Puts HTML paragraph tags around selected text:</p>

<blockquote><pre>
#!/bin/bash<br/><br/>KEYPRESS='xvkbd -xsendevent -secure -text'<br/><br/>xdotool key Control+c<br/><br/>$KEYPRESS '&lt;p&gt;'<br/>xdotool key Control+v<br/>$KEYPRESS '&lt;/p&gt;'<br/>
</pre>
</blockquote>

<h2>Launching commands with keystrokes in Openbox</h2>

<p>I normally use blather voice commands to launch the scripts and keystroke commands, but I have a handful of frequently-used commands that I launch using keystroke combos configured in the Openbox config file (<code>~/.config/openbox/rc.xml</code> on my system). This block configures the <code>super+n</code> key combo to launch my <code>examplelink.sh</code> script.</p>

<blockquote>
<pre>
&lt;keybind key=&quot;W-n&quot;&gt;
  &lt;action name=&quot;Execute&quot;&gt;
	&lt;startupnotify&gt;
	  &lt;enabled&gt;true&lt;/enabled&gt;
	  &lt;name&gt;special&lt;/name&gt;
	&lt;/startupnotify&gt;
	&lt;command&gt;examplelink.sh&lt;/command&gt;
  &lt;/action&gt;
&lt;/keybind&gt;
</pre>
</blockquote>

<h2>Links</h2>

<ul>
	<li>Amazing collection of one-line tricks for the <code>sed</code> stream editor: <a href="https://sed.sourceforge.net/sed1line.txt">https://sed.sourceforge.net/sed1line.txt</a></li>
	<li>Blather source code: <a href="https://gitorious.org/blather">https://gitorious.org/blather</a>  </li>
	<li>Sphinx knowledge base tool: <a href="https://www.speech.cs.cmu.edu/tools/lmtool-new.html">https://www.speech.cs.cmu.edu/tools/lmtool-new.html</a>  </li>
	<li>snapshot of my blather commands file: <a href="https://paste.jonkulp.net/sicegamupi.tex">https://paste.jonkulp.net/sicegamupi.tex</a></li>
	<li>Blather Installation Script for Debian: <a href="https://paste.jonkulp.net/lolilabuje">https://paste.jonkulp.net/lolilabuje</a></li>
</ul>
