You are not logged in.

#1 2015-08-18 11:41:20

jeroen_JDOG
Member
Registered: 2015-03-28
Posts: 19

Openbox dynamic window position

Hello,

I am trying open a program (for example chromium) with a given position and size from the command line, but so far I cannot find any way to do this.
There is a way to give a program a static position (through the <application> tag in rc.xml from openbox), but I would like to get a dynamic positioning.

The reason I want to do this is to make keyboard shortcuts.
For example, one shortcut would be to browse the internet, so I want chromium to open in full size (1920x1080).
An other example is when I want to do some php programming, where I want chromium to occupy only half of the screen, and a terminal the other half.
For both cases I am launching the same program, but with a different size and positioning.

In rc.xml from openbox I can create a keyboard shortcut to execute a bash script, but I don't know how to proceed.

Does anyone know how I could open a program with given position and size from the command line?
Thanks in advance,
Jeroen

Offline

#2 2015-08-18 11:53:24

ayekat
Member
Registered: 2011-01-17
Posts: 1,611

Re: Openbox dynamic window position

I know this is not the answer to your problem, but have you considered using a tiling window manager like dwm, xmonad, i3, ...? It allows you to do exactly these kinds of things, and doesn't even fix you at half a screen, but you could dynamically switch between fullscreen and "halfscreen" (because, having one fix size for your web browser window when making websites results in horrible websites).

Have you checked whether chromium accepts some command line options, possibly `-geometry` or something?

Also, what exactly have you already tried? It's been a while since I've used openbox for the last time, but I think it supports matching windows by their classes or names - perhaps you could give one of your chromium windows a special name, and openbox would treat it differently.

Last edited by ayekat (2015-08-19 09:54:19)


pkgshackscfgblag

Offline

#3 2015-08-18 12:19:15

jeroen_JDOG
Member
Registered: 2015-03-28
Posts: 19

Re: Openbox dynamic window position

I did try the geometry option on chromium, I found two ways that could work after some googleing.
"chromium --geometry=200x200" opens chromium and just ignores the geometry option, and "chromium -geometry 200x200+100+100" opens chromium with url "200x200+100+100".
Also "chromium google.com -geometry 200x200+100+100" doesn't work, it opens chromium with two tabs, one for "google.com" and one for "200x200+100+100".
So I am not sure if chromium accepts the geometry option, but also other programs like medit don't seem to support the geometry option.

Could you explain what you mean by "give one of your chromium windows a special name"?
I know that rc.xml from openbox is able to position a window when the name of the window is known, but how would I set the window's name from the command line?

Offline

#4 2015-08-18 12:39:42

ayekat
Member
Registered: 2011-01-17
Posts: 1,611

Re: Openbox dynamic window position

jeroen_JDOG wrote:

Could you explain what you mean by "give one of your chromium windows a special name"?

X windows may have a class name and a window name assigned. Usually the class name is just the application name, while the window name can take arbitrary values (a terminal for instance may set it to the current working directory, or the currently running process, whereas a web browser usually sets it to the currently focused website's title). You can check these values by using the `xprop` command.

Many window managers (including Openbox) support defining rules that match certain windows by their name or class and treat them accordingly. However, I just had a glance at the Chromium manpage, and at least from the command line there seems to be no way to set its window class (nor its geometry) manually.

That said, that's just some background information, in case you were interested. Otherwise, I am, unfortunately, out of ideas.

Last edited by ayekat (2015-08-18 12:41:07)


pkgshackscfgblag

Offline

#5 2015-08-18 12:53:47

jeroen_JDOG
Member
Registered: 2015-03-28
Posts: 19

Re: Openbox dynamic window position

Ok, thanks.
I tried using obxprop on a chromium window, but unlike other programs it doesn't seem to have an "_NET_WM_NAME". The following is the output from obxprop on a chromium window:

_GTK_HIDE_TITLEBAR_WHEN_MAXIMIZED(CARDINAL) = 1
WM_WINDOW_ROLE(STRING) = "browser"
WM_CLASS(STRING) = "Chromium", "Chromium"
_NET_WM_WINDOW_TYPE(ATOM) = _NET_WM_WINDOW_TYPE_NORMAL
_NET_WM_PID(CARDINAL) = 21633
WM_LOCALE_NAME(STRING) = "C"
WM_CLIENT_MACHINE(STRING) = "jeroen"
WM_PROTOCOLS(ATOM) = WM_DELETE_WINDOW, _NET_WM_PING

To me there does not seem to be any useful data for this purpose.
I googled a bit, but I don't think there is a way to set a property like "_NET_WM_NAME" from the command line.

I guess this option deadlocks here, am I wrong or does anyone know something else I can try?
Thanks in advance

Offline

#6 2015-08-18 12:55:46

wirr
Member
Registered: 2009-10-25
Posts: 70

Re: Openbox dynamic window position

Why do you want to set the window's name? Do you want different positions for different chromium windows?

Use xprop:

xprop WM_NAME
xprop WM_CLASS

and this guide.

If you really need to change a window atom use xprop:

xprop -f WM_CLASS 8s -set WM_CLASS 'something'

On a newly opened, active window:

xprop -f WM_CLASS 8s -set WM_CLASS 'something' -id $(xprop -root _NET_ACTIVE_WINDOW | awk '{print $NF}')

--
wow I'm slow smile

Last edited by wirr (2015-08-18 12:57:13)

Offline

#7 2015-08-18 13:27:58

jeroen_JDOG
Member
Registered: 2015-03-28
Posts: 19

Re: Openbox dynamic window position

I don't necessarily want to set the window's name, I just want something such that openbox knows how to position the window.
Since the homepages for both cases are known, I could use that to tell openbox what position and size to use.

I don't have xprop, but I tried running "obxprop WM_NAME" on a chromium window (google.com), which gave "WM_NAME(UTF8_STRING) = Google - Chromium".
That indeed gives some useful information, although openbox needs an "_OB_APP_NAME" instead of "WM_NAME".
I tried using the "WM_NAME" in rc.xml instead of "_OB_APP_NAME", but it had no effect.
I also looked for the other properties openbox accepts in rc.xml, but there was no useful information:

_OB_APP_NAME(UTF8_STRING) = "Chromium"
_OB_APP_CLASS(UTF_8_STRING) = "Chromium"
_OB_APP_GROUND_NAME(UTF8_STRING) =
_OB_APP_GROUND_CLASS(UTF8_STRING) =
_OB_APP_ROLE(UTF8_STRING) = "browser"
_OB_APP_TITLE(UTF8_STRING) = "Untitled - Chromium"
_OB_APP_TYPE(UTF8_STRING) = "normal"

The _OB_APP_TITLE looks strange to me, because it always seems to give "Untitled - Chromium".

The WM_NAME did look promising, but openbox does not seem to accept it.
Any ideas?

Offline

#8 2015-08-18 14:03:47

ayekat
Member
Registered: 2011-01-17
Posts: 1,611

Re: Openbox dynamic window position

jeroen_JDOG wrote:

I don't necessarily want to set the window's name, I just want something such that openbox knows how to position the window.

... but you may want to set the window's class. smile

Have you tried what wirr has suggested? It's basically what openbox (and many other window managers, by the way) use to match a specific window and configure it to your liking. And that xprop solution looks particularly promising to me.


pkgshackscfgblag

Offline

#9 2015-08-18 14:26:27

jeroen_JDOG
Member
Registered: 2015-03-28
Posts: 19

Re: Openbox dynamic window position

I did try "xprop -f WM_CLASS 8s -set WM_CLASS 'test'" on a chromium window, and it did set the WM_CLASS property to "test", but ideally I don't want to click the window to change it's WM_CLASS property.
After reading through the xprop man page, I think that is where the "-name" option comes in.
I tried passing it the value of WM_NAME, namely "Google - Chromium", but I got an error saying "xprop: error: No window with name Google - Chromium exists!". (The exact command I ran is "xprop -name "Google - Chromium" -f WM_CLASS 8s -set WM_CLASS 'test'".)
Probably I am just passing it the wrong value, because manually clicking the window does work.
Also I am still to test whether or not openbox updates the position once I manage to change the _OB_APP_CLASS, because if it doesn't I would have to define the _OB_APP_CLASS before opening the window.

Also, I found out that the other programs I need to open (medit and terminator) both do support the --geometry option, so chromium is the only window I need an alternative for.

Last edited by jeroen_JDOG (2015-08-18 14:28:04)

Offline

#10 2015-08-18 23:24:25

jedijimi
Member
From: Hartford Wi
Registered: 2013-12-10
Posts: 93

Re: Openbox dynamic window position

try here. Look at the coordinates.


Crude matter we are not, Luminous beings we are

Offline

#11 2015-08-19 09:51:32

thisoldman
Member
From: Pittsburgh
Registered: 2009-04-25
Posts: 1,172

Re: Openbox dynamic window position

Some programs do not always respond well to openbox position or size commands. But without much testing, this rc.xml fragment seems to work well, placing a chromium window's upper left corner ten pixels down and ten pixels to the right of the desktop's top left corner.

<application name="Chromium">
   <position force="yes">
     <x>10</x>                                                                        
     <y>10</y>
   </position>
 </application>

You can search through this thread, https://bbs.archlinux.org/viewtopic.php?id=93126 for other openbox configuration suggestions.

Offline

Board footer

Powered by FluxBB