speedwm-wiki/pages/Client rules.md

131 lines
2.9 KiB
Markdown
Raw Normal View History

2023-02-01 21:03:56 +01:00
Client rules
============
The `Rule` array allows you to specify rules for X11 clients based on factors such as WM_CLASS and WM_NAME. In the English language, that means you can specify how clients are tiled based on the class, instance or title of said client.
To get this information, you can use the X11 utility `xprop` to get information about a client. If you want to see in detail how the rule system works, refer to function `applyrules` and the `Rule` struct in `speedwm.c`.
2023-02-03 16:40:18 +01:00
### Rule structure (user-friendly)
2023-02-01 21:03:56 +01:00
1. Class
2023-02-03 16:40:18 +01:00
Type: `const char *`
2023-02-01 21:03:56 +01:00
2. Instance
2023-02-03 16:40:18 +01:00
Type: `const char *`
2023-02-01 21:03:56 +01:00
3. Title
2023-02-03 16:40:18 +01:00
Type: `const char *`
2023-02-01 21:03:56 +01:00
4. Tags
2023-02-03 16:40:18 +01:00
Type: `unsigned int`
2023-02-01 21:03:56 +01:00
5. isfloating
2023-02-03 16:40:18 +01:00
Type: `int`
2023-02-01 21:03:56 +01:00
6. ispermanent
2023-02-03 16:40:18 +01:00
Type: `int`
2023-02-01 21:03:56 +01:00
7. isterminal
2023-02-03 16:40:18 +01:00
Type: `int`
2023-02-01 21:03:56 +01:00
8. noswallow
2023-02-03 16:40:18 +01:00
Type: `int`
2023-02-01 21:03:56 +01:00
9. Monitor
2023-02-03 16:40:18 +01:00
Type: `int`
2023-02-01 21:03:56 +01:00
10. unmanaged
2023-02-03 16:40:18 +01:00
Type: `int`
2023-02-01 21:03:56 +01:00
11. ignoretransient
2023-02-03 16:40:18 +01:00
Type: `int`
2023-02-01 21:03:56 +01:00
12. floatx
2023-02-03 16:40:18 +01:00
Type: `int`
2023-02-01 21:03:56 +01:00
13. floaty
2023-02-03 16:40:18 +01:00
Type: `int`
2023-02-01 21:03:56 +01:00
14. floatw
2023-02-03 16:40:18 +01:00
Type: `int`
2023-02-01 21:03:56 +01:00
15. floath
2023-02-03 16:40:18 +01:00
Type: `int`
2023-02-01 21:03:56 +01:00
16. scratchkey
2023-02-03 16:40:18 +01:00
Type: `const char`
### Rule structure (internally)
`typedef struct {`
`const char *class;`
`const char *instance;`
`const char *title;`
`unsigned int tags;`
`int isfloating;`
`int ispermanent;`
`int isterminal;`
`int noswallow;`
`int monitor;`
`int unmanaged;`
`int ignoretransient;`
`int floatx, floaty, floatw, floath;`
`const char scratchkey;`
`} Rule;`
2023-02-01 21:03:56 +01:00
### Class
Every X11 client has a class. Even the window manager, speedwm in this case which has the class `speedwm` has a class. speedwm is **not** responsible for setting a client's class, clients using X11 libraries should set this themselves. speedwm just retrieves this information when a client is mapped.
As mentioned previously, you can get the class for a client by running the command-line utility `xprop` on any client. Running `xprop` on speedwm's bar for example will return:
`
[anon@arch ~]$ xprop
WM_CLASS(STRING) = "speedwm", "speedwm"
`
Running it and clicking on the root window however will return information such as the different tags and their glyphs, supported atoms, loaded xrdb resources and information such as the focused client which is not relevant here.
Now, some clients may have multiple classes, `st` for example has both `st` and `St`. Note the class of the program you want to use. Let's say, we want to set a rule for Chromium. Running `xprop | grep CLASS` returns the following information.
`
[anon@arch ~]$ xprop | grep CLASS
WM_CLASS(STRING) = "chromium", "Chromium"
`
This means our class here is `chromium`. That would also be the value of `const char *class` or simply the class. This means if the class matches what we specified (ie. `chromium`), and provided the instance and title also matches an existing client, we set the other values to what is specified.
### Instance
This allows us to specify which instance of the class