ref: 43633bf3a33c43021b9cfeed3bd33be5f99f6094
parent: 3ebe52854b302dc63c3b07472b0e6a2e7e2a1555
	author: cinap_lenrek <cinap_lenrek@felloff.net>
	date: Fri Dec  1 18:13:01 EST 2017
	
screenlock: blank screen using /dev/mousectl (thanks sl)
--- a/sys/src/cmd/screenlock.c
+++ b/sys/src/cmd/screenlock.c
@@ -8,7 +8,6 @@
char pic[] = "/lib/bunny.bit";
-int vgactl;
int debug;
int doblank;
int chatty = 0;
@@ -16,16 +15,6 @@
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
error(char *fmt, ...)
 {Fmt f;
@@ -122,7 +111,6 @@
fprint(2, "%s's screenlock password: ", user);
memset(buf, 0, sizeof buf);
readline(buf, sizeof buf);
- blankscreen(0);
if(chatty || !must)
fprint(2, "\n");
 		if(buf[0] == '\0' || buf[0] == '\04'){@@ -142,14 +130,16 @@
doblank = 1;
}
memset(buf, 0, sizeof buf);
- blankscreen(0);
}
void
blanker(void *)
 {- int tics;
+ int fd, tics;
+	fd = open("/dev/mousectl", OWRITE);+ if(fd < 0)
+ return;
tics = 0;
 	for(;;){ 		if(doblank > 0){@@ -157,7 +147,7 @@
tics = 10;
}
if(tics > 0 && --tics == 0)
- blankscreen(1);
+ write(fd, "blank", 5);
sleep(1000);
}
}
@@ -268,10 +258,6 @@
threadmain(int argc, char *argv[])
 { 	readfile("#c/user", user, sizeof user, 1);-
-	if((vgactl = open("/dev/vgactl", OWRITE)) < 0)-		vgactl = open("#v/vgactl", OWRITE);-
 	ARGBEGIN{case 'd':
debug++;
--
⑨