What is PyQe?
PyQe (Python Quick Execute) is a small (< 10 Kb) Python program that uses Tkinter, Python's standard GUI toolkit, to let the user launch (execute) commands and programs from a pre-defined list of commands, just by entering a few characters.
I wrote it because I could not find any really simple, keyboard driven program launcher to use under GNU/Linux that worked exactly as I wanted (I tried quite a few, but all of them didd something that annoyed me or did not work the way I wanted).
PyQe is released under the GNU General Public License (GPL), which means that it is Free software (both free as in free beer and free as in freedom).
Starting PyQe
Linux
The suggested usage is to tell your window manager to run pyqe on a certain keypress. How this is done depends on the window manager. If you cannot configure your window manager to do it, a program like xbindkeys can be used.
pyqe comes with a sheband (#!) at the beginning of the file. By default it uses this line to start:
#!/usr/bin/env python
If that does not work on your set up you have to change it.
If for some reason it does not work to execute pyqe directly, or if you do not want to make the script executable, start it in this way:
python path_to_pyqe/pyqe
Windows
In Windows, the easiest way to start pyqe is creating a shortcut on your desktop containing the following "command line":
PATH_TO_PYTHON\pythonw.exe PATH_TO_PYQE\pyqe
Next, bind a keyboard combination to this shortcut by placing the cursor in the Shortcut Key field and pressing a keyboard combination, for example CTRL + SHIFT + P.
Another way to do it is to place the same shortcut directly under the Start Menu (you have to use the Classic look if you are running Windows XP), giving the shortcut a unique character as the first character of the file name, for example a hyphen (-). This way, all yu have to do is press the Windows key (this brings up the Start Menu), and press the hyphen (note you must release the Windows key for the Start Menu to open, and before you press -).
General
If you want to speed the startup a bit, you can add the -S option to the interpreter.
Command line options
From now and on I will assume you start pyqe as a executable script.
pyqe understands a couple of command line options. To see them, do this:
pyqe --help
When you have tested it for a while you might want PyQe to execute single matches automatically (so that you do not need to press enter when there is only one match left):
pyqe --auto
If you want to control the number of visible items in the listbox (default is 4):
pyqe --height 10
The width, in character, of the listbox (default is 40):
pyqe --width 20
The default startup position of PyQe is 0,0. You can change this:
pyqe --xpos 100 --ypos 100
By default, PyQe sorts the commands list. If you do not want this:
pyqe --nosort
You can turn on debug (you must run pyqe.py from a terminal to see the output) if something seems wrong:
pyqe --debug
If pyqe does not start fast enough for you, consider using the --listen parameter:
pyqe --listen
This will start pyqe in the background, listening for commands in a named pipe called ".pyqepipe" in your home diretory. The current commands are "quit", "open" and "reload"and can be sent to the program in the following way:
echo open > ~/.pyqepipe
Listen-mode commands
- open - Open the GUI for executing a command. When a command is executed or the GUI closed by pressing Escape, it will go back to listen mode again. This is probably the command you will use the most.
- reload - Reload configuration file.
- quit - Quick the listening PyQe process.
Configuring PyQe
Configuring PyQe is easy. Create a text file called .pyqerc and place it in your HOME directory (pyqe will concatenate the value of your HOME environment variable with "/.pyqerc" to find it and, yes, it works on Windows too as long as you create the environment variable HOME and set it to he directory where .pyqerc is placed) and place each command on its own line, in the following format:
command_name command
command_name is the name that will be visible in the GUI and matched against when you type on your keyboard.
command is the actual command to be executed (using Python's os.system() call).
Examples of a valid configuration file under GNU/Linux:
# My own .pyqerc file xmms xmms & rx rxvt & emacs emacs & firefox /home/mathias/pgm/firefox/firefox & gnome-terminal /usr/bin/gnome-terminal &
Blank lines and lines starting with # are ignored.
On GNU/Linux, an ampersand (&) is needed to the command so that it is executed asynchronously (or else pyqe will not quit until the executed application is closed. It will hide the GUI though so it is not visible.)
Examples of a valid configuration file under Windows:
# My own .pyqerc file notepad start notepad google start http://www.google.com firefox start firefox
(The start command on Windows is very useful and I recommend using it for starting programs.)
You might wonder why I did not shorten the commands above, using for example "em" instead of "emacs", but that is usually not necessary as long as you do not have many commands beginning in the same letters. When you use pyqe with the configuration above, just typing "e" will be enough to run the emacs command. You name your commands as you wish, this works for me.
Usage
Basic
After starting pyqe, you will be presented with the full list of pre-defined commands in a list box, and the cursor will be waiting for input in an entry field. You can now either select a command using the arrow keys (up/down) and pressing return, or start typing the first letters of the command you want to run, which will make the list of commands smaller. After executing the command with return (or when using the auto option, when only one item is in the list), pyqe will close. Pressing escape will also close the program.
Note: the command names are compared to user input in a case sensitive way, so "my_program" and "My_program" are different.
Tab expansion
If two or more currently matching commands have several leading characters in common, the user can expand the command to the longest common string. For example, if you have two commands starting with "play_" (let's say "play_music" and "play_movies"), first type "p" and, asuming you have no other command starting with "p", you can now press the Tab key to expand the entered command to "play_". It is easier to use than it is to explain, so try it out.
Screenshots
Main window showing first four commands at startup:
Showing matches after user input:
User can use the arrow keys to select any of the matches to execute:
Example of how the expand command (pressing Tab) works. These are two matches that have common leading characters:
After pressing Tab:
Download
Todo
- Nothing yet.
Feedback
Mail me at <mathias . dahl at gmail . com> or use the forums or trackers.