9front - general discussion about 9front
 help / color / mirror / Atom feed
* [9front] [PATCH] Allow Acme Battery to use ACPI
@ 2021-03-11 14:55 julien
  2021-04-02 15:41 ` Julien Blanchard
  2021-04-09  0:56 ` Noam Preil
  0 siblings, 2 replies; 3+ messages in thread
From: julien @ 2021-03-11 14:55 UTC (permalink / raw)
  To: 9front; +Cc: julien

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--

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

* Re: [9front] [PATCH] Allow Acme Battery to use ACPI
  2021-03-11 14:55 [9front] [PATCH] Allow Acme Battery to use ACPI julien
@ 2021-04-02 15:41 ` Julien Blanchard
  2021-04-09  0:56 ` Noam Preil
  1 sibling, 0 replies; 3+ messages in thread
From: Julien Blanchard @ 2021-04-02 15:41 UTC (permalink / raw)
  To: 9front


> Le 11 mars 2021 à 17:01, julien@typed-hole.org a écrit :
> 
> 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--

Hello I have this patch waiting eventually.

—
julienxx

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

* Re: [9front] [PATCH] Allow Acme Battery to use ACPI
  2021-03-11 14:55 [9front] [PATCH] Allow Acme Battery to use ACPI julien
  2021-04-02 15:41 ` Julien Blanchard
@ 2021-04-09  0:56 ` Noam Preil
  1 sibling, 0 replies; 3+ messages in thread
From: Noam Preil @ 2021-04-09  0:56 UTC (permalink / raw)
  To: 9front

The comparison is wrong - if acpifs is not mounted, but aml is, this will 
wrongly error out.

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

end of thread, other threads:[~2021-04-10 23:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-11 14:55 [9front] [PATCH] Allow Acme Battery to use ACPI julien
2021-04-02 15:41 ` Julien Blanchard
2021-04-09  0:56 ` Noam Preil

9front - general discussion about 9front

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://inbox.vuxu.org/9front

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 9front 9front/ http://inbox.vuxu.org/9front \
		9front@9front.org
	public-inbox-index 9front

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.9front


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git