LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Desktop (http://www.linuxquestions.org/questions/linux-desktop-74/)
-   -   Command to change number of workspaces (http://www.linuxquestions.org/questions/linux-desktop-74/command-to-change-number-of-workspaces-805763/)

samineru 05-04-2010 12:48 AM

Command to change number of workspaces
 
I'm currently using Ubuntu GNU/Linux with compiz.

I'd like to have a hotkey to change the number of workspaces, just by increasing the width of my desktop by adding or removing 1 workspace at a time. So...how do I do it?

smoker 05-04-2010 03:16 AM

you don't.

samineru 05-04-2010 03:31 AM

I did more research on my own, and found the key in gconf that has the hsize of my desktop, it was:
/apps/compiz/general/screen0/options/hsize

catkin 05-04-2010 03:43 AM

Quote:

Originally Posted by samineru (Post 3956499)
I did more research on my own, and found the key in gconf that has the hsize of my desktop, it was:
/apps/compiz/general/screen0/options/hsize

If you change it does that do what you wanted?

samineru 05-04-2010 03:54 AM

It does, right now I'm trying to figure out how to write a command that will increment or decrement it. I have very little experience in actual scripting...
I know I can use gconftool to get or set keys, but I don't actually know how to
Code:

value = get foo
set foo = value-1


catkin 05-04-2010 04:04 AM

Code:

#!/bin/bash

file=/apps/compiz/general/screen0/options/hsize

case $1 in
    up | down )
        ;;
    * )
        echo "Usage: ${0##*/} up | down" >&2
        builtin exit 1
esac

read n_workspaces < $file
if [[ $1 = up ]]; then
    let n_workspaces++
else
    let n_workspaces--
    [[ $n_workspaces -lt 1 ]] && let n_workspaces=1
fi
echo $n_workspaces > $file

EDIT: to put the output from a command into a variable
Code:

var=$( some command 2>&1 )
The 2>&1 is only necessary if the command writes to standard error instead of standard out.

samineru 05-04-2010 04:56 AM

That's great thank you so much! One of my friends also whipped up this:
Code:

#!/usr/bin/env bash
# the backticks tell bash to store the shell output of the enclosed command into the variable "number"
number=`gconftool --get /apps/compiz/general/screen0/options/hsize`
# the $(()) syntax apparently tells bash to do math on the stuff inside
numberInc=$(($number + 1))
# this is just running the right command, but pasting the calculated number onto the end of the command line
gconftool --type Integer --set /apps/compiz/general/screen0/options/hsize $numberInc

This one seems a little simpler, but thank you for taking the time to write that for me.


All times are GMT -5. The time now is 07:10 AM.