Powered By

Powered by Blogger

Rabu, 18 Agustus 2010

How To Add / Delete Workspaces In Compiz Using Keyboard Shortcuts

Compiz expo screenshot

If you tried Gnome Shell, you probably noticed how cool it is to quickly add / delete workspaces using the + / - buttons. Deafiant @ Ubuntuforums wanted this for Compiz so he wrote a script which can be used to add or delete a workspace on the fly by using a keyboard shortcut (not using buttons like in Gnome Shell, but the result is pretty much the same). Can't wait to try this out? Read on!

Create the script

To use this script, create a file in your home folder (or anywhere else) and name it "workspace".

Then paste this in the newly created file:
#!/bin/bash
case $1 in
add) ACTION="+" ;;
del) ACTION="-" ;;
esac
WS=$(dbus-send --print-reply --type=method_call \
--dest=org.freedesktop.compiz /org/freedesktop/compiz/core/screen0/hsize \
org.freedesktop.compiz.get | tail -c -2)

dbus-send --type=method_call --dest=org.freedesktop.compiz \
/org/freedesktop/compiz/core/screen0/hsize \
org.freedesktop.compiz.set int32:$[ $WS $ACTION 1 ]
exit 0
And save the file.


Now you must make the script executable. If you created the file in your home folder and named it exactly like we wrote in this post, simply run the following command:
chmod +x ~/workspace

Assign Keyboard shortcuts to the script

We're almost done! Now you must bind this script to some keyboard shortcuts. Assuming you already have CCSM installed, go to System > Preferences > CompizConfig Settings Manager, under "General" make sure the "Commands" option is enabled and then click it.

If you don't have any other custom commands added on the "Commands" tab, under "Command line 0" add this: "~/workspace add" (without the quotes) and for "Command line 1", add: "~/workspace del" - if you followed our exact instructions; if not, use your script path. Here is a screenshot with how it should look:

compiz commands

Then switch to the "Key bindings" tab and assign a key combination for command 0 and command 1 such as "Ctrl Alt +" for adding a new workspace and "Ctrl Alt -" for deleting a workspace. Of course, you can add any other key combinations, just make sure nothing else uses the exact same shortcut. You can also assign it Button Bindings or Edge Bindings.

Try it out

Now you can try it out. Enable the "Expo" plugin in Compiz and press "Super + E" (where "Super" is the Windows logo button on the left of your keyboard) and then use the keyboard shortcut you've set up to add or delete a workspace.



Credits for the script: deafiant (many thanks!). Also thanks to Anno Nymus for the simplified script!

Tidak ada komentar:

Posting Komentar