nwg-piotr / nwg-wrapper

Wrapper to display a script output or a text file content on the desktop in sway or other wlroots-based compositors
MIT License
139 stars 8 forks source link

Display on top of swaylock? #5

Closed bhepple closed 2 years ago

bhepple commented 2 years ago

I use swaylock to display a random image while locked:

swaylock --daemonize --image "$IMAGE" &

Is there any way to have nwg-wrapper display some text 'on top of' that image. I tried --layer=2 but it does not display (until I unlock!).

nwg-piotr commented 2 years ago

The -l 3 argument seems to display the wrapper content over swaylock. I'm not sure ATM how switching layers with a signal is going to behave.

bhepple commented 2 years ago

You're right! Thanks for that and BTW thanks for all your sway/wl-roots contributions!!

nwg-piotr commented 2 years ago

You're welcome! Thanks for featuring them on your and sway Wiki.

bhepple commented 2 years ago

I spoke too soon! It seems that the very first time an image is used with swaylock, nwg-wrapper is able to display on top of it. Subsequent runs (using the same image) are not able - although when swaylock terminates (on password entry) the nwg-wrapper window is visible. The effect is preserved even after the sway session is exited and restarted. Each image can be displayed exactly once before nwg-wrapper fails!!! Quite weird.

swaylock --image '/home/bhepple/media/backgrounds/Evening at Bilbos-X3.jpg' & 
nwg-wrapper -s timezones.sh -r 10000 -c timezones.css -p right -mr 50 -a start -mt 50 -j right --layer 3
bhepple commented 2 years ago

BTW - hitting a running nwg-wrapper with USR1 or USR2 signals does not fix things, nor does using a different offset eg -mr 100 instead of 50. Nor does alternating 2 different images; nor does running swaylock without an image.

Rebooting resets the counter so that nwg-wrapper succeeds for a previously used image - but for only one time.

nwg-piotr commented 2 years ago

Inverted command order and sleep 1 && seem to help here:

#!/usr/bin/env bash

nwg-wrapper -s timezones.sh -r 10000 -c swaylock-time.css -p right -mr 50 -a start -mt 50 -j right --layer 3 &
sleep 1 && swaylock --image /home/piotr/Obrazy/Wallpapers/wallhaven-kwxjl6-1920x1080.jpg && pkill -f -2 nwg-wrapper

Don't use the --daemonize argument. If you need the wrapper content on the lock screen only, you'll probably want to kill it later. Use SIGINT (2) or SIGTERM (15) for it to terminate safely.

lockscreen1

bhepple commented 2 years ago

That worked! although I need 2s sleep to be reliable. Maybe my system is slow (10yo laptop). Thank you again!!

EDIT no, I'm wrong again - I was slowing nwg-wrapper by having a curl in the script. Removed that and sleep 0.5 was enough

nwg-piotr commented 2 years ago

Tomorrow, when I'm bored enough at the office, I'll check it out on my old, testing laptop. For now only tested on my main machine and dwl compositor. I'm glad that it works for you.

nwg-piotr commented 2 years ago

One more thing: killing the process with signal 2 or 15 terminates all the wrapper instances. I think we need one more argument, like -sq | --sig_quit to choose a custom signal for a certain instance.

10b14224cc commented 7 months ago

I can't get it to work.

I have:

#!/usr/bin/env bash
nwg-wrapper --script $(pwd)/mydate.sh --css "$(pwd)/mydate.css" --layer 3 --refresh 500 --alignment start 1>/dev/null 2>&1 &
sleep 2 && swaylock && pkill -f -2 nwg-wrapper

but swaylock keeps overlaying nwg-wrapper :(

10b14224cc commented 7 months ago

I found this here:

Swaylock used to be rendered on the same layer (overlay), which is why your results depend on the surface creation order. Nowadays (sway 1.8) it uses ext-session-lock-v1 protocol and it's no longer possible to draw anything above the lockscreen at all.

bhepple commented 7 months ago

I gave up on nwg-wrapper for use on the lockscreen (although I still use it on normal sway sessions to overlay help information eg in resize or move modes).

Instead I wrote some add-on modules for gtklock that provide the same information. It's all documented at https://github.com/jovanlanik/gtklock including the wiki there.

10b14224cc commented 7 months ago

I gave up on nwg-wrapper for use on the lockscreen (although I still use it on normal sway sessions to overlay help information eg in resize or move modes).

Instead I wrote some add-on modules for gtklock that provide the same information. It's all documented at https://github.com/jovanlanik/gtklock including the wiki there.

It looks like gtklock is based on wlr-layer-shell and wlr-input-inhibitor instead of ext-session-lock, thus is more insecure.