> 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