From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 24775 invoked from network); 18 Jul 2021 19:37:15 -0000 Received: from 1ess.inri.net (216.126.196.35) by inbox.vuxu.org with ESMTPUTF8; 18 Jul 2021 19:37:15 -0000 Received: from mail-ed1-f47.google.com ([209.85.208.47]) by 1ess; Sun Jul 18 15:32:04 -0400 2021 Received: by mail-ed1-f47.google.com with SMTP id k27so20655682edk.9 for <9front@9front.org>; Sun, 18 Jul 2021 12:31:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=HC9Vg0QQVsZS3K3Mxz9b9YXlc12NAYgLuIH56C08E5k=; b=bcnQgqWixWZ9LhaKB4XP9McGrVdyvqnqv/qWF5qwDGgaltKXm+GDVBoqHD4nKjpqfC 1XiL4Eb3fBvQaJyDXhMmj1YJMabI9qg9r1K5Zvbb8vzHfEbVbe9o7mTJQTiQB+JOVasn UOiASYFNwTyoFfkEENJ3l+1Sf6P/fVyodtccHDPbyTwEB8j5FTVLvGiZ5O7Ht0HBAh3m qA5LGBnVZh5a1pQv5rL58/1zZ621NjmmgZKeBkiInEEonNys8syMTmrBbAE/TcTA+9jr 30483BdkyJs4VVIZgKi3GMUGIYPY6qHAhjwTp6fX080/0aVTe/QVi0YCSqjka0DcGOM5 Rvpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=HC9Vg0QQVsZS3K3Mxz9b9YXlc12NAYgLuIH56C08E5k=; b=BIoPV7Vb6pCxFCpWSMW3DWJptDoiTq1fKAApzpjDgjOv4ubI94Dh43KTGs228ne3lU Ldq3qu1gVCyVr4g54dljyCqGhpMGjWnsiGEpqUoHNDORw0ofv8hop53HqBOxIRzZXS2X 1hFkMRFpVZL+EEA1Ey9EJXDfc3YyYa+xjA30qp6t8tn4Qe51cKA/CWJulxEmH3WiMnfr xRF6JgW1y6yIuPcnKuOYHnqpSDWhXpEfwyqPxEV28a+YoGhDXrY493gcnTlUT/EZzFbx JIZyKKt9PsKnZfhVktv+Yhaw5sHWQIDXcK07jX0btkUf2TzCgnaeuuGRWqKCo7A2PCAC WQTg== X-Gm-Message-State: AOAM532nMvTHcV1KMd0H+HMF6Vr8PTlMKCg0MZSmW8MGZqC4BbUxycDk Ee4FtuAm248HBhmqa6i9LE/SMhjGducSAhgow9abZ9nyDr4= X-Google-Smtp-Source: ABdhPJwWsaTgArqpTn6WQmY5ZqKkamDsOFDeyIzecbpk5Mlma9qyHnrUiu1NlxEUDNXza4CXE8hR9BCLENO0K0KpZnE= X-Received: by 2002:a05:6402:1242:: with SMTP id l2mr29783748edw.97.1626636713186; Sun, 18 Jul 2021 12:31:53 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a17:906:76c8:b029:4d9:7711:78cc with HTTP; Sun, 18 Jul 2021 12:31:52 -0700 (PDT) In-Reply-To: References: From: Stuart Morrow Date: Sun, 18 Jul 2021 20:31:52 +0100 Message-ID: To: 9front@9front.org Content-Type: text/plain; charset="UTF-8" List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: scale-out CSS wrapper-aware SQL over XML scripting general-purpose-based controller Subject: Re: [9front] screenlock Reply-To: 9front@9front.org Precedence: bulk > thats wrong because the read wont return you a '\0' terminated string. Oh, yeah. And I can even come up with a scenario where wctl will emit without there being a notcurrent. --- /mnt/git/object/be36c092ac061a04065720e98e5849130487be7f/tree/sys/src/cmd/screenlock.c +++ sys/src/cmd/screenlock.c @@ -119,14 +119,19 @@ void top(void*) { - int fd; + int fd, n; + char buf[128]; - if((fd = open("/dev/wctl", OWRITE)) < 0) + if((fd = open("/dev/wctl", ORDWR)) < 0) return; for(;;){ - write(fd, "current", 7); - sleep(500); + n = read(fd, buf, sizeof buf-1); + if(n > 48){ + buf[n] = '\0'; + if(strstr(buf+48, "notcurrent")) + write(fd, "current", 7); + } } } @@ -186,7 +191,7 @@ tm = localtime(time(&blank)); s = smprint("user %s at %d:%02.2d", getuser(), tm->hour, tm->min); p = subpt(p, Pt(stringwidth(font, "m") * strlen(s) / 2, 0)); - string(screen, p, screen->display->white, ZP, font, s); + stringbg(screen, p, display->white, ZP, font, s, display->black, ZP); }