
<p>In this episode I talk about how to set up custom keystrokes so that you can launch or switch to applications easily using the <code>super</code> key on your keyboard. I do this on the classic Gnome desktop environment and have not tested it on Gnome 3 or Unity to see whether it works on those.</p>

<p>To create a new custom keystroke, open <code>System Settings</code>, then go to <code>Keyboard</code> and <code>Shortcuts</code>. Click on the plus sign to open the dialog box where you specify the name of the keystroke and the command that is to be launched when the keystroke is executed. Click "Apply" and then click "Disabled" and it will allow you to type the keystroke you want to use.</p>

<p>At this point the keystroke configuration is ready, but you have to either log out of the current session and log back in, or find some other way to reload the desktop environment configuration before you can actually use the keystroke.</p>

<p>I also talked about how I use my own scripts to check to see whether a program is running, and then either switch to that program if it's running or launch it if it's not. Here is an example for launching or switching to LibreOffice.</p>

<pre>#!/bin/bash

# Look for the string &quot;LibreOffice&quot; on the list of 
# window titles and check the return code

checktitle=$(wmctrl -l | grep &quot;LibreOffice&quot; &amp;&gt; /dev/null ; echo $?)

# If the return code is 0 that means it found the 
# string, so I use wmctrl to switch to the window 
# that has that string in the title. 

if [ $checktitle == 0 ] ; then
    wmctrl -a &quot;LibreOffice&quot;
    
# If it returns a 1, then that means it did not 
# find a window with that string in it so I 
# launch the application.
    
  else
    loffice &amp;
fi
</pre>

<p>Save the script somewhere in your PATH, make it executable, and then use the script name in the command when you're setting up the keystroke.</p>
