Giter Site home page Giter Site logo

swaylock-effects's Introduction

swaylock-effects

Swaylock-effects is a fork of swaylock which adds built-in screenshots and image manipulation effects like blurring. It's inspired by i3lock-color, although the feature sets aren't perfectly overlapping.

Screenshot

Example Command

swaylock \
	--screenshots \
	--clock \
	--indicator \
	--indicator-radius 100 \
	--indicator-thickness 7 \
	--effect-blur 7x5 \
	--effect-vignette 0.5:0.5 \
	--ring-color bb00cc \
	--key-hl-color 880033 \
	--line-color 00000000 \
	--inside-color 00000088 \
	--separator-color 00000000 \
	--grace 2 \
	--fade-in 0.2

New Features

The main new features compared to upstream swaylock are:

  • --screenshots to use screenshots instead of an image on disk or a color
  • --clock to show date/time in the indicator
    • Use --indicator to make the indicator always active
    • Use --timestr and --datestr to set the date/time formats (using strftime-style formatting)
  • --submit-on-touch to use your touchscreen to submit a password. If you can unlock your device with anything else than your password, this might come helpful to trigger PAM's authentication process.
  • --grace <seconds> to set a password grace period, so that the password isn't required to unlock until some number of seconds have passed.
    • Used together with --indicator, the indicator is always shown, even in the grace period.
    • Used together with --indicator-idle-visible, the indicator is only visible after the grace period.
    • By default, a key press, a mouse event or a touch event will unlock during the grace period. Use --grace-no-mouse to not unlock as a response to a mouse event, and --grace-no-touch to not unlock as a response to a touch event.
  • --fade-in <seconds> to make the lock screen fade in.
  • Various effects which can be applied to the background image
    • --effect-blur <radius>x<times>: Blur the image (thanks to yvbbrjdr's fast box blur algorithm in i3lock-fancy-rapid)
    • --effect-pixelate <factor>: Pixelate the image.
    • --effect-scale <scale>: Scale the image by a factor. This can be used to make other effects faster if you don't need the full resolution.
    • --effect-greyscale: Make the image greyscale.
    • --effect-vignette <base>:<factor>: Apply a vignette effect (range is 0-1).
    • --effect-compose <position>;<size>;<gravity>;<path>: Overlay another image.
    • --effect-custom <path>: Load a custom effect from a C file or shared object.

New feature ideas are welcome as issues (though I may never get around to implement them), new feature implementations are welcome as pull requests :)

Installation

From Packages

Compiling from Source

Install dependencies:

  • meson *
  • wayland
  • wayland-protocols *
  • libxkbcommon
  • cairo
  • gdk-pixbuf2 **
  • pam (optional)
  • scdoc (optional: man pages) *
  • git *
  • openmp (if using a compiler other than GCC)

*Compile-time dep

**Optional: required for background images other than PNG

Run these commands:

meson build
ninja -C build
sudo ninja -C build install

On systems without PAM, you need to suid the swaylock binary:

sudo chmod a+s /usr/local/bin/swaylock

Swaylock will drop root permissions shortly after startup.

Effects

Blur

--effect-blur <radius>x<times>: Blur the image.

<radius> is a number specifying how big the blur is, <times> is a number which specifies essentially how high quality the blur is (i.e how closely the effect will resemble a true gaussian blur).

Pixelate

--effect-pixelate <factor>: Pixelate the image.

<factor> is the amount of pixelation; a value of 10 will make each 10x10 square of pixels the same color.

Scale

--effect-scale <scale>: Scale the image by a factor.

This effect scales the internal buffer. This has a few uses:

  • Use --effect-scale in combination with --scaling to create a zoom effect: --effect-scale 1.1 --scaling center
  • Speed up other effects by making the resolution smaller: with --effect-scale 0.5 --effect-blur 7x5 --effect-scale 2, swaylock-effect needs to blur only 1/4 as many pixels.

Greyscale

--effect-greyscale: Make the displayed image greyscale.

Vignette

--effect-vignette <base>:<factor>: Apply a vignette effect. Base and factor should be between 0 and 1.

Compose

--effect-compose "<position>;<size>;<gravity>;<path>": Overlay another image to your lock screen.

  • <position>: Optional. The position on the screen to put the image, as <x>,<y>.
    • Can be a percentage (10%,10%), a number of pixels (20,20), or a mix (30%,40).
    • A negative number indicates that number of pixels away from the right/bottom instead of from the top/left; -1,-1 would be the bottom right pixel.
    • Default: 50%,50%.
  • <size>: Optional. The size of the image on the screen, as <w>x<h>.
    • Can be a percentage (10%x10%), a number of pixels (20x20), or a mix (30%x40).
    • If the width is -1, the width is figured out based on the height and aspect ratio.
    • If the height is -1, the height is figured out based on the width and aspect ratio.
    • Default: The size of the image file.
  • <gravity>: Optional. Determine which point of the image is placed at <position>.
    • Possible values: center, north, south, west, east, northwest, northeast, southwest, southeast`.
    • With a <gravity> of northwest, <position> gives the location of the top/left corner of the image; with southeast, <position> controls the bottom/right corner, center controls the middle of the image, etc.
    • Default: center if no <position> is given; otherwise, intelligently decide a gravity based on position (10,10 -> northwest, -10,10 -> northeast, etc).
  • <path>: The path to an image file.

This command requires swaylock-effects to be compiled with gdk-pixbuf2. It supports all image formats gdk-pixbuf2 supports; on my system, that's png, jpeg, gif, svg, bmp, ico, tiff, wmf, ani, icns, pnm, qtif, tga, xbm and xpm.

Custom

--effect-custom <path>: Load a custom effect from a shared object.

The .so must export a function void swaylock_effect(uint32_t *data, int width, int height) or a function uint32_t swaylock_pixel(uint32_t pix, int x, int y, int width, int height).

swaylock-effects's People

Contributors

abdelq avatar acrisci avatar attente avatar bendooru avatar cedws avatar christophgysin avatar ddevault avatar deklov avatar eli-schwartz avatar emersion avatar fluxchief avatar gdamjan avatar ggreer avatar ianyfan avatar ivyl avatar jbeich avatar johnae avatar jubalh avatar martinetd avatar mikkeloscar avatar milkey-mouse avatar mortie avatar mswiger avatar nuew avatar redsoxfan avatar ryandwyer avatar thra11 avatar usersv4 avatar wasamasa avatar yschaeff avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

swaylock-effects's Issues

Building error

This error occures while building package from AUR:

Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/mesonbuild/mesonmain.py", line 132, in run
    return options.run_func(options)
  File "/usr/lib/python3.9/site-packages/mesonbuild/msetup.py", line 279, in run
    app.generate()
  File "/usr/lib/python3.9/site-packages/mesonbuild/msetup.py", line 183, in generate
    self._generate(env)
  File "/usr/lib/python3.9/site-packages/mesonbuild/msetup.py", line 245, in _generate
    intr.backend.generate()
  File "/usr/lib/python3.9/site-packages/mesonbuild/backend/ninjabackend.py", line 532, in generate
    for t in ProgressBar(self.build.get_targets().values(), desc='Generating targets'):
  File "/home/bohdan-arch/.local/lib/python3.9/site-packages/tqdm/_tqdm.py", line 388, in __new__
    cls.monitor = TMonitor(cls, cls.monitor_interval)
  File "/home/bohdan-arch/.local/lib/python3.9/site-packages/tqdm/_tqdm.py", line 68, in __init__
    getattr(sys, 'setcheckinterval'))(100)
AttributeError: module 'sys' has no attribute 'setcheckinterval'
Exception ignored in: <function tqdm.__del__ at 0x7fbee752e670>
Traceback (most recent call last):
  File "/home/bohdan-arch/.local/lib/python3.9/site-packages/tqdm/_tqdm.py", line 790, in __del__
    self.close()
  File "/home/bohdan-arch/.local/lib/python3.9/site-packages/tqdm/_tqdm.py", line 1017, in close
    if self.disable:
AttributeError: 'ProgressBarTqdm' object has no attribute 'disable'
==> ERROR: A failure occurred in build().
    Aborting...
error making: swaylock-effects-git

Kernel version: 5.11.13-arch1-1

Wrong rotation of screenshot when transform was set in sway

swaylock-effects version: v1.6-1

sway config
output HDMI-A-1 transform 90

Monitor (hardware, rotated)

    +------+
    |      |
    |      |
    |      |
UP  |      |  Down
    |      |
    |      |
    +------+

Screen

   UP

+------+
|      |
|      |
|      |
|      |
|      |
|      |
+------+

  DOWN

swaylock screenshot ($ swaylock -S)

     +------+
     |      |
     |      |
DOWN |      | UP
     |      |
     |      |
     |      |
     +------+

$ swaylock is fine, just the screenshot has wrong rotation.

`grace` option unrecognized when set in config file

--grace <seconds> works correctly when used from the command line, but when set in the config file:

indicator
grace 5

we get this error:

$ swaylock
swaylock: unrecognized option '--grace 5'
Usage: swaylock [options...]
...

Screenshot background appears upside down

I just noticed that the screenshots taken by swaylock-effects appear upside down on the lockscreen. I'm not sure since which version this is happening, because I probably haven't looked that closely in the past (and with all the blur effect applied the bug is not obvious ;-) )... but here's some version information:

  • Fedora 34 Workstation
  • Swaylock-effects 1.6-1
  • Sway 1.6

My swaylock command:

/usr/bin/swaylock  --screenshots \
                                    --effect-blur 7x5 \
                                    --effect-vignette 0.5:0.5

Is this reproducible for anyone of you?

Edit: Background images with --image do not appear upside down.

Clock text is invisible

Clock text is invisible until i directly specify its color, for example
cairo_set_source_u32(cairo, state->args.colors.ring.verifying); cairo_show_text(cairo, text_l1);
I`m currently using sway as my wm.

Doesn't accept password

I rebuilt swaylock-effects from source on fedora 34 to get around the inverse screen effect and now it doesn't accept my password. I've tried enough times to be certain of this. It sometimes says cleared in situations where it isn't supposed to have input.

When using `fade-in`, suspending the laptop shows screen contents

Given the config below with a 0.2s fade in, when I suspend my laptop the animation doesn't complete before the laptop actually goes into sleep. I'm not entirely sure how to avoid this. The animation completes after the laptop resumes from suspension.

The main take away here is that screen contents aren't obfuscated and are visible for a few seconds after resuming.

Vid: https://www.youtube.com/watch?v=pBpErmBESo4

Sway config:

exec swayidle -w \
         timeout 300 'swaylock -f -c 000000 -i $lock_bg' \
         timeout 600 'swaymsg "output * dpms off"' \
              resume 'swaymsg "output * dpms on"' \
         before-sleep 'swaylock -f -c 000000 -i $lock_bg'

Swaylock-effects config:

ignore-empty-password
font=Ubuntu

clock
timestr=%R
datestr=%a, %e of %B

screenshots

fade-in=0.2

effect-blur=30x2
effect-greyscale
effect-scale=0.1

indicator
indicator-radius=240
indicator-thickness=20
indicator-caps-lock

key-hl-color=880033

separator-color=00000000

inside-color=00000099
inside-clear-color=ffd20400
inside-caps-lock-color=009ddc00
inside-ver-color=d9d8d800
inside-wrong-color=ee2e2400

ring-color=231f20D9
ring-clear-color=231f20D9
ring-caps-lock-color=231f20D9
ring-ver-color=231f20D9
ring-wrong-color=231f20D9

line-color=00000000
line-clear-color=ffd204FF
line-caps-lock-color=009ddcFF
line-ver-color=d9d8d8FF
line-wrong-color=ee2e24FF

text-clear-color=ffd20400
text-ver-color=d9d8d800
text-wrong-color=ee2e2400

bs-hl-color=ee2e24FF
caps-lock-key-hl-color=ffd204FF
caps-lock-bs-hl-color=ee2e24FF
disable-caps-lock-text
text-caps-lock-color=009ddc

Feature: Battery indicator (or generic status)

Sometimes it's nice to check the battery charge without having to unlock it. It's not uncommon for other desktops to show a battery indicator on their lockscreens.

Having said that, working out how to read the status of different batteries is quite complex (Sometimes it comes from acpi, sometimes you have to read sysfs, and then there's a bunch of different properties which may or may not exist), so probably not something you want to reimplement in a screen locker.

This got me thinking... what if swaylock-effects just had an option to periodically run a command and display the result, the way swaybar does? That way, I could have my battery status with whatever percentage / time left / icon-font combination I happen to prefer by simply running i3status (or whatever your favourite variant is) with a minimal config, but it would also allow a wide variety of other use cases (Maybe someone else wants to show the weather forecast, or the currently playing track).

Options that might be helpful: update frequency, position, font, colour, etc.

Grace does not work correctly with sleep

When locking and sleeping with a grace period setup, the time the PC is sleeping does not count for grace period.
Maybe the systemtime should be used to make sure that not only the time, while swylock is activly running counts.

Indicator doesn't show when used with --grace

I'm using the swaylock-effects-git from AUR on Arch Linux. When I set a grace period, indicator never shows up, however if I run the exact same command without the grace option everything works as expected.

Fade in and out the lockscreen

This is perhaps a bit of a long shot considering sway itself doesn't support animations yet, but I was wondering if it is technically possible for swaylock-effects to do transitions from the desktop to the lockscreen. an MVP would perhaps be a simple alpha fade.

Is this something that can be implemented here alone, or does it require wlroots support?

Package Request

Hey there!
You're missing out Void Linux to distribute this package. Here, I made a template for xbps-src and it works perfectly.

# Template file for 'swaylock-effects'
pkgname=swaylock-effects
version=1.6
revision=3
archs="x86_64"
build_style=meson
conf_files="/etc/pam.d/swaylock"
hostmakedepends="pkg-config wayland-devel scdoc git"
makedepends="wayland-protocols cairo-devel gdk-pixbuf-devel pam-devel
 libxkbcommon-devel wayland-devel libgomp-devel"
short_desc="Swaylock, with fancy effects"
replaces=swaylock>=0
maintainer="<>"
license="MIT"
homepage="https://github.com/mortie/swaylock-effects"
distfiles="${homepage}/archive/refs/tags/v${version}-${revision}.tar.gz"
checksum=c7c4e420276aef9bd952b321b68e24c31f050859a226edb8fde15a5ccee1a9fe
wrksrc=${pkgname}-${version}-${revision}

post_install() {
	vlicense LICENSE
}

Calling swaylock-effects while its running should modify the currently running instance

This may be a huge feature request, but if that is possible, it would allow to implement like a battery indicator #25. rotating lock images or even displaying arts of the current running music without that swaylock-effects needs to support this explicit.

The feature is if swaylock-effects gets called a second time while swaylock-effects (not default swaylock or so) is already running, the new process tries to build up a new rendered lock picture (taking a screenshot of the screen behind the lock screen while its locked might be not easy or possible at all) with new configuration given and then transfers this picture to the currently running swaylock instance via IPC so that the running instance can update its pictures.
This feature may also support other settings like fade (fading from old to new picture) or grace or the indicator configuration. Together with an option like --only-update (which does prevent opening swaylock-effects if it is currently not running but supports updating an already running instance) you could easily implement things like a live battery or network indicator.

Linking error using clang

The error I'm getting when trying to build with ninja:

[1/1] Linking target swaylock. FAILED: swaylock /usr/bin/clang -o swaylock 'swaylock@exe/background-ima ge.c.o' 'swaylock@exe/cairo.c.o' 'swaylock@exe/comm.c.o' 'swaylock@exe/log.c.o' 'swaylock@exe/loop.c.o' 'swayloc k@exe/main.c.o' 'swaylock@exe/password.c.o' 'swaylock@ex e/pool-buffer.c.o' 'swaylock@exe/render.c.o' 'swaylock@e xe/seat.c.o' 'swaylock@exe/unicode.c.o' 'swaylock@exe/ef fects.c.o' 'swaylock@exe/pam.c.o' -Wl,--no-undefined -Wl ,--as-needed -fopenmp -flto -Wl,--start-group libclient_ protos.a /usr/lib64/libcairo.so /usr/lib64/libgdk_pixbuf -2.0.so /usr/lib64/libgobject-2.0.so /usr/lib64/libglib- 2.0.so -lm -lrt -ldl /usr/lib64/libxkbcommon.so /usr/lib 64/libwayland-client.so -lpam -Wl,--end-group '-Wl,-rpat h,$ORIGIN/' -Wl,-rpath-link,/home/z4rcher/swaylock-effects/ build/ /usr/bin/ld: libclient_protos.a: error adding symbols: a rchive has no index; run ranlib to add one

And trying to build index using ranlib I got:
ranlib: libclient_protos.a: no archive map to update

Wrong Input during waking up screen

To reproduce

  • wait for screen to turn off due to inactivity by using swayidle
  • type your password and hit enter

Expected Behaviour

  • screen should be unlocked by swaylock ( as per swaylock upstream )

Error

  • password dosn't get recognised

Issue : swaylock-effect is not parsing first keypress correctly, once I press the key after screen is turned off, I have to press backspace 7-9 times to clear the password input text completely and only then I can re-enter my password
Present in both swaylock-effects and swaylock-effects-git

swayidle error : [pam.c:101] pam_authenticate failed: unknown error (6)

swayidle command to test : swayidle -w timeout 10 'swaylock -f -c 000000' timeout 20 'swaymsg "output * dpms off"' resume 'swaymsg "output * dpms on"' before-sleep 'swaylock -f -c 000000'

question: upstreaming to swaylock

Hello!

I am wondering if there are plans to upstream this to swaylock?

I'd consider uploading this to Debian repositories ( I am a Debian Developer), but I wouldn't need to do that if some of the swaylock-effects features got merged in swaylock.

Even if that is suboptimal, I might also prefer uploading a i3lock-fancy-like solution (script that takes a screenshot and passes it to swaylock) because it would probably require less maintenance and wouldn't fall out of sync with swaylock

Indicator ring not shown

I've noticed that the indicator ring isn't showing when swaylock-effects is activated since moving to latest wlroots-git and sway-git from the AUR as of March 9th. The screen still locks and unlocks properly, just the indicator ring is missing. If I use a secondary monitor however the indicator ring does show on that monitor. Also, swaylock upstream properly shows the ring. I wonder there are upstream commits that need to be pulled in? I'm currently using latest of swaylock-effects-git from the AUR

Let me know if there's any more info I can provide or anything else I can do to help debug! Thanks!

--effect-compose not scaling correctly

I've got a 1080p monitor and a 1440p monitor with a composite image centered inside of the indicator. I've noticed that the pixel value doesn't match the indicator diameter. The image is set to 190px while the indicator radii is set to 60px (so 130px diameter including the thickness).

image
1440p

image

1080p

If it would scale correctly the image size would be smaller on my 1440p monitor while bigger on the 1080p display

release outdated

I know there's not tons of changes since last year, but for the manjaro package I'd really like to bind to a newer release. would you mind doing for example a patch release?

Would not build on Debian Bullseye due to missing include of stdio.h

Seems to be a missing include of stdio.h in effects.c making it impossible to build for me:

diff --git a/effects.c b/effects.c
index e63f722..89b28a4 100644
--- a/effects.c
+++ b/effects.c
@@ -15,6 +15,7 @@
 #include <time.h>
 #include "effects.h"
 #include "log.h"
+#include "stdio.h"

Clock disappears with caps lock on

When numlock is on, and indicator-caps-lock is active in swaylock, the clock disappears.

Config:

ignore-empty-password
font=Ubuntu

clock
timestr=%R
datestr=%a, %e of %B

screenshots

effect-blur=30x3
effect-greyscale
effect-scale=2

indicator
indicator-radius=240
indicator-thickness=20
indicator-caps-lock

key-hl-color=880033

separator-color=00000000

inside-color=00000088
inside-clear-color=ffd20400
inside-caps-lock-color=009ddc00
inside-ver-color=d9d8d800
inside-wrong-color=ee2e2400

ring-color=231f20D9
ring-clear-color=231f20D9
ring-caps-lock-color=231f20D9
ring-ver-color=231f20D9
ring-wrong-color=231f20D9

line-color=00000000
line-clear-color=ffd204FF
line-caps-lock-color=009ddcFF
line-ver-color=d9d8d8FF
line-wrong-color=ee2e24FF

text-clear-color=ffd20400
text-caps-lock-color=009ddc00
text-ver-color=d9d8d800
text-wrong-color=ee2e2400

bs-hl-color=ee2e24FF
caps-lock-key-hl-color=ffd204FF
caps-lock-bs-hl-color=ee2e24FF

Feature Request: Composite a logo onto a lockscreen image

It'd be nice to allow for some basic image compositing. Right now, I use the following helper script with the upstream swaylock. It takes a screenshot of the specified display, blurs it, and adds an icon/logo to the center of the blurred screenshot at 20% of the height of the screenshot. Ends up looking like this.

lock.sh
#!/usr/bin/env sh

OVERLAY=~/.dotfiles/sway/images/_lock_img
WORKDIR=$(mktemp -d)
DISPLAY=${1}

grim -o "${DISPLAY}" - | mogrify -blur 0x5 png:- > $WORKDIR/lock_initial.png

if [ -f "$OVERLAY" ]; then
  HEIGHT_PERCENT=$(convert $WORKDIR/lock_initial.png -format "%[fx:0.2*h]" info:);
  convert -background transparent -density 400 -resize x$HEIGHT_PERCENT $OVERLAY png:- \
    | convert $WORKDIR/lock_initial.png png:- -gravity center -composite png:- > $WORKDIR/lock.png
else
  mv $WORKDIR/lock_initial.png $WORKDIR/lock.png;
fi

swaylock -u -i $WORKDIR/lock.png;
#rm -rf $WORKDIR;
exit 0;

This works fine, but imagemagick is a little slow. Is this something you'd be interested in adding?

Locale settings

Hello,
I am using the packaged version in Fedora 31, and I find it ignoring my locale settings.
This is in my config:

clock
timestr=%R
datestr=%A %e. %B %Y

And this is the ouput of the locale command:

LANG=cs_CZ.UTF-8
LC_CTYPE="cs_CZ.UTF-8"
LC_NUMERIC="cs_CZ.UTF-8"
LC_TIME="cs_CZ.UTF-8"
LC_COLLATE="cs_CZ.UTF-8"
LC_MONETARY="cs_CZ.UTF-8"
LC_MESSAGES="cs_CZ.UTF-8"
LC_PAPER="cs_CZ.UTF-8"
LC_NAME="cs_CZ.UTF-8"
LC_ADDRESS="cs_CZ.UTF-8"
LC_TELEPHONE="cs_CZ.UTF-8"
LC_MEASUREMENT="cs_CZ.UTF-8"
LC_IDENTIFICATION="cs_CZ.UTF-8"
LC_ALL=

What I get is "Tuesday 31. March 2020" and I expect "Úterý 31. Březen 2020" per my locale. Interestingly, the time is in the correct timezone. Other applications (likew waybar) use the correct locale. Any idea what can cause this behaviour? Any help would be much appreciated.

Bar indicator

Could you please consider adding support for the bar indicator as seen in i3lock-color?

[Feature request] Enable video file playing (via mpv, mplayer or similar)

While swaylock is minimal, I genuinely prefer nicer lockscreens, so glad to see this fork.

Is it possible to add the capability to play a movie on loop from the lock? And then overlay the unlocking interface?

Am attempting to find a way to duplicate Aerial on sway (so minimal, and jaw-droppingly gorgeous... =] ).

thanks! (already added this to my Arch sway config... =] ).

FR request/investigation --background option to scrape existing background

This came up in #33. It would be nice to have a --background option alongside --image and --screenshot which can use the existing per-output background (with effects applied). This would hopefully reuse all of the existing scaling/cropping done by swaybg rather than needing to separate pass the same background(s) to --image (which AFAIK doesn't have a full set of options to scale/crop).

Feature request: launch subprocess to draw background

I was originally going to ask about a feature to rotate background images every N minutes, but now I think that would lead to a horribly complicated interface after a few years of feature expansion.

Instead, I would like to propose a plugin/subprocess architecture, in which swaylock-effects runs a background-drawing program (like swaybg, or a shell script to periodically rerun swaybg) inside a nested Wayland compositor, and uses the surfaces that the nested process provides to draw its own background. This can be done efficiently, because swaylock already uses a separate surface to draw the text and indicator icon, so it only has to provide the buffers already submitted by the subprogram .

To check that this is possible, I made a prototype! Expand for details.
  • Source code available at: https://github.com/mstoeckl/swaylock-plugin . It requires that the subprograms implement a rarely used but simple to implement protocol, fullscreen-shell-unstable-v1 . I have a branch of swaybg which implements the protocol at mstoeckl/swaybg/fullscreen-shell, mstoeckl/swaybg@24557b1 . I also converted a few XScreenSaver backgrounds to run using this protocol, see https://git.sr.ht/~mstoeckl/wscreensaver , and have an animated background of my own at https://git.sr.ht/~mstoeckl/rwalkbg .

  • Example usage: swaylock --command 'swaybg -i test.jpg', or
    swaylock --command 'voronoi --wayland'.

  • Limitations of the prototype: it doesn't have a way to restart the background process if it dies or replace it with a new swaybg.
    It does a weird and possibly unnecessary subsurface trick to render the background surface. It requires an Mesa-specific protocol to render OpenGL backgrounds. It does not support resizing or removing outputs at runtime. It doesn't support subprocesses that support only layer-shell. It is currently based on upstream swaylock, not on swaylock-effects, so the prototype lacks all of swaylock-effect's options.

  • Good things: it's not a very invasive change -- adding the nested Wayland server is a small change to the event loop, a few extra protocols in the build, a few extra struct fields, maybe 50 changed lines to existing functions, and about 800 lines which could safely be put in their own file. The nested compositor ensures that the background process does not receive any user input, and runs independently of swaylock, so swaylock can immediately start and listen for input instead of waiting for the background to load/screenshot to blur.

Unfortunately, I can't guarantee that I will have time to bring my prototype to completion, but probably can do a 90%-correct fix for any of the above limitations if asked. The last 10% are tricky.

Since a subprocess implementation might add 500-2K lines of code, this is a rather large feature request; but hopefully something others are interested in and which could integrate well with current swaylock-effects.

Fails to build swaylock.p/fade.c.o

I'm packaging this project for Gentoo, but since 600477e it doesn't build on my machine.

Meson version: 0.55.1
Ninja version: 1.10.0
OS: Gentoo Linux
Processor: Intel(R) Core(TM) i7-5500U CPU @ 2.40GHz

build log
ninja: Entering directory `build'
[1/2] Compiling C object swaylock.p/fade.c.o
FAILED: swaylock.p/fade.c.o 
ccache cc -Iswaylock.p -I. -I.. -Iinclude -I../include -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/lib64/libffi/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/uuid -I/usr/include/libpng16 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libmount -I/usr/include/blkid -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -Werror -std=c11 -g -Wno-unused-parameter -Wno-unused-result -Wundef -Wvla -fopenmp -O3 -mtune=native '-DSYSCONFDIR="//usr/local/etc"' '-DSWAYLOCK_VERSION="v1.6-1-6-g2cbc0c8 (" __DATE__ ", branch '"'"'master'"'"')"' -pthread -MD -MQ swaylock.p/fade.c.o -MF swaylock.p/fade.c.o.d -o swaylock.p/fade.c.o -c ../fade.c
../fade.c: In function 'set_alpha_sse':
../fade.c:41:22: error: implicit declaration of function '_mm_loadu_si64'; did you mean '_mm_loadl_epi64'? [-Werror=implicit-function-declaration]
   __m128i argb_vec = _mm_loadu_si64(orig_bytes + index);
                      ^~~~~~~~~~~~~~
                      _mm_loadl_epi64
../fade.c:41:22: error: incompatible types when initializing type '__m128i' {aka '__vector(2) long long int'} using type 'int'
../fade.c:49:3: error: implicit declaration of function '_mm_storeu_si64'; did you mean '_mm_store_epi64'? [-Werror=implicit-function-declaration]
   _mm_storeu_si64(dest_bytes + index, argb_vec);
   ^~~~~~~~~~~~~~~
   _mm_store_epi64
cc1: all warnings being treated as errors
ninja: build stopped: subcommand failed.

Grace period before full lock

I don't know if this is in scope for this project but it would be nice to be able to have a few seconds when it locks to wiggle the mouse or something and have it immediately unlock. While I watch YouTube it tends to lock -- probably because of no input -- and I have to type in my password which is not short. This might be better to implement in swayidle but I'm not certain. If anyone has guidance, I'd love to try and implement it.

effect-compose path bug

Using ~/image/image.png result in

[effects.c:374] Compose effect: Failed to load image file '~/image/image.png' (Failed to open file “~/image/image.png”: No such file or directory).

But using full path like /home/user/image/image.png works

Image path works though using ~

[Bug] Lock fails if screenshot fails

Issue
When using a screenshot as a lockscreen and the screencopy tool fails - the lock will terminate

Expected Behaviour
The lock will use a fallback such as a black screen if the screencopy fails.

ConfigFile

#General
screenshots
clock
indicator
ignore-empty-password
grace=5
grace-no-mouse
fade-in=0.2
datestr="%a, %d/%m/%y"


indicator-radius=80
indicator-thickness=5

effect-blur=7x5
effect-vignette=0.5:0.5

#Colors
bs-hl-color=D08770
inside-color=2E344080
inside-clear-color=2E344080
inside-ver-color=2E344080
inside-wrong-color=BF616A80
key-hl-color=88C0D0
line-color=00000000
line-clear-color=00000000
line-ver-color=00000000
line-wrong-color=00000000
ring-color=5E81AC
ring-clear-color=5E81AC
ring-ver-color=5E81AC
ring-wrong-color=5E81AC
separator-color=00000000
text-color=D08770
text-clear-color=D08770
text-ver-color=D08770
text-wrong-color=2E3440

--effect-compose size not affected by scaling, proposing additional modifier

Quoted the manual of --effect-compose:

  • <size>: Optional. The size of the image on the screen, as <w>x<h>.
    • Can be a percentage (10%x10%), a number of pixels (20x20), or a mix (30%x40).
    • If the width is -1, the width is figured out based on the height and aspect ratio.
    • If the height is -1, the height is figured out based on the width and aspect ratio.
    • Default: The size of the image file.

I want to use effect-compose to add a company logo above the indicator in a similar size. As I tried to resize it to the right size I discovered that the indicator's size is affected by scaling of the output but the size of effect-compose is not.
For explaining, I have two screens (the internal of my laptop and an external screen) and the laptop screen has enabled an scaling of 2 while the normal screen has a scaling of 1. Also both screens have different resolutions (3000x2000 vs 2560x1440).
Because of the different resolutions, I cannot use the % modifier and because of the different scaling, I cannot use an absolute declaration.

I would propose adding a new modifier (maybe a ~ or something else) which allows setting the size in pixels but is affected by the scaling of the screen (e.g. 300~x-1), if this is possible to implement. Also a ~% modifier must not be implemented because it makes no sense that a fraction of the screen size may be affected by the scaling.
This would allow users using different scalings on different screens to let symbols having the same size relative to the indicator across different screens for example, while keeping the old behavior that the pixel size is not affected by the scaling.

Errors with source build

Built from source because this said that would fix the inversion issue. Every time I try to run swaylock-effects I get an error in red saying [shadow.c:18] swaylock needs to be setuid to read /etc/shadow. If I run swaylock as root(shouldn't need it, but just in case), I get a different error saying [shadow.c:36] Unable to drop root (we shouldn't be able to restore it after setuid): Success

Release Tags

Currently, it seems like swaylock-effects is using swaylock's git tags with the effects patches rebased on top of the last release.

Could you have separate release tags so that we can package this outside of the AUR?

Thanks.

failed to compile on debian buster T.T

original swaylock compiles fine, but could not compile swaylock-effect, error is following:

ninja: Entering directory `build'
[1/2] Compiling C object 'swaylock@exe/fade.c.o'.
FAILED: swaylock@exe/fade.c.o
cc -Iswaylock@exe -I. -I.. -Iinclude -I../include -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libmount -I/usr/include/blkid -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -Werror -std=c11 -g -Wno-unused-parameter -Wno-unused-result -Wundef -Wvla -fopenmp '-DSYSCONFDIR="//usr/local/etc"' -mtune=native '-DSWAYLOCK_VERSION="v1.6-3-4-g3aa6b4b (" DATE ", branch '"'"'master'"'"')"' -pthread -MD -MQ 'swaylock@exe/fade.c.o' -MF 'swaylock@exe/fade.c.o.d' -o 'swaylock@exe/fade.c.o' -c ../fade.c
../fade.c: In function ‘set_alpha_sse’:
../fade.c:41:22: error: implicit declaration of function ‘_mm_loadu_si64’; did you mean ‘_mm_loadl_epi64’? [-Werror=implicit-function-declaration]
__m128i argb_vec = _mm_loadu_si64(orig_bytes + index);
^~~~~~~~~~~~~~
_mm_loadl_epi64
../fade.c:41:22: error: incompatible types when initializing type ‘__m128i’ {aka ‘__vector(2) long long int’} using type ‘int’
../fade.c:49:3: error: implicit declaration of function ‘_mm_storeu_si64’; did you mean ‘_mm_store_epi64’? [-Werror=implicit-function-declaration]
_mm_storeu_si64(dest_bytes + index, argb_vec);
^~~~~~~~~~~~~~~
_mm_store_epi64
cc1: all warnings being treated as errors
ninja: build stopped: subcommand failed.

swaylock-effects doesn't let the screen turn on until after unlocked

Expected behavior:

with swaylock, when the system is suspended by systemd the screen turns on after resuming and receiving some input and allows the user to see the lock screen before letting the user back into the system.

swaylock:

exec swayidle -w idlehint 10 \
          timeout 300 'swaymsg "output * dpms off"' \
          resume 'swaymsg "output * dpms on"' \
          before-sleep 'swaylock -efF -c 00000099 \
          --indicator-idle-visible --indicator-radius 75 \
          --indicator-thickness 15 --inside-clear-color FFFF00 \
          --ring-clear-color FFFF00'

Issue:

But with swaylock-effects, the system resumes from sleep and the screen won't come back on until after it is unlocked meaning the user can't see anything and has to type the password into a black screen and hope for the best.

Switching to a different TTY will turn on the screen but switching back will turn it off again.

The after-resume command is not needed with vanilla swaylock and it doesn't help with swaylock-effects

swaylock-effects:

exec swayidle -w idlehint 10 \
           timeout 300 'swaymsg "output * dpms off"' \
           resume 'swaymsg "output * dpms on"' \
           before-sleep 'swaylock --screenshots --clock \
           --indicator-radius 100 --grace 2 --fade-in 0.2 \
           --indicator-thickness 7 --effect-blur 7x5 \
           --effect-vignette 0.5:0.5 --ring-color bb00cc \
           --key-hl-color 880033 --line-color 00000000 \
           --inside-color 00000088 --separator-color 00000000'
          after-resume 'swaymsg "output * dpms on"'

effect-scale doesn't seem to do anything

As per title. effect-scale=2 or 200 or whatever seems to have no effect, at least from config file:

ignore-empty-password
font=Ubuntu

clock
timestr=%R
datestr=%a, %e of %B

screenshots

effect-blur=30x3
effect-greyscale
effect-scale=2

indicator
indicator-radius=240
indicator-thickness=20
indicator-caps-lock

key-hl-color=880033

separator-color=00000000

inside-color=00000088
inside-clear-color=ffd20400
inside-caps-lock-color=009ddc00
inside-ver-color=d9d8d800
inside-wrong-color=ee2e2400

ring-color=231f20D9
ring-clear-color=231f20D9
ring-caps-lock-color=231f20D9
ring-ver-color=231f20D9
ring-wrong-color=231f20D9

line-color=00000000
line-clear-color=ffd204FF
line-caps-lock-color=009ddcFF
line-ver-color=d9d8d8FF
line-wrong-color=ee2e24FF

text-clear-color=ffd20400
text-caps-lock-color=009ddc00
text-ver-color=d9d8d800
text-wrong-color=ee2e2400

bs-hl-color=ee2e24FF
caps-lock-key-hl-color=ffd204FF
caps-lock-bs-hl-color=ee2e24FF

Regression caused by "Fix dynamically adding and removing displays"

Ironically, eb2d931 is causing an issue with --screenshots combined with --effects-blur (I use -blur, I'm not sure if other effects are in scope too, but certainly --screenshots is important here).

I tested against upstream swaywm/swaylock to be sure and then bisected between v1.6-1 and v1.6-2. When I change displays while locked (since eb2d931) and I return to my seat, the static screen is still covered with a blurred screenshot, the "new" display just shows the raw screen. To be clear, not the original un-blurred screenshot, but whatever is live on the screen, a video for example. I quote "new" because in my situation I'm using a KVM so what's happening is that one screen is being disconnected and reconnected while the swaylock is running.

A secondary issue (or maybe primary depending on your perspective) is that there's no defense in depth here and an error is leading to my screen being completely visible while locked. Input is still blocked, but I'm not sure if that's because swaylock is deadlocked or not.

--screenshot flips colors

~ $ uname -a
Linux gentoo-laptop 5.4.72-gentoo #1 SMP Sun Oct 25 10:54:30 CET 2020 x86_64 Intel(R) Core(TM) i7-5500U CPU @ 2.40GHz GenuineIntel GNU/Linux
~ $ sway -v
sway version 1.5-32b93ef6 (Dec  1 2020, branch 'HEAD')
~ $ swaylock -v
swaylock version v1.6-3-4-g3aa6b4b (Nov 26 2020, branch 'HEAD')

wlroots is also built from master on 1 december.

Portrait screenshot rotated to landscape

In multi-display setup i have output DP-2 pos 2560 0 transform 270 (vertical/portrait display).
When locking the screen, it seems this setting is ignored and the blurred image is applied&stretched in the landscape mode.
Am i missing something or it's the "feature"? :)

Multihead - Main Monitor has white background instead of blurred desktop image on resume from DPMS off

When resuming from DPMS off on a multihead system, my secondary monitor displays the correct blurred background image for the lock screen, but my main monitor only displays a white background image behind it.

(A hint that this might be an upstream sway problem: windows on the main monitor reports being resized to a small value during sleep, while ones on the secondary monitor do not)

Sway v1.5,
swaylock-effects latest from AUR

Thanks for the help!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.