After a few hours of fiddling around, I’ve come up with a thing I’m calling “Linglish”: it’s a very simple scripting language for the Linux desktop. It looks a lot like AppleScript, and it’s nowhere near finished. It basically allows you to write in a sort of bastardised English which then calls D-Bus functions, so you can say things like:
- tell screensaver to lock
- tell banshee‘s window to present
- tell banshee‘s playerengine to pause
- tell tomboy to createnamednote with ‘My Named Note’
- tell guake to add_tab
- wait for tomboy‘s noteadded then tell banshee‘s playerengine to toggleplaying
- wait repeatedly for tomboy‘s noteadded then tell banshee‘s playerengine to toggleplaying
- wait 6 times for tomboy‘s noteadded then tell banshee‘s playerengine to toggleplaying
- A script editor program would be nice, which could dynamically inspect D-Bus to help you write scripts. It could compile a script to an executable that wouldn’t need the script runtime either without too much difficulty (one big Python script, perhaps, or using glick to make an actual executable).
- Obviously it needs to be able to run multiple commands, and have
later ones react to what happened in earlier ones. I’m imagining an
ask banshee's engine for positionsort of sentence, which would get the
Positionproperty and then stash it in an invisible
resultvariable, meaning that the next command could be
tell banshee's playerengine to seek to the result + 20or something similar.
Key question is: is this worth pursuing? Or is it reasonable to demand
that people who want to script our desktop should learn a more real
programming language? Code (written in Python) in svn at
http://svn.kryogenix.org/svn/linglish/; it’s only half a dozen files.
If you want to fiddle with the grammar to add new ways of parsing
commands you’ll need yapps2 (in Ubuntu as yapps2), and you’ll
need the yapps2 runtime to actually run any commands (in Ubuntu as
python linglish/runner.py -c "tell tomboy to createnamednote with 'named note'"