I learned today (via a great blog post) about
xte. This program lets you simulate X Windows mouse and keyboard events from the commandline. How much more awesome can you get?
Hans illustrates how to integrate
xte to make KDE4 effects activate. I wanted the KDE4 "Desktop Grid" to appear when I press a mouse button (because my new mouse has a lot of buttons to spare), so this is exactly what I was looking for.
xte is the kind of glue that makes Linux awesome. KDE lets you set global keyboard shortcuts for lots of things.
xbindkeys lets you assign shell commands to mouse buttons. And
xte ties the two together. Possibly none of the programmers on these three tools knew about the others, but they interact perfectly to let you do anything you want.
You may be thinking, "If you want to work with KDE from the commandline, why not use DBUS?" That's what I tried to do first. But I can't for the life of me figure it out. There's some indication that we might be able to do this somday, like so:
qdbus org.kde.kglobalaccel /component/kwin org.kde.kglobalaccel.Component.invokeShortcut ShowDesktopGrid
Or maybe it's already in the latest version of KDE and I haven't upgraded yet. Either way.
By the way: could DBUS possibly have a more verbose or cryptic interface? I was hunting through the available DBUS commands looking for something that would show the Desktop Grid, and I ended up having to scan through lists of crap like this:
~ % qdbus org.kde.kwin /KWin method Q_NOREPLY void org.kde.KWin.cascadeDesktop() method void org.kde.KWin.circulateDesktopApplications() method bool org.kde.KWin.compositingActive() signal void org.kde.KWin.compositingToggled(bool active) method int org.kde.KWin.currentDesktop() method QList<int> org.kde.KWin.decorationSupportedColors() method void org.kde.KWin.doNotManage(QString name) method Q_NOREPLY void org.kde.KWin.killWindow() method QStringList org.kde.KWin.listOfEffects() method void org.kde.KWin.loadEffect(QString name) method QStringList org.kde.KWin.loadedEffects() method void org.kde.KWin.nextDesktop() method void org.kde.KWin.previousDesktop() method Q_NOREPLY void org.kde.KWin.reconfigure() method void org.kde.KWin.reconfigureEffect(QString name) method void org.kde.KWin.refresh() signal void org.kde.KWin.reinitCompositing() signal void org.kde.KWin.reloadConfig() method bool org.kde.KWin.setCurrentDesktop(int desktop) method void org.kde.KWin.showWindowMenuAt(qlonglong winId, int x, int y) method Q_NOREPLY void org.kde.KWin.toggleCompositing() method void org.kde.KWin.toggleEffect(QString name) method Q_NOREPLY void org.kde.KWin.unclutterDesktop() method void org.kde.KWin.unloadEffect(QString name) method bool org.kde.KWin.waitForCompositingSetup() method QDBusVariant org.freedesktop.DBus.Properties.Get(QString interface_name, QString property_name) method QVariantMap org.freedesktop.DBus.Properties.GetAll(QString interface_name) method void org.freedesktop.DBus.Properties.Set(QString interface_name, QString property_name, QDBusVariant value) method QString org.freedesktop.DBus.Introspectable.Introspect()
This is line noise to me.