Skip to content

Animated lock/screensaver #2254

@TimsManter

Description

@TimsManter

It's an use case of swaylock and an idea for little improvement to make swaylock more flexible.

I've managed to personalize swaylock so it now works as animated lock screen. The way is to use custom script which creates floating window with specified title (termite + cmatrix in my case), next runs swaylock with transparent color and at the end waits for swaylock process to exit then kills floating window. Script by itself looks like so:

#!/bin/sh
term='termite -t Screensaver -e'
saver=cmatrix
locker='swaylock -c 00000000'
($term $saver) &
sleep .2
($locker && kill $!) &

And is controlled by swayidle in config:

for_window [title="Screensaver"] floating enable
for_window [title="Screensaver"] fullscreen enable
set $kbdbl sudo brightnessctl -d tpacpi::kbd_backlight set
set $scroff swaymsg "output * dpms off"
set $scron swaymsg "output * dpms on"
set $hidecursor swaymsg seat seat0 cursor set 2000 2000
exec swayidle \
  timeout 5 '$hidecursor' \
  timeout 300 locker \
  timeout 360 '$scroff; $kbdbl 0' \
    resume '$scron; $kbdbl 1' \
  before-sleep locker

The final result depends on:

  • If there's no fullscreen window already: Shows fullscreen cmatrix and enables transparent swaylock so nothing below is visible,
  • If there's e.g. fullscreen YouTube video or any other fullscreen window: Termite is not getting fullscreen so the primary window is visible under transparent swaylock (so it's still locked).

I think there're at least two things that can be improved:

  1. Ability to set command to run in swaylock container just like solid color or image so the script wouldn't be mandatory,
  2. Appearance setting to disable cleared indicator or set delay in seconds after indicator is hidden; current --no-unlock-indicator is not a good solution.

BTW: The setup above works on current wlroots version of sway from the latest master branch.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions