baskerville / bspwm

A tiling window manager based on binary space partitioning
BSD 2-Clause "Simplified" License
7.79k stars 414 forks source link

a second libreoffice window is created as floating, even with tiled rule configured #671

Closed ninrod closed 6 years ago

ninrod commented 7 years ago

Firstly, thanks so much for this program, @baskerville.

So this bspc rule -a Libreoffice state=tiled is working for me for one libreoffice window.

Now if I open another libreoffice app after I opened the first, like, say if I want to open two calc sheets, then bspwm does not partition the windows for me. the second window seats on top of the first one as a floating window.

To reproduce, just open a calc sheet. then chose file -> open recents -> another sheet.

baskerville commented 7 years ago

I can't reproduce.

LibreOffice behaves as expected for me (and I don't need any rule).

Regarding the given rule:

bspc rule -a Libreoffice state=tiled

If LibreOffice followed the conventions given in man 7 X, this would certainly be the correct class name, but unfortunately it isn't:

$ for wid in $(xdo id -n libreoffice); do bspc query -T -n "$wid" | jq '.client | {className, instanceName}'; done
{
  "className": "libreoffice-startcenter",
  "instanceName": "libreoffice"
}
{
  "className": "libreoffice-writer",
  "instanceName": "libreoffice"
}
{
  "className": "libreoffice-draw",
  "instanceName": "libreoffice"
}

Ideally, the output would be:

{
  "className": "Libreoffice",
  "instanceName": "startcenter"
}
{
  "className": "Libreoffice",
  "instanceName": "writer"
}
{
  "className": "Libreoffice",
  "instanceName": "draw"
}
ninrod commented 7 years ago

tks. so what do I have to write as the class name?

libreoffice-calc? libreoffice/calc?

maybe camelcased?

tks in advance

msteen commented 7 years ago

@ninrod That might depend on your version of LibreOffice, but is likely to be libreoffice-calc. To be sure, if you use e.g. xprop and click on your LibreOffice Calc window, you should be able to see an entry such as:

WM_CLASS(STRING) = "libreofficedev", "libreofficedev-calc"

Meaning the <instance_name> (application name) is libreofficedev and the <class_name> is libreofficedev-calc in my case. So in my case the following rule should work:

bspc rule -a libreofficedev-calc state=tiled

In your case the following is likely to work, but just check it with xprop as mentioned:

bspc rule -a libreoffice-calc state=tiled

Rules have to match a class name exactly, which is better than having to deal with false positives.

icf20 commented 6 years ago

@msteen please not that is not working like i said here https://github.com/baskerville/bspwm/issues/655#issuecomment-333335008

msteen commented 6 years ago

@icf20 So it just means that the class name reported by LibreOffice is not always the same, it depends on how you start it. So you should just have checked what those different class names were in those different situations and added the necessary rules to fix the problem. I just checked for you what different names I could find with my LibreOffice installation and I found three variations by echoing the class and instance name to my console:

libreofficedev-calc libreofficedev
LibreOfficeDev 5.2 libreofficedev
Soffice soffice

So probably the easiest way to catch them, and potential future ones, is to check the instance name for the word office. This can be achieved be e.g. adding the following to your external rules:

instance=$3
if [[ "$instance" == *office* ]]; then
  echo state=tiled
fi

I hope this solves your issue.

icf20 commented 6 years ago

wont bspc rule -a *office* state=tiled solve the issue ?

msteen commented 6 years ago

@icf20 You could just have tried that yourself, but no, it will not work. It only supports either a wildcard (single asterisk) or tries to match the string as a whole. But if what you are really asking is how to do it without resorting to using an external rules file, then given the variations I found, you could also do something like this:

bspc rule -a '*:libreofficedev' state=tiled
bspc rule -a '*:soffice' state=tiled
icf20 commented 6 years ago

@msteen this solution is perfect