From: Stuart Morrow <morrow.stuart@gmail.com>
To: 9front@9front.org
Subject: [9front] rio-dependence of screenlock
Date: Tue, 19 Jan 2021 00:22:32 +0000 [thread overview]
Message-ID: <CABB-WO_=Y47ag=G-JBMV+wEW9-6DYo9kjeNFb=4sCWSADCSR_A@mail.gmail.com> (raw)
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);
next reply other threads:[~2021-01-19 0:50 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-19 0:22 Stuart Morrow [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CABB-WO_=Y47ag=G-JBMV+wEW9-6DYo9kjeNFb=4sCWSADCSR_A@mail.gmail.com' \
--to=morrow.stuart@gmail.com \
--cc=9front@9front.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).