Sweets

Animations

Window, layer, and workspace transitions

Animations are off by default. Turn them on, then change what you like:

sweets.animations({
  enabled = true,

  window_open = { type = "zoom", scale = 0.9, duration = 160 },
  window_close = { type = "fade", duration = 160 },
  window_move = { duration = 220 },
  workspace_switch = { duration = 220 },
  overview = { duration = 220 },
  layer_open = { type = "slide", duration = 160 },
})

What animates

NameDefaultAnimates
window_openfade, 160 msA window opening
window_closefade, 160 msA window closing
window_minimizefade, 160 msMinimize and restore
window_move220 msWindows moving and resizing
window_opacity160 msOpacity and dim changes
border160 msBorder color changes
workspace_switch220 msSwitching workspaces
overview220 msZooming into and out of Overview
special_workspacefade, 220 msShowing and hiding a special workspace
layer_openfade, 160 msA launcher or notification appearing
layer_closefade, 160 msA launcher or notification closing

Every one takes:

FieldDefaultEffect
enabledtruefalse turns this one off
durationsee aboveMilliseconds, 0–5000
curve"default"Easing curve

Set duration and curve for all of them at once with defaults:

sweets.animations({
  enabled = true,
  defaults = { duration = 200, curve = "ease_out" },
})

overview is always a zoom and takes only enabled, duration, and curve. Turn it off, or set duration = 0, to open and close Overview instantly. The same timing drives wheel scrolling in the scrolling Overview.

Effects

window_open, window_close, window_minimize, special_workspace, layer_open, and layer_close also take an effect:

FieldDefaultEffect
type"fade""fade", "zoom", "slide", or "slide_fade"
scale0.8Starting size for zoom, 0.1–1.0
direction"auto"Slide direction: "auto", "left", "right", "up", or "down"
distance"auto"Slide distance: "auto" or pixels
shadernoneGLSL file for type = "shader", relative to the config file
typeResult
"fade"Fades in or out
"zoom"Grows from scale while fading
"slide"Slides in from off screen
"slide_fade"Slides and fades
"shader"Your own GLSL, window_open and window_close only. See Custom shaders

layer_open and layer_close don't support zoom.

With direction = "auto", each window slides in from the screen edge nearest its spot in the layout. distance = "auto" moves it just far enough to start off screen.

Custom shaders

Write a small GLSL function to draw a window while it opens or closes. Sweets still controls when it runs, how long it takes, and the curve.

sweets.animations({
  enabled = true,
  window_open = { type = "shader", shader = "shaders/reveal.glsl", duration = 240 },
  window_close = { type = "shader", shader = "shaders/reveal.glsl", duration = 240 },
})

Put the file next to your sweets.lua, here ~/.config/sweets/shaders/reveal.glsl. Sweets ships reveal.glsl and dissolve.glsl in share/sweets/shaders; copy one to start:

// wipe in from the left, and back out
vec4 sweets_window(vec2 coords) {
    float edge = mix(-0.05, 1.05, sweets_visibility);
    float mask = 1.0 - smoothstep(edge - 0.05, edge, coords.x);
    return sweets_sample(coords) * mask;
}

coords is (0, 0) at the window's top-left corner and (1, 1) at its bottom-right. The shadow lies just outside that square, so your effect covers it too. You can draw a quarter of the window's size past each edge. Return a premultiplied color.

NameValue
sweets_sample(coords)The window and its shadow as they look with no animation. Clear outside them
sweets_visibility0 hidden to 1 shown, following the curve
sweets_direction1.0 while opening, -1.0 while closing
sweets_sizeWindow size in pixels
sweets_scaleMonitor scale
sweets_seedA random number from 0 to 1, new for each window

The file can be up to 64 KiB. Don't add #version; Sweets adds it. Saving the file reloads it. If it doesn't compile, Sweets keeps the last working one and shows the error bar. The full GL error is in the session log.

Use the same file for opening and closing. A window closed while it is still opening then turns around smoothly, because both run on sweets_visibility.

To keep one app on a normal effect, set its type in a window rule.

A shader that loops too long can freeze the screen. Fix it from a TTY or SSH by setting type = "fade". Sweets still starts normally, because the shader only runs when a window opens or closes.

Layer surfaces

layer_open and layer_close animate launchers, notifications, and on-screen displays. Panels that reserve space, like a bar, and wallpapers don't animate.

With direction = "auto", a surface slides in from the edge it is anchored to. Change it for one app with a layer rule:

sweets.layer_rule({ namespace = "mako", animation_direction = "right" })
sweets.layer_rule({ namespace = "swaync", animation = false })

Workspace switching

directionSlides
"auto"Left and right, by workspace number
"horizontal"Left and right
"vertical"Up and down

Window opacity

window_opacity fades between a window's focused, unfocused, dragged, and fullscreen opacity, and its dim.

sweets.window({
  opacity = { focused = 1.0, unfocused = 0.92 },
  dim_inactive = 0.15,
})

sweets.animations({
  enabled = true,
  window_opacity = { duration = 160 },
})

No fade runs when the old and new values are equal.

Curves

curve takes a built-in name or four numbers, as in CSS cubic-bezier:

sweets.curve("quick", { 0.46, 1.0, 0.29, 0.99 })

sweets.animations({
  enabled = true,
  window_move = { curve = "quick" },
  window_open = { curve = { 0.46, 1.0, 0.29, 0.99 } },
})

Built-in names: default, linear, ease, ease_in, ease_out, and ease_in_out. Declare your own with sweets.curve before using it.

workspace_switch, window_open, window_close, window_minimize, layer_open, layer_close, and special_workspace support curves that overshoot. For example, { 0.34, 1.56, 0.64, 1 } moves past the destination, then settles back.

slide and slide_fade preserve overshoot for windows, layers, and special workspaces. Window and special-workspace zoom do too. Opacity and special-workspace dimming stay bounded.

Zoom can briefly grow beyond full size or shrink below its configured scale.

Minimize and restore use the same curve. Reversing mid-animation starts from the current pose. A slide can briefly leave the screen during overshoot without interrupting other windows being minimized.

Reversing a special workspace starts from its current pose, including overshoot.

window_move preserves overshoot when windows move without resizing. When any window in the moving group resizes, the whole group stays within its starting and final bounds.

Other animations keep their existing limits.

Note

  • Fullscreen changes never animate window geometry, including rapid reversals. Maximized windows and other windows resizing alongside them keep their animations.
  • Dragging a window with the mouse follows the pointer exactly. The other windows still animate around it.
  • To turn off animations for one app, use animation = false in a window rule.

On this page