9front - general discussion about 9front
 help / color / mirror / Atom feed
* [9front] rio-dependence of screenlock
@ 2021-01-19  0:22 Stuart Morrow
  2021-01-19  8:14 ` hiro
  2021-01-27  2:20 ` [9front] " ori
  0 siblings, 2 replies; 7+ messages in thread
From: Stuart Morrow @ 2021-01-19  0:22 UTC (permalink / raw)
  To: 9front

How screenlock works:

1. Get screen size
2. Create new Rio window with that size, ignore return value
3. for(;;) warp mouse to centre.

There are two ways to do 1.  From the shell, they are:

A%  file /dev/screen
B%  awk '{print $7"x"$8}' /dev/draw/new

Screenlock uses A. On the system console, you can in fact run
screenlock by binding any static image over stub(4)'s /dev/screen.
Recall that we don't check if we *actually got* a Rio window.

My patch uses B.  Runs on the system console just fine. In a nested
Rio, no different from current.  It also tops itself so that a popup's
right-click menu can't be used to delete it.  Popups aren't really the
style on Plan 9, but one can easily imagine a script that catches
kprints and tops a normally-hidden window.

I'll throw you a quid, whoever writes that.  I'd like to test that I know
how to use Bitcoin, which seems the best way to do bounties (everyone
can verify in blockchain.info, or in a local copy of the blockchain, that
the payment was made and received).  Or Bitcoin Cash if you insist on
something you can actually run on Plan 9.

diff -r 63eee0700f09 sys/src/cmd/screenlock.c
--- a/sys/src/cmd/screenlock.c	Sun Jan 17 14:02:17 2021 +0100
+++ b/sys/src/cmd/screenlock.c	Mon Jan 18 23:54:12 2021 +0000
@@ -17,6 +17,7 @@
 	exits("usage");
 }

+/* ^D, Delete, Enter, Backspace, ^U */
 void
 readline(char *buf, int nbuf)
 {
@@ -116,27 +117,38 @@
 }

 void
+top(void*)
+{
+	int fd;
+
+	if((fd = open("/dev/wctl", OWRITE)) < 0)
+		return;
+
+	for(;;){
+		write(fd, "current", 7);
+		sleep(500);
+	}
+}
+
+void
 lockscreen(void)
 {
-	enum { Nfld = 5, Fldlen = 12, Cursorlen = 2*4 + 2*2*16, };
+	enum { Cursorlen = 2*4 + 2*2*16 };
 	char *s;
-	char buf[Nfld*Fldlen], *flds[Nfld], newcmd[128], cbuf[Cursorlen];
+	char newcmd[128], cbuf[Cursorlen];
 	int fd, dx, dy;
 	Image *i;
 	Point p;
 	Rectangle r;
 	Tm *tm;

-	if((fd = open("/dev/screen", OREAD)) < 0)
-		sysfatal("can't open /dev/screen: %r");
-	if(read(fd, buf, Nfld*Fldlen) != Nfld*Fldlen)
-		sysfatal("can't read /dev/screen: %r");
-	close(fd);
-	buf[sizeof buf-1] = 0;
-	if(tokenize(buf, flds, Nfld) != Nfld)
-		sysfatal("can't tokenize /dev/screen header");
-	snprint(newcmd, sizeof newcmd, "-r %s %s %s %s",
-		flds[1], flds[2], flds[3], flds[4]);
+	display = initdisplay(nil, nil, nil);
+	if(display == nil)
+		sysfatal("can't open /dev/draw: %r");
+	r = display->image->r;
+	snprint(newcmd, sizeof newcmd, "-r %d %d %d %d",
+		r.min.x, r.min.y, r.max.x, r.max.y);
+	closedisplay(display);

 	newwindow(newcmd);
 	if((fd = open("/dev/consctl", OWRITE)) >= 0)
@@ -179,6 +191,7 @@
 	flushimage(display, 1);

 	/* screen is now open and covered.  grab mouse and hold on tight */
+	procrfork(top, nil, 8*1024, RFFDG);
 	procrfork(grabmouse, nil, 8*1024, RFFDG);
 	procrfork(blanker, nil, 8*1024, RFFDG);

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [9front] rio-dependence of screenlock
  2021-01-19  0:22 [9front] rio-dependence of screenlock Stuart Morrow
@ 2021-01-19  8:14 ` hiro
  2021-01-19 17:58   ` Stuart Morrow
  2021-01-19 20:01   ` ori
  2021-01-27  2:20 ` [9front] " ori
  1 sibling, 2 replies; 7+ messages in thread
From: hiro @ 2021-01-19  8:14 UTC (permalink / raw)
  To: 9front

> how to use Bitcoin, which seems the best way to do bounties

no.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [9front] rio-dependence of screenlock
  2021-01-19  8:14 ` hiro
@ 2021-01-19 17:58   ` Stuart Morrow
  2021-01-19 20:01   ` ori
  1 sibling, 0 replies; 7+ messages in thread
From: Stuart Morrow @ 2021-01-19 17:58 UTC (permalink / raw)
  To: 9front

On 19/01/2021, hiro <23hiro@gmail.com> wrote:
>> how to use Bitcoin, which seems the best way to do bounties
>
> no.

Bitcoin Cash it is, then.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [9front] rio-dependence of screenlock
  2021-01-19  8:14 ` hiro
  2021-01-19 17:58   ` Stuart Morrow
@ 2021-01-19 20:01   ` ori
  2021-01-19 20:27     ` Stuart Morrow
  1 sibling, 1 reply; 7+ messages in thread
From: ori @ 2021-01-19 20:01 UTC (permalink / raw)
  To: 9front

Quoth hiro <23hiro@gmail.com>:
> > how to use Bitcoin, which seems the best way to do bounties
> 
> no.
> 

Mutiny on the bounties?


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [9front] rio-dependence of screenlock
  2021-01-19 20:01   ` ori
@ 2021-01-19 20:27     ` Stuart Morrow
  2023-12-11 22:26       ` [9front] " magma698hfsp273p9f
  0 siblings, 1 reply; 7+ messages in thread
From: Stuart Morrow @ 2021-01-19 20:27 UTC (permalink / raw)
  To: 9front

> Mutiny on the bounties?

https://youtu.be/bGhR7tMDgxg?t=1860

Just leaving this here. Whole video is worth watching.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [9front] rio-dependence of screenlock
  2021-01-19  0:22 [9front] rio-dependence of screenlock Stuart Morrow
  2021-01-19  8:14 ` hiro
@ 2021-01-27  2:20 ` ori
  1 sibling, 0 replies; 7+ messages in thread
From: ori @ 2021-01-27  2:20 UTC (permalink / raw)
  To: 9front

Quoth Stuart Morrow <morrow.stuart@gmail.com>:
> How screenlock works:
> 
> 1. Get screen size
> 2. Create new Rio window with that size, ignore return value
> 3. for(;;) warp mouse to centre.
> 
> There are two ways to do 1.  From the shell, they are:
> 
> A%  file /dev/screen
> B%  awk '{print $7"x"$8}' /dev/draw/new
> 
> Screenlock uses A. On the system console, you can in fact run
> screenlock by binding any static image over stub(4)'s /dev/screen.
> Recall that we don't check if we *actually got* a Rio window.
> 
> My patch uses B.  Runs on the system console just fine. In a nested
> Rio, no different from current.  It also tops itself so that a popup's
> right-click menu can't be used to delete it.  Popups aren't really the
> style on Plan 9, but one can easily imagine a script that catches
> kprints and tops a normally-hidden window.
> 
> I'll throw you a quid, whoever writes that.  I'd like to test that I know
> how to use Bitcoin, which seems the best way to do bounties (everyone
> can verify in blockchain.info, or in a local copy of the blockchain, that
> the payment was made and received).  Or Bitcoin Cash if you insist on
> something you can actually run on Plan 9.
>

The patch seems reasonable to me.
 


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [9front] Re: rio-dependence of screenlock
  2021-01-19 20:27     ` Stuart Morrow
@ 2023-12-11 22:26       ` magma698hfsp273p9f
  0 siblings, 0 replies; 7+ messages in thread
From: magma698hfsp273p9f @ 2023-12-11 22:26 UTC (permalink / raw)
  To: 9front

Stuart Morrow <morrow.stuart@gmail.com> writes:

>> Mutiny on the bounties?
>
> https://youtu.be/bGhR7tMDgxg?t=1860
>
> Just leaving this here. Whole video is worth watching.

Just got around to watching this video.  Then found myself wondering
why.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-12-12 23:59 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-19  0:22 [9front] rio-dependence of screenlock Stuart Morrow
2021-01-19  8:14 ` hiro
2021-01-19 17:58   ` Stuart Morrow
2021-01-19 20:01   ` ori
2021-01-19 20:27     ` Stuart Morrow
2023-12-11 22:26       ` [9front] " magma698hfsp273p9f
2021-01-27  2:20 ` [9front] " ori

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).