Ubuntu – Can Unity display a Launcher icon for Spread Mode

11.04launchershortcut-keysunity

There is a Launcher icon for Expo Mode Super+S located in the Launcher. Is there a way to put a Launcher icon for Spread Mode Super+W in the Launcher?

Best Answer

Normally, you could do this with compiz's d-bus integration, but it appears to be broken in natty.

Instead, we can do this with xdotool.

Install xdotool:

sudo apt-get install xdotool

Create a script called ~/scripts/compiz-scale.sh to invoke scale:

#! /bin/sh
# Assumes compiz binding for Initiate Window Picker is Super-Tab
xdotool keydown Super && xdotool key Tab
xdotool keyup Super

(If you have a different binding, just replace Super with the meta key you use and Tab with the letter you use.)

Make the script executable:

chmod u+x ~/scripts/compiz-scale.sh

Create an app file called ~/scripts/compiz-scale.desktop to run your script:

#!/usr/bin/env xdg-open
# link me to /usr/share/applications/

[Desktop Entry]
Comment=Switch programs
Exec=/home/YOURUSERNAME/scripts/compiz-scale.sh
Icon=gnome-klotski
Name=Scale
Terminal=false
Type=Application
Version=1.0

Be sure to replace YOURUSERNAME with your user name.

In order to add to the launcher, the app file must be part of the system configuration. (If you just want it available as a search result, you can put it in ~/.local/share/applications .) We'll add a link to the file you created (so your setup is portable to new installs).

sudo ln -s ~/scripts/compiz-scale.desktop /usr/share/applications/compiz-scale.desktop

Now invoke the dash and search for "Scale". Your new app should show up. Click and drag it to the launcher. You should now be able to invoke scale from your launcher.

However, if you change your key binding it will break and you'll have to update your script. Also, it can't be invoked multiple times quickly. The launcher seems to have some double-click detection that prevents an app from being launched twice, so you have to wait before you can click again.

Related Question