screenlock: blank screen using /dev/mousectl (thanks sl)

This commit is contained in:
cinap_lenrek 2017-12-01 23:13:01 +01:00
parent f03260bf25
commit 2bf642de9d

View file

@ -8,23 +8,12 @@
char pic[] = "/lib/bunny.bit"; char pic[] = "/lib/bunny.bit";
int vgactl;
int debug; int debug;
int doblank; int doblank;
int chatty = 0; int chatty = 0;
char user[256]; char user[256];
void
blankscreen(int blank)
{
if(vgactl < 0)
return;
seek(vgactl, 0, 0);
if(fprint(vgactl, blank? "blank": "unblank") < 0)
fprint(2, "blankscreen: can't blank: %r\n");
}
void void
error(char *fmt, ...) error(char *fmt, ...)
{ {
@ -122,7 +111,6 @@ checkpassword(void)
fprint(2, "%s's screenlock password: ", user); fprint(2, "%s's screenlock password: ", user);
memset(buf, 0, sizeof buf); memset(buf, 0, sizeof buf);
readline(buf, sizeof buf); readline(buf, sizeof buf);
blankscreen(0);
if(chatty || !must) if(chatty || !must)
fprint(2, "\n"); fprint(2, "\n");
if(buf[0] == '\0' || buf[0] == '\04'){ if(buf[0] == '\0' || buf[0] == '\04'){
@ -142,14 +130,16 @@ checkpassword(void)
doblank = 1; doblank = 1;
} }
memset(buf, 0, sizeof buf); memset(buf, 0, sizeof buf);
blankscreen(0);
} }
void void
blanker(void *) blanker(void *)
{ {
int tics; int fd, tics;
fd = open("/dev/mousectl", OWRITE);
if(fd < 0)
return;
tics = 0; tics = 0;
for(;;){ for(;;){
if(doblank > 0){ if(doblank > 0){
@ -157,7 +147,7 @@ blanker(void *)
tics = 10; tics = 10;
} }
if(tics > 0 && --tics == 0) if(tics > 0 && --tics == 0)
blankscreen(1); write(fd, "blank", 5);
sleep(1000); sleep(1000);
} }
} }
@ -268,10 +258,6 @@ void
threadmain(int argc, char *argv[]) threadmain(int argc, char *argv[])
{ {
readfile("#c/user", user, sizeof user, 1); readfile("#c/user", user, sizeof user, 1);
if((vgactl = open("/dev/vgactl", OWRITE)) < 0)
vgactl = open("#v/vgactl", OWRITE);
ARGBEGIN{ ARGBEGIN{
case 'd': case 'd':
debug++; debug++;