9front - general discussion about 9front
 help / color / mirror / Atom feed
From: julien@typed-hole.org
To: 9front@9front.org
Cc: julien@typed-hole.org
Subject: [9front] [PATCH] Allow Acme Battery to use ACPI
Date: Thu, 11 Mar 2021 15:55:45 +0100	[thread overview]
Message-ID: <6A2C69B172AD0333000D35A4618F8FFF@typed-hole.org> (raw)

This is a multi-part message in MIME format.
--upas-tagxexdttctmbtbirbrxngwnxy
Content-Disposition: inline
Content-Type: text/plain; charset="US-ASCII"
Content-Transfer-Encoding: 7bit

Hello,
I stubbled upon the content of /acme/bin and noticed this Battery script. It uses /mnt/apm. This patch allows it to use apm or acpi.
Hope my rc scripting is not too bad.
Cheers,
Julien


--upas-tagxexdttctmbtbirbrxngwnxy
Content-Disposition: attachment; filename=acme_battery.patch
Content-Type: text/plain; charset="US-ASCII"
Content-Transfer-Encoding: 7bit

diff -r 55df775635f0 acme/bin/Battery
--- a/acme/bin/Battery	Wed Mar 10 16:49:17 2021 -0800
+++ b/acme/bin/Battery	Thu Mar 11 15:27:40 2021 +0100
@@ -1,25 +1,37 @@
 #!/bin/rc
 
-if(! test -f /mnt/apm/battery){
-	echo no apm >[1=2]
-	exit 'no apm'
+pm=()
+
+if(test -f /mnt/apm/battery) pm = apm
+if(test -f /mnt/acpi/battery) pm = acpi
+if not {
+	echo no apm or acpi >[1=2]
+	exit 'no apm or acpi'
 }
 
 cd /mnt/acme/new
-echo name /dev/apm >ctl
+echo name /dev/^$pm >ctl
 echo dump Battery >ctl
 
-awkscript='
-NR==1 {
-	if($3 != -1)
-		printf("%d%% %d:%02d %s", $2, $3/3600, ($3/60)%60, $1);
-	else
-		printf("%d%% %s", $2, $1);
+if(~ $pm apm){
+	awkscript='
+	NR==1 {
+		if($3 != -1)
+			printf("%d%% %d:%02d %s", $2, $3/3600, ($3/60)%60, $1);
+		else
+			printf("%d%% %s", $2, $1);
+	}'
 }
-'
+
+if(~ $pm acpi){
+	awkscript='
+	NR==1 {
+		printf("%d%% %s", $1, $11);
+	}'
+}
 
 fn chk {
-	what=`{awk $awkscript /mnt/apm/battery}
+	what=`{awk $awkscript /mnt/^$pm/battery}
 	echo cleartag >ctl || exit die
 	echo clean >ctl || exit die
 	echo ' '^$"what >tag || exit die
--upas-tagxexdttctmbtbirbrxngwnxy--

             reply	other threads:[~2021-03-11 16:02 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-11 14:55 julien [this message]
2021-04-02 15:41 ` Julien Blanchard
2021-04-09  0:56 ` Noam Preil

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=6A2C69B172AD0333000D35A4618F8FFF@typed-hole.org \
    --to=julien@typed-hole.org \
    --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).