Programmatically Changing the Xfce Desktop Names

Shlomi Fish shlomif at iglu.org.il
Mon Dec 28 15:17:17 CET 2009


Hi all!

On Monday 28 Dec 2009 12:58:43 Shlomi Fish wrote:
> On Monday 28 Dec 2009 12:48:32 Peter de Ridder wrote:
> > On Mon, Dec 28, 2009 at 6:48 AM, Shlomi Fish <shlomif at iglu.org.il> wrote:
> > > Hi all!
> > >
> > > How can I programmatically change the virtual desktop names of Xfce
> > > while Xfce is running? I'd like to write a script to initialise
> > > desktops 1-8 with names that I define in case they get reset.
> >
> > You can do this with xfconf-query.
> > To set the workspace count use: xfconf-query -c xfwm4 -p
> > /general/workspace_count -s 8
> > The workspace names are stored as an array so you must specify them all
> > at once. xfconf-query -c xfwm4 -p /general/workspace_names -s "Name 1" -s
> > "Name 2" -s "Name 3" (etc.)
> 
> Many thanks! I'll try that and let you know how it works out.
> 

It worked very well, now that I've tried it. Thanks again.

Here's a Ruby script I wrote to simplify setting up the desktop names and 
their count (I wrote it in Ruby because I started learning it and could use 
the practice):

<<<<<<<<<<<<<
#!/usr/bin/env ruby

# Set the wallpapers number and names.
# Usage: 
#   $ xfce-set-virtual-desktops "Name 1" "Name 2" "Name 3"...
#
# Copyright by Shlomi Fish, 2009.
#
# Licensed under the MIT/X11 License:
#
# http://www.opensource.org/licenses/mit-license.php

names = ARGV
def xconf_workspace_query(op, args)
    command_line = [
        "xfconf-query", "-c", "xfwm4", 
        "-p", "/general/workspace_#{op}",
    ] + args.map { |a| ["-s", a]}.inject([]) { |a,e| a+e}
    if not system(*(command_line)) then
        raise "xfconf-query #{command_line} failed. $?"
    end
end

xconf_workspace_query("count", [names.length.to_s])
xconf_workspace_query("names", names)

>>>>>>>>>>>>>

Here's the shell script that I'm using to configure the workspaces for my own 
use:

<<<<<<<<<
#!/bin/bash
xfce-set-virtual-desktops \
    "Main" "Development" "Chat" "Donkey" \
    "Music" "Config" "Workspace 7" "Games" \
>>>>>>>>>

Thanks again.

Happy New Year and New Decade.

Regards,

	Shlomi Fish

-- 
-----------------------------------------------------------------
Shlomi Fish       http://www.shlomifish.org/
Parody on "The Fountainhead" - http://shlom.in/towtf

Bzr is slower than Subversion in combination with Sourceforge. 
( By: http://dazjorz.com/ )



More information about the Xfce mailing list