You are not logged in.

#1 2019-10-05 11:10:10

kes
Member
Registered: 2017-12-12
Posts: 20

Openbox: can I customise it to add a desktop with a specific name?

I am running the latest arch with Openbox and all the updates.

I currently have 4 Openbox desktops set up in rc.xml

I have just added this keybinding

<keybind key="W-F12">
  <action name="AddDesktop">
     <where>current</where>
  </action
</keybind>

When I press the `W-F12` key combo I get a new desktop called "desktop 5".

Anyone know if I can put a <name></name> tag somewhere in the above key binding to give it a specific relevant name?

Even better would be a script with a pop up box asking for new desktop name input.

eg  say i'm working on statistics and suddenly I want to create a desktop called "stats" how would I do that?   

reference: http://openbox.org/wiki/Help:Actions#AddDesktop

Last edited by kes (2019-10-05 11:12:50)

Offline

#2 2019-10-05 11:42:59

ohnonot
...again
Registered: 2015-09-29
Posts: 3,998
Website

Re: Openbox: can I customise it to add a desktop with a specific name?

Interesting.
I tried but it does not seem to be possible.
Also a desktop added via client-list-combined-menu (or your keybind) is not being added to rc.xml <desktops> section, it's kinda temporary, but the X session remembers it.
In other words, playing with it might require actually restarting X.org and not just openbox.
I have now tried to add more <names> than required, under <desktops>.
After restarting X I'd expect these names to be used when I "add a new desktop".

However, that doesn't answer your question - you want dynamic.
I'm pretty sure this is possible with a little script that
a) adds a new desktop
b) immediately names it with xprop

Offline

#3 2019-10-05 20:48:11

hhh
Meep!
Registered: 2015-09-17
Posts: 8,483
Website

Re: Openbox: can I customise it to add a desktop with a specific name?

You can edit desktop names in obconf (Main Menu>Preferences>Openbox>WM Preferences>Desktops>Desktop Names>double-click an entry and edit it>Close).

You could just add a fifth and sixth desktop and name them there (example: name Desktop 5 'Inkscape' and switch to it before opening Inkscape, or set an Inkscape shortcut keybind to open it on desktop 5, or use the Openbox window menu to send Inkscape to desktop 5 from the current desktop it's opened to). That will also alter the config file, maybe looking at that will help with a script.

Offline

#4 2019-10-06 11:41:46

brontosaurusrex
Middle Office
Registered: 2015-09-29
Posts: 1,836
Website

Re: Openbox: can I customise it to add a desktop with a specific name?

1. Playing around,

info

wmctrl -d
0  * DG: 3840x1200  VP: 0,0  WA: 6,42 3828x1112  first
1  - DG: 3840x1200  VP: 0,0  WA: 6,42 3828x1112  wasssuuuppp

backup

# backup first
cd .config/openbox
cp rc.xml rc.xml.bak

name

# name 1st desktop 'mkay'
xmlstarlet ed --inplace -N o="http://openbox.org/3.4/rc" \
-u '//o:openbox_config/o:desktops/o:names/o:name[1]' \
-v mkay rc.xml

refresh = problem

openbox --reconfigure # will not refresh names

However they do show in obconf.

edit: after some poking into obconf-2.0.4/src/desktops.c I think some sort of magic happens in line 214

    /* make openbox re-set the property */
    XDeleteProperty(GDK_DISPLAY(), GDK_ROOT_WINDOW(),
                    gdk_x11_get_xatom_by_name("_NET_DESKTOP_NAMES"));

but no clue what that means.

2. Workaround: Make shortkey to 'obconf --tab 6' so one lands directly in desktops section.

Last edited by brontosaurusrex (2019-10-06 19:39:25)

Offline

#5 2019-10-07 07:44:37

ohnonot
...again
Registered: 2015-09-29
Posts: 3,998
Website

Re: Openbox: can I customise it to add a desktop with a specific name?

^ always good for a quick & dirty one, eh? wink

Anyhow:

ohnonot wrote:

In other words, playing with it might require actually restarting X.org and not just openbox.
I have now tried to add more <names> than required, under <desktops>.
After restarting X I'd expect these names to be used when I "add a new desktop".

So that's in rc.xml, add more desktop names in the <desktop> <names> section, and more means: more than the <number> specified.
And indeed: only after restarting X, desktops added on-the-fly use these names.

But:

that doesn't answer your question - you want dynamic.
I'm pretty sure this is possible with a little script that
a) adds a new desktop
b) immediately names it with xprop

There's a ready-made python script in the first non-ad search result. It does the second half of what you want. You can call it from within a shell script that does the first part.

However, I still believe it's possible with xprop alone. If we only knew how.

Offline

#6 2019-10-07 07:58:38

brontosaurusrex
Middle Office
Registered: 2015-09-29
Posts: 1,836
Website

Re: Openbox: can I customise it to add a desktop with a specific name?

I tested that too, but not getting there (also that would not be permanent, which is ok in this case), possible 'xprop dformats' seems to be 8t, 8u and 8s.

xprop -root -f _NET_DESKTOP_NAMES 8u -set _NET_DESKTOP_NAMES 'woot, asaf' 

wmctrl -d                                                                
0  * DG: 1920x1200  VP: 0,0  WA: 6,46 1908x1108  woot, asaf
1  - DG: 1920x1200  VP: 0,0  WA: 6,46 1908x1108  two

xprop -root _NET_DESKTOP_NAMES 
_NET_DESKTOP_NAMES(UTF8_STRING) = "woot, asaf", "two"

I guess 8s could work, but not sure how to null-terminate string in shell.

https://superuser.com/questions/508128/ … ommandline

^ always good for a quick & dirty one, eh? wink

I might make that my blog title if it's ok. smile

Last edited by brontosaurusrex (2019-10-07 08:03:51)

Offline

#7 2019-10-07 08:35:03

ohnonot
...again
Registered: 2015-09-29
Posts: 3,998
Website

Re: Openbox: can I customise it to add a desktop with a specific name?

brontosaurusrex wrote:
xprop -root -f _NET_DESKTOP_NAMES 8u -set _NET_DESKTOP_NAMES 'woot, asaf' 

wmctrl -d                                                                
0  * DG: 1920x1200  VP: 0,0  WA: 6,46 1908x1108  woot, asaf
1  - DG: 1920x1200  VP: 0,0  WA: 6,46 1908x1108  two

xprop -root _NET_DESKTOP_NAMES 
_NET_DESKTOP_NAMES(UTF8_STRING) = "woot, asaf", "two"

That's what my experiments looked like, too.
Never managed to change all desktops names, only the first one. A "simple" formatting problem. sad
Tried 8u and 8s, not 8t though.

not sure how to null-terminate string in shell.

should be '\0', no?

I might make that my blog title if it's ok. smile

sure.

Offline

#8 2019-10-09 10:11:11

kes
Member
Registered: 2017-12-12
Posts: 20

Re: Openbox: can I customise it to add a desktop with a specific name?

I've done the following hack; it's messy but it works.
https://www.dropbox.com/sh/exdgtsgmu4qx … pR7ma?dl=0

to get it working you have to
- create a directory for the 3 files to sit in. The files are a png image, the bash script and the python script mentioned in the last post on this thread
- connect the file `set_desktop_name.sh` to a keybinding in your own rc.xml
- set the path variables at the top of the bash script
- install `yad` which should be in the repositories (https://sourceforge.net/projects/yad-dialog/)
- install `python-xpybutil` (the name this has on Arch which I'm on now), so that the python part of the script works

I used the quoted python script as I didn't want to go back and move that into bash until I got something working.

The latter part of the bash script changes the desktop names and uses sed to update  rc.xml to reflect the change. If your `rc.xml` file is formatted differently to mine you will need to make changes to this part of the script accordingly.     
 
No doubt someone who knows bash better than me can make the list like repeats more efficient using arrays/ lists and loops. My head does not have enough space to hold that kind of detail. I could dig it up, but this seems to work.

btw I have found that with named desktops I actually use desktops. I never used them before until I saw my friends daughter using them on her new apple the other day. I though "that's slick".
Before the last couple days I only ever used desktop "1".
2,3 & 4 just sat there.
Now they are all named and I have far more use of the laptop.
If like me you often have a few browsers open for different topics and never know which is which without clicking on them to see, then named work spaces is very very useful.
I have always found that clicking on each browser to see which is which distracts me and sets my head spinning.
I think dynamic naming of desktops is a break through !

Cheers

Last edited by kes (2019-10-09 16:14:50)

Offline

#9 2019-10-11 04:42:43

ohnonot
...again
Registered: 2015-09-29
Posts: 3,998
Website

Re: Openbox: can I customise it to add a desktop with a specific name?

kes wrote:

I think dynamic naming of desktops is a break through !

Great!
Personally I find tint2's approach (as seen on BL, but expanded to more desktops) usable enough - I can always see the icons of what sits on my other desktops, don't really need to name them.
But I know many people prefer to name desktops for a certain topic.

A little side-note:
Some people here don't (like to) use dropbox. Maybe the scripts are short enough to share directly?

Offline

Board footer

Powered by FluxBB