You are not logged in.

#1 2016-11-16 02:51:55

madscience
Member
From: Ontario, Canada
Registered: 2014-02-11
Posts: 83
Website

[SOLVED]Screenshots are a blank black screen

Hey everyone,  I'm not sure if this is the best forum to post this in, and google has failed me.  I'm using i3lock to lock my workstation, and the following script:

/usr/local/bin/lockscreen

#!/bin/bash
scrot /tmp/screen.png
mogrify -blur 0x5 /tmp/screen.png
i3lock -n -u -i /tmp/screen.png
rm /tmp/screen.png

which, I swear, used to work fine.  It gives me a blurred version of my desktop as a lockscreen.  At some point, several months ago, it stopped working and now I just get a plain black screen.

At the time, I chalked it up to an update to either scrot, imagemagick, or i3lock, and ignored it until I had a chance to sit down and troubleshoot.  I took out the final line of the script, so it left behind /tmp/screen.png - a it's a plain black png.  I ran each command from a terminal, and it works fine.  The only two possibilities I can think of are a) it's locking the screen before scrot runs or b) there's an issue with permissions for scrot to grab the screen when run from a script.

I have tried running scrot as a regular user and as root (sudo) from the terminal, and it works.  I have also tried using import (from imagemagick) from the terminal instead of scrot, and it works.  This is only occurring when running from my script (which is in /usr/local/bin and chmod +x). I was using proprietary nvidia drivers, but have switched to nouveau and it's still occurring.


Can anyone point me in the right direction here?

Last edited by madscience (2016-11-17 21:49:28)

Offline

#2 2016-11-16 02:57:08

madscience
Member
From: Ontario, Canada
Registered: 2014-02-11
Posts: 83
Website

Re: [SOLVED]Screenshots are a blank black screen

so I just tested running xset s activate, and I get the issue.  However... if I run just the lockscreen script it works...

Offline

#3 2016-11-16 15:01:45

tate
Member
Registered: 2016-11-16
Posts: 1

Re: [SOLVED]Screenshots are a blank black screen

I've noticed that some time over the last month or so there has been an update that has caused the screencloud client to do the same thing. (produce black screenshots)
Perhaps this has something to do with Wayland? I don't have any ideas because I've just started troubleshooting it.

Offline

#4 2016-11-16 15:52:25

madscience
Member
From: Ontario, Canada
Registered: 2014-02-11
Posts: 83
Website

Re: [SOLVED]Screenshots are a blank black screen

I'm not running wayland, just good old xorg.  I am using

exec --no-startup-id xset s 300

and

exec --no-startup-id xss-lock -- lockscreen

in my i3 config.  I previously had those in my .xinitrc, and at one point I tried them in my .xprofile, but all with the same results.

Offline

#5 2016-11-17 15:58:06

seth
Member
Registered: 2012-09-03
Posts: 62,998

Re: [SOLVED]Screenshots are a blank black screen

Let's start with "wtf do you use scrot for this"? ;-)

convert x:root -blur 0x5 /tmp/screen.png

Do you use a compositor?
Try to "sleep 1" after each step.

Offline

#6 2016-11-17 21:20:06

madscience
Member
From: Ontario, Canada
Registered: 2014-02-11
Posts: 83
Website

Re: [SOLVED]Screenshots are a blank black screen

This is what I have now:

#!/bin/bash
#scrot /tmp/screen.png
#mogrify -blur 0x5 /tmp/screen.png
convert x:root -blur 0x5 /tmp/screen.png
i3lock -n -u -i /tmp/screen.png
rm /tmp/screen.png

... and it works, mostly.  I didn't need to use the sleep 1, although I did try it.  The only problem I can see is that convert isn't grabbing the wallpaper image, which may be due to the way feh is painting it to the root window.  Anyone have any thoughts on that?

Offline

#7 2016-11-17 21:48:27

madscience
Member
From: Ontario, Canada
Registered: 2014-02-11
Posts: 83
Website

Re: [SOLVED]Screenshots are a blank black screen

So, now I have this:

#!/bin/bash
scrot /tmp/screen.png
convert x:root -blur 0x5 /tmp/screen.png
i3lock -n -u -i /tmp/screen.png
rm /tmp/screen.png

which works, I assume, by scrotting the desktop, then capturing it again with convert and appending the data to the png, then blurring the whole thing.  It works, but it ain't pretty.  Oh well, [SOLVED] I guess.

Offline

#8 2016-11-17 21:52:41

seth
Member
Registered: 2012-09-03
Posts: 62,998

Re: [SOLVED]Screenshots are a blank black screen

Something is performing non-deterministic.
Your last script will scrot to /tmp/screen.png and then *override* the file with the convert result (which operates on an import of the root window)

I assume the reason is the way the script is invoked and sleeping briefly *before* scrot'ing OR convert'ing to drop a grab (from a shortcut handler?) might do?

Offline

#9 2016-11-17 22:02:32

madscience
Member
From: Ontario, Canada
Registered: 2014-02-11
Posts: 83
Website

Re: [SOLVED]Screenshots are a blank black screen

Alright, now it's really solved, but I'm not sure what is causing my issues.  I'm locking using xset and xss-lock to set the locker script.  I invoke the script using xset s activate.  With this script:

#!/bin/bash
sleep 1
convert x:root -blur 0x5 /tmp/screen.png
i3lock -n -u -i /tmp/screen.png
rm /tmp/screen.png

it's working perfectly, and grabbing the background as well as the windows. I'm not sure why the delay at the beginning is required and it triggers my OCD a little, but it now works.  BTW, I tested with my original script and added the sleep at the beginning, and it too works perfectly again.

Last edited by madscience (2016-11-17 22:03:37)

Offline

#10 2016-11-17 22:05:52

madscience
Member
From: Ontario, Canada
Registered: 2014-02-11
Posts: 83
Website

Re: [SOLVED]Screenshots are a blank black screen

seth wrote:

Let's start with "wtf do you use scrot for this"? ;-)

convert x:root -blur 0x5 /tmp/screen.png

Do you use a compositor?
Try to "sleep 1" after each step.

BTW, thanks for the convert tip, it's much more elegant.  And yes, I'm using compton for fancy drop shadows in my tiling environment ¯\_(ツ)_/¯

Offline

#11 2016-11-17 22:14:27

seth
Member
Registered: 2012-09-03
Posts: 62,998

Re: [SOLVED]Screenshots are a blank black screen

> I invoke the script using xset s activate
Like, you type it into some shell interpreter?
You may btw. get away with "sleep 0.25" (notably if this is caused by some key or mouse press and you need to release the button to release the server)

Offline

#12 2016-11-17 22:19:05

madscience
Member
From: Ontario, Canada
Registered: 2014-02-11
Posts: 83
Website

Re: [SOLVED]Screenshots are a blank black screen

seth wrote:

> I invoke the script using xset s activate
Like, you type it into some shell interpreter?
You may btw. get away with "sleep 0.25" (notably if this is caused by some key or mouse press and you need to release the button to release the server)

I'm using xset s 300 to lock it after 5 min, and also I have a key combo bound to xset s activate.  The same thing happened in both cases.  Lowering the sleep time to .25 still works as well.

Offline

Board footer

Powered by FluxBB