Sweets

Permissions

Choose which programs may capture the screen, inject input, or read the clipboard

By default, any program can capture the screen, read the clipboard, and send fake input. Permissions limit that to programs you allow.

sweets.permissions({ enforce = true })

sweets.permission({
  program = "/usr/lib/xdg-desktop-portal-wlr",
  protocol = "screencopy",
  mode = "allow",
})
sweets.permission({ program = "/usr/bin/grim", protocol = "screencopy", mode = "allow" })
sweets.permission({ program = "/usr/bin/wl-paste", protocol = "data_control", mode = "allow" })

Allow your screen-sharing portal before you turn on enforce, or screen sharing stops working everywhere.

Restart Sweets after changing permissions. A reload doesn't change them.

On FreeBSD, executable-based rules cannot grant access yet. See the FreeBSD limits.

sweets.permissions

FieldDefaultEffect
enforcefalsetrue blocks everything no rule allows

sweets.permission

Each call adds one rule.

FieldEffect
programFull path to the program, or a pattern
protocolOne protocol from the table below, or a list
mode"allow" or "deny"
ProtocolCoversUsed by
screencopyScreenshots and screen sharinggrim, sweetshot, xdg-desktop-portal-wlr, wf-recorder
virtual_inputFake keyboard and mouse inputwtype, wlrctl
data_controlClipboard accesswl-copy, wl-paste, sweetshot, clipboard managers
gamma_controlScreen color temperaturegammastep
output_managementMonitor settingswlr-randr, kanshi

If several rules match, the last one wins:

-- Everything in /usr/bin may send input, except wtype.
sweets.permission({ program = { prefix = "/usr/bin/" }, protocol = "virtual_input", mode = "allow" })
sweets.permission({ program = "/usr/bin/wtype", protocol = "virtual_input", mode = "deny" })

A program that needs several protocols takes a list. A suffix pattern matches it wherever it is installed:

-- sweetshot captures the screen and copies the shot to the clipboard.
sweets.permission({
  program = { suffix = "/bin/sweetshot" },
  protocol = { "screencopy", "data_control" },
  mode = "allow",
})

See sweetshot.

A blocked program usually reports that the compositor doesn't support the feature.

Finding a program's path

Blocked programs are logged:

grep "permission policy" ~/.local/state/sweets/sweets.log

Copy the program= path into your rule. Scripts show up as their interpreter, like /usr/bin/python3.

Limits

  • Flatpak and other sandboxed apps are always blocked from these protocols.
  • If your config fails to load at startup, permissions aren't enforced.
  • This prevents accidents. It isn't a security guarantee.

On this page