You are not logged in.
Pages: 1
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
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)
Offline
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
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)
Offline
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
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
Last edited by wirr (2015-08-18 12:57:13)
Offline
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
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.
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.
Offline
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
try here. Look at the coordinates.
Crude matter we are not, Luminous beings we are
Offline
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
Pages: 1