Script output over a random image in swaylock

Nothing really sophisticated, but looks not bad. Maybe some sway / river / dwl / whatever user finds it useful.

  1. Prerequisites: swaylock, nwg-wrapper

  2. Save this to your bin folder, make executable, run to lock the screen:


nwg-wrapper -s -o eDP-1 -r 20000 -c timezones.css -p right -mr 50 -a start -mt 0 -j right -l 3 -sq 31 &

pic=$(rffd -p /home/piotr/Obrazy/lockscreen/)
sleep 0.5 && swaylock --image $pic && pkill -f -31 nwg-wrapper

  1. The script to produce whatever content displayed by nwg-wrapper over swaylock. Save as ~/.config/nwg-wrapper/, make executable. Use own path to images folder:

time=$(date +'%a, %d. %b  %H:%M')
echo '<span size="20000" foreground="#c6ad8f" face="monospace">'$time'</span>'
echo; echo '<span size="12000" foreground="#cccccc" face="monospace">'$(echo $USER)'@'$(uname -n) on $(uname -sr)'</span>'
echo '<span size="12000" foreground="#cccccc" face="monospace">'$(uptime -p)'</span>'
  1. Simple ~/.config/nwg-wrapper/timezones.css contains nothing but a transparent window:
window {
    background-color: rgba (0, 0, 0, 0.0);
  1. Python script to draw a random image. Save as rffd in your bin directory, make executable:

This scripts returns a random file path from given directory.
Subdirectories are not being searched.

import os
import argparse
import sys
import random

def main():
    parser = argparse.ArgumentParser()
                        help="full path to draw the file from")

    args = parser.parse_args()
    if not args.path:
        print("No patch specified")

    if not os.path.isdir(args.path):
        print("{} is not a directory".format(args.path))
        files = []
        paths = os.listdir(args.path)
        for p in paths:
            if os.path.isfile(os.path.join(args.path, p)):

        print(os.path.join(args.path, files[random.randint(0, len(files)-1)]))

if __name__ == '__main__':


Top job again @nwg

Nice video !

1 Like

Cool idea @nwg, thanks for the share!!

1 Like