Module: cuteful.rules

Declarative way to rule objects.

The rule has 3 main components:

  • Constraint - a set of condition the object has to satisfy. (where and where_not field)
  • Effect - new value of the object if constraint is satisfied. (set and run field)
  • Event - signals when the rule is applied. (when field)

Examples:

  1. Set picture-in-picture window to be floating and always on top.
-- the string comparison is using lua pattern matching and case insensitive
add_client_rule {
    where = { title = "picture-*in-*picture" },
    set = { ontop = true, floating = true },
}

2. Set dolphin, thunar, pcmanfm to be always maximized.

add_client_rule {
    where_any = {
        appid = {
           "dolphin",
           "thunar",
           "pcmanfm",
        }
    },
    set = { maximized = true },
}

3. Set every screen except DP-3 to use 1920x1080@240 mode and disallow tearing.

add_rule {
  where_not = { name = "DP-3" },
  set = { allow_tearing = false }
  run = function (screen)
      screen:set_mode(1920, 1080, 240)
  end
  when = { "screen::new" }
}

Info:

  • Copyright: 2026
  • License: GPLv3
  • Originally authored by: Dwi Asmoro Bangun
    (Full contributors list available on our github project)

Static module functions

cuteful.rules.apply_rule (obj, rule) Apply rule to an object.
cuteful.rules.add_rule (rule) -> string Create a rule for an object.
cuteful.rules.remove_rule (id) -> boolean Remove rule using id or table reference.
cuteful.rules.add_client_rule (rule) -> string Macro to create a rule that applied when a client appear.


Static module functions

🔗 cuteful.rules.apply_rule (obj, rule)
Apply rule to an object.

Parameters:

Name Type(s) Description Default value
obj cwc_object The object to rule Not applicable
rule table Rule table. Not applicable
where Optional table Constraint of the rule. nil
where_any Optional table Constraint of the rule. nil
where_not Optional table Constraint of the rule. nil
where_not_any Optional table Constraint of the rule. nil
set Optional table Effect of the rule if the constraint match. nil
run Optional function Callback function if the constraint match. nil
🔗 cuteful.rules.add_rule (rule) -> string
Create a rule for an object.

Either set or run field must be not empty.

Parameters:

Name Type(s) Description Default value
rule table Rule table. Not applicable
where Optional table Constraint of the rule. nil
where_any Optional table Constraint of the rule. nil
where_not Optional table Constraint of the rule. nil
where_not_any Optional table Constraint of the rule. nil
set Optional table Effect of the rule if the constraint match. nil
run Optional function Callback function if the constraint match. nil
when table Signals to apply rule. Not applicable

Returns:

    string The ID of the rule
🔗 cuteful.rules.remove_rule (id) -> boolean
Remove rule using id or table reference.

Parameters:

Name Type(s) Description
id table or string The id or table reference.

Returns:

    boolean True if a rule has been removed.
🔗 cuteful.rules.add_client_rule (rule) -> string
Macro to create a rule that applied when a client appear.

Parameters:

Name Type(s) Description
rule table Rule table.

Returns:

    string The ID of the rule

See also:

add_rule Create a rule for an object. static module functions
generated by LDoc 1.5.0 based on AwesomeWM template