Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

The utility wmctrl has the possiblity to list the names of all virtual desktops:

%  wmctrl -d
0  - DG: 3360x1200  VP: 0,0  WA: 0,0 3360x1199  Mail / Comm
1  * DG: 3360x1200  VP: 0,0  WA: 0,0 3360x1199  Web / Docs
2  - DG: 3360x1200  VP: 0,0  WA: 0,0 3360x1199  A
3  - DG: 3360x1200  VP: 0,0  WA: 0,0 3360x1199  B

I would like to be able to change, from the commandline, the name of the current desktop to something else. This is possible by using some pagers, for example, but I couldn't find out how to do it from the command line.

Update: the xprop utility seems to be able to set the desktop names, but I could not figure out the exact format to do so, yet:

% xprop -root -f _NET_DESKTOP_NAMES 8s -set _NET_DESKTOP_NAMES asdf
% xprop -root _NET_DESKTOP_NAMES
_NET_DESKTOP_NAMES(UTF8_STRING) = "asdf", "Web / Docs", "A"
share|improve this question

2 Answers 2

There is no option in wmctrl to do what you ask. Virtual desktops are not windows and can not be managed my wmctrl. Depending on how your window manager stores those values, it could be trivial to use sed to set those names. With Fluxbox, all that needs changing is the following line (~/.fluxbox/init):

session.screen0.workspaceNames: internoit,terms,admin,gui,eclipse,droid-ui

Figure out how your WM sets the names and change/set the values manually.

update:

OpenBox

As previously alleged this can be done in two steps:

  1. edit the values in the config
  2. force OpenBox to "reconfigure"
$ xml ed -N o="http://openbox.org/3.4/rc" \
    -u '//o:openbox_config/o:desktops/o:names/o:name[1]' \
    -v moo  rc.xml

This sets the name of the first workspace to "moo". tmp/ob.xml represents ~rc.xml

$ openbox --reconfigure

Cause the WM to re-read its configuration files.


PS. I haven't actually tried this, because getting that xmlstarlet command to work was interesting enough and because I trust the openbox man page.

share|improve this answer
    
I'm using OpenBox, where you can set it in the rc.xml. This is not what I want however - I want to change it at runtime. –  Dave Vogt Nov 20 '12 at 20:20
    
change it at runtime and call "reconfigure". fluxbox supports this via fluxbox-remote, idk about openbox. –  Ярослав Рахматуллин Nov 20 '12 at 20:32
up vote 0 down vote accepted

I have hacked up a small python script that does this, after not finding anything else. It requires xpybutil as a dependency, tested on current (2014-03-27) Arch Linux.

#!/usr/bin/python2

"Helper for setting current desktop's name"

import sys

from xpybutil import conn, root

import xpybutil.ewmh as ewmh

if len(sys.argv) == 2 and sys.argv[1] == '--help':
    print "Usage: "
    print "   set_desktop_name NAME_OF_NEW_DESKTOP  - sets current desktop name"
    print "   set_desktop_name NR NAME_OF_NEW_DESKTOP - sets name of NRth desktop"

if len(sys.argv) > 2:
    desktop_offset = int(sys.argv[1])
    new_name = sys.argv[2]

else:
    desktop_offset = ewmh.get_current_desktop().reply()
    new_name = sys.argv[1]

current_names = ewmh.get_desktop_names().reply()

current_names[desktop_offset] = new_name

# Not sure why I have to do it twice - somehow
# doesn't work if I only call it once
c = ewmh.set_desktop_names(current_names)
c = ewmh.set_desktop_names(current_names)

Usage is fairly simple:

dv@ankh-morpork ~ % wmctrl -d
0  * DG: 3840x1200  VP: 0,0  WA: 0,24 3840x1176  MAIL
1  - DG: 3840x1200  VP: 0,0  WA: 0,24 3840x1176  Project A
2  - DG: 3840x1200  VP: 0,0  WA: 0,24 3840x1176  Project B
3  - DG: 3840x1200  VP: 0,0  WA: 0,24 3840x1176  Random Stuff
4  - DG: 3840x1200  VP: 0,0  WA: 0,24 3840x1176  Music
dv@ankh-morpork ~ % set_desktop_name 3 "Yet another project"
dv@ankh-morpork ~ % wmctrl -d
0  * DG: 3840x1200  VP: 0,0  WA: 0,24 3840x1176  MAIL
1  - DG: 3840x1200  VP: 0,0  WA: 0,24 3840x1176  Project A
2  - DG: 3840x1200  VP: 0,0  WA: 0,24 3840x1176  Project B
3  - DG: 3840x1200  VP: 0,0  WA: 0,24 3840x1176  Yet another project
4  - DG: 3840x1200  VP: 0,0  WA: 0,24 3840x1176  Music
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.