Skip to content
Animations

Animations

SamWM supports smooth animations for window opening, closing, focusing, and workspace switching.

Configuration

samwm.general({
    animations = {
        -- Enable/disable all animations
        enabled = true,

        -- Animation speed (multiplier, 1.0 = normal)
        speed = 1.0,

        -- Transition type: linear, ease, ease-in, ease-out, ease-in-out
        transition = "ease-out",

        -- Spring physics for window movement
        spring = {
            stiffness = 200,
            damping = 20,
            mass = 1.0,
        },
    }
})

Animation Types

Window Open

samwm.animations({
    window_open = {
        -- Duration in milliseconds
        duration = 200,

        -- Animation curve
        curve = "ease-out",

        -- Start properties
        from = {
            opacity = 0,
            scale = 0.8,
        },

        -- End properties
        to = {
            opacity = 1,
            scale = 1.0,
        },
    }
})

Window Close

samwm.animations({
    window_close = {
        duration = 150,
        curve = "ease-in",
        from = {
            opacity = 1,
            scale = 1.0,
        },
        to = {
            opacity = 0,
            scale = 0.8,
        },
    }
})

Window Focus

samwm.animations({
    window_focus = {
        duration = 100,
        curve = "ease-out",
        border_color = {0.2, 0.6, 1.0, 1.0},
    }
})

Workspace Switch

samwm.animations({
    workspace_switch = {
        duration = 300,
        curve = "ease-in-out",
        effect = "slide", -- slide, fade, instant
        direction = "left", -- left, right, up, down
    }
})

Window Move

samwm.animations({
    window_move = {
        duration = 200,
        curve = "spring",
        use_physics = true,
    }
})

Window Resize

samwm.animations({
    window_resize = {
        duration = 150,
        curve = "ease-out",
    }
})

Presets

Fast & Snappy

samwm.animations({
    enabled = true,
    speed = 1.5,
    window_open = { duration = 100 },
    window_close = { duration = 80 },
    workspace_switch = { duration = 150 },
})

Smooth & Fluid

samwm.animations({
    enabled = true,
    speed = 0.8,
    window_open = { duration = 400, curve = "ease-out" },
    window_close = { duration = 300, curve = "ease-in" },
    workspace_switch = { duration = 500, curve = "ease-in-out" },
})

Disabled

samwm.animations({
    enabled = false,
})

Easing Functions

Supported easing curves:

Name Description
linear No easing
ease Default ease
ease-in Start slow, end fast
ease-out Start fast, end slow
ease-in-out Slow start and end
spring Spring physics
bounce Bouncing effect

Lua API

Enable/Disable Animations

samwm.animations({ enabled = true })
samwm.animations({ enabled = false })

Set Animation Speed

samwm.set_animation_speed(1.0) -- Normal
samwm.set_animation_speed(2.0) -- Double speed
samwm.set_animation_speed(0.5) -- Half speed

Animate Custom Properties

samwm.animate(window, {
    duration = 300,
    properties = {
        x = 100,
        y = 100,
        width = 800,
        height = 600,
        opacity = 1.0,
    },
    curve = "ease-out",
})

Stop Animation

samwm.stop_animation(window, "move")

Event Hooks

-- Animation started
samwm.on("animation_start", function(window, type)
    print("Animation started:", type, window.title)
end)

-- Animation completed
samwm.on("animation_end", function(window, type)
    print("Animation completed:", type, window.title)
end)

Performance Tips

  • Disable on low-end hardware
  • Use linear curve for simpler rendering
  • Reduce duration for faster animations
  • Avoid animating opacity on GPU-intensive apps

Integration with wlr_scene

Animations are implemented using wlr_scene’s node properties:

  • Position changes via wlr_scene_node_set_position
  • Size changes via scene rect APIs
  • Opacity via scene node alpha
  • Staggered animations for multiple windows