Discussion
Loading...

Post

  • Log in
  • Sign up
  • About
  • Code of conduct
  • Privacy
  • Users
  • Instances
  • About Bonfire
sql's monster
sql's monster
@algernon@come-from.mad-scientist.club  ·  activity timestamp 7 months ago

A'ight, gonna spin this out of my daily hellthread: I have a need for a small tool that can help me arrange my windows automatically, following a set of rules.

For X11, there's devilspie2 that can do this, but there's no generic solution for Wayland, and I am sticking to Wayland, because it has niri, which X11 does not.

So I will try to build something similar-ish! A little tool that listens on the Niri event stream, and does stuff according to pre-defined rules.

Unlike devilspie2, I do not plan to embed Lua, or any other language. I could, and that would make it almost trivial to implement, but I don't wanna. I want a configuration that is simple for me to write, even if that makes the tool a little bit more complicated, and somewhat more limited than embedding Lua.

(I might embed Lua later, but I don't see the immediate need).

  • Copy link
  • Flag this post
  • Block
sql's monster
sql's monster
@algernon@come-from.mad-scientist.club  ·  activity timestamp 7 months ago

Imaginary configuration:

match-window app-id="librewolf" title="Google Meet" {
on "window-opened-or-changed" {
move-window-to-workspace "social"
}
}

match-window app-id="librewolf" workspace="browser" {
on "window-opened" {
consume-or-expel-window-left
}
}

This would:

  • Move all LibreWolf windows titled "Google Meet" to the "social" workspace, whenever such a window is opened or changed (eg, when its title changes to Google Meet after opening)
  • Consume all newly opened LibreWolf windows on the "browser" workspace into the window on the left (their parent)

This pretty much covers everything I need from the tool right now.

  • Copy link
  • Flag this comment
  • Block
sql's monster
sql's monster
@algernon@come-from.mad-scientist.club  ·  activity timestamp 7 months ago

Obligatory note and highlight: this is for Niri only. I have no intention of ever supporting another compositor within the tool, unless I switch away from Niri.

  • Copy link
  • Flag this comment
  • Block
Federation Bot
Federation Bot
@Federation_Bot  ·  activity timestamp 7 months ago

Small progress was made on the tool: I'm experimenting with parsing the imagined configuration into something the tool can then work with.

It's going to be a little more complicated than originally anticipated, but I'll make do.

One obstacle I'll have to tackle later is good error messages. I want to emit similar miette diagnostics as the kdl crate itself, but with my interpretations on top of the KDL document.

So that for example:

match-window title="something" {
on "no-such-event" {
no-such-action
}
}

...would correctly report that "no-such-event" is not known, neither is "no-such-action", and would do the fancy diagnostics that point to the exact place.

  • Copy link
  • Flag this comment
  • Block
sql's monster
sql's monster
@algernon@come-from.mad-scientist.club  ·  activity timestamp 7 months ago
Error: × Failed to load tmp/config.kdl
╰─▶ Failed to parse KDL document

Error:
× Found unrecognised event
╭─[5:8]
4 │ }
5 │ on "whatever" {
· ─────┬────
· ╰── unknown event
6 │ something
╰────

There we go!

  • Copy link
  • Flag this comment
  • Block
sql's monster
sql's monster
@algernon@come-from.mad-scientist.club  ·  activity timestamp 7 months ago

This will be mighty useful for iocaine aswell, later down the line. Not for 3.0, but in some 3.x update.

  • Copy link
  • Flag this comment
  • Block
Instance logo
bonfire.cafe
Log in Create account
Banner for bonfire.cafe

bonfire.cafe

A space for Bonfire maintainers and contributors to communicate

bonfire.cafe: About · Code of conduct · Privacy · Users · Instances
Bonfire bovenjan · 1.0.3-alpha.10 no JS en
Federation disabled
Instance logo
  • Explore
  • About
  • Members
  • Code of Conduct

Install bonfire.cafe

Get the full app experience

1 Tap Share 2 Add to Home Screen