Results 1 to 4 of 4

Thread: Scripts to add/delete workspaces with Compiz

  1. #1
    Join Date
    Feb 2008
    Location
    Warrnambool, Australia
    Beans
    8
    Distro
    Ubuntu 10.04 Lucid Lynx

    Scripts to add/delete workspaces with Compiz

    I was reading an article in Australian PC magazine that mentioned Gnome Shell in the upcoming Gnome 3.0. Gnome Shell will have a 'Overview' mode with large '+' and '-' buttons to add or delete additional workspaces. I was wondering if I could do something similar with Compiz.

    A bit of goggling & experimenting and I found out I can - using the dbus plug-in! No big buttons but I have hot-key goodness. The script to add a workspace is:

    Code:
    #!/bin/bash
    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 + 1 ]
    Quick explanation - We tell dbus to get the horizontal virtual size and tail grabs just the number that we are after. This is saved in the variable ws. Then we add 1 to ws and tell dbus to set the new horizontal virtual size.
    (Note that I am new to Ubuntu and bash - there may be better ways of doing this. And it could be made more robust with error-checking.)

    I saved this script as 'addWorkspace' and bound it to <Control><Alt>equals. The second script that I saved as 'delWorkspace' and bound to <Control><Alt>minus is exactly the same except for the last bit - we need to take away instead of add.

    Code:
    #!/bin/bash
    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 - 1 ]
    Hope this helps someone else. It is a lot of fun when using Expo to quickly add or drop another workspace.

  2. #2
    Join Date
    Jun 2006
    Location
    UnderTheSea
    Beans
    265

    Re: Scripts to add/delete workspaces with Compiz

    Great Script!!
    I notice it only adds it Horizontally how do you make it add Vertically?
    So She Said Internet, And I Said Inter-Not



  3. #3
    Join Date
    Feb 2008
    Location
    Warrnambool, Australia
    Beans
    8
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Scripts to add/delete workspaces with Compiz

    Bonster & aryy113, thanks for the praise. I am glad that others can make use of my little bit of tinkering. Even Webupd8 has written a post about it! Wow! There is a more efficient script in the comments so it is worth while checking out.

    how do you make it add Vertically?
    Change all occurences of
    Code:
    /org/freedesktop/compiz/core/screen0/hsize
    to
    Code:
    /org/freedesktop/compiz/core/screen0/vsize

  4. #4
    Join Date
    Jan 2008
    Location
    Romania
    Beans
    403
    Distro
    Ubuntu Development Release

    Re: Scripts to add/delete workspaces with Compiz

    I updated the post with the simplified version by Anno Nymus. It doesn't really matter how the code looks as long as it works the same, but it looks prettier now

    Thanks once again for the script!
    ...Things To Tweak After Installing Ubuntu 12.04 Precise Pangolin

    http://www.webupd8.org - Daily Ubuntu / Linux news and application reviews.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •