From owner-freebsd-acpi@FreeBSD.ORG Tue Dec 8 16:25:55 2009 Return-Path: Delivered-To: freebsd-acpi@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6DD741065676 for ; Tue, 8 Dec 2009 16:25:55 +0000 (UTC) (envelope-from ume@mahoroba.org) Received: from asuka.mahoroba.org (ent.mahoroba.org [IPv6:2001:2f0:104:8010::1]) by mx1.freebsd.org (Postfix) with ESMTP id 70A6F8FC2A for ; Tue, 8 Dec 2009 16:25:54 +0000 (UTC) Received: from yuga.mahoroba.org (ume@yuga.mahoroba.org [IPv6:2001:2f0:104:8010:21b:d3ff:fe38:5381]) (user=ume mech=CRAM-MD5 bits=0) by asuka.mahoroba.org (8.14.3/8.14.3) with ESMTP/inet6 id nB8GPhK9020339 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 9 Dec 2009 01:25:49 +0900 (JST) (envelope-from ume@mahoroba.org) Date: Wed, 09 Dec 2009 01:25:43 +0900 Message-ID: From: Hajimu UMEMOTO To: Taku YAMAMOTO In-Reply-To: <20091208041000.1d2f75f8.taku@tackymt.homeip.net> References: <200912042337.04403.freebsd@insightbb.com> <20091208041000.1d2f75f8.taku@tackymt.homeip.net> User-Agent: xcite1.58> Wanderlust/2.15.7 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?ISO-2022-JP-2?B?R29qGyQoRCtXGyhC?=) APEL/10.7 Emacs/23.1 (i386-portbld-freebsd8.0) MULE/6.0 (HANACHIRUSATO) X-Operating-System: FreeBSD 8.0-STABLE X-PGP-Key: http://www.imasy.or.jp/~ume/publickey.asc X-PGP-Fingerprint: 1F00 0B9E 2164 70FC 6DC5 BF5F 04E9 F086 BF90 71FE Organization: Internet Mutual Aid Society, YOKOHAMA MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: multipart/mixed; boundary="Multipart_Wed_Dec__9_01:25:43_2009-1" X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.3 (asuka.mahoroba.org [IPv6:2001:2f0:104:8010::1]); Wed, 09 Dec 2009 01:25:49 +0900 (JST) X-Virus-Scanned: clamav-milter 0.95.3 at asuka.mahoroba.org X-Virus-Status: Clean X-Spam-Status: No, score=-2.6 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on asuka.mahoroba.org Cc: freebsd-acpi@freebsd.org Subject: Re: ACPI temperature X-BeenThere: freebsd-acpi@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: ACPI and power management development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Dec 2009 16:25:55 -0000 --Multipart_Wed_Dec__9_01:25:43_2009-1 Content-Type: text/plain; charset=US-ASCII Hi, >>>>> On Tue, 8 Dec 2009 04:10:00 +0900 >>>>> Taku YAMAMOTO said: taku> # I think it is very convenient to have a knob (or better, honors LANG) to taku> # let sysctl show "IK" oids in Fahrenheit. Yup, I thought similar thing before. How about this patch? Sincerely, --Multipart_Wed_Dec__9_01:25:43_2009-1 Content-Type: text/x-patch; type=patch; charset=US-ASCII Content-Disposition: attachment; filename="sysctl.c-fahrenheit.diff" Content-Transfer-Encoding: 7bit Index: sbin/sysctl/sysctl.8 diff -u sbin/sysctl/sysctl.8.orig sbin/sysctl/sysctl.8 --- sbin/sysctl/sysctl.8.orig 2009-08-03 17:13:06.000000000 +0900 +++ sbin/sysctl/sysctl.8 2009-12-09 01:11:18.928540783 +0900 @@ -36,11 +36,11 @@ .Nd get or set kernel state .Sh SYNOPSIS .Nm -.Op Fl bdehNnoqx +.Op Fl bcdefhkNnoqx .Ar name Ns Op = Ns Ar value .Ar ... .Nm -.Op Fl bdehNnoqx +.Op Fl bcdefhkNnoqx .Fl a .Sh DESCRIPTION The @@ -67,6 +67,13 @@ Force the value of the variable(s) to be output in raw, binary format. No names are printed and no terminating newlines are output. This is mostly useful with a single variable. +.It Fl c +Show temperature in Celsius. +This is default when neither +.Fl f +nor +.Fl k +is specified. .It Fl d Print the description of the variable instead of its value. .It Fl e @@ -80,8 +87,13 @@ or .Fl n is specified, or a variable is being set. +.It Fl f +Show temperature in Fahrenheit. .It Fl h Format output for human, rather than machine, readability. +.It Fl k +Show temperature in Kelvin. +The value is decupled. .It Fl N Show only variable names, not their values. This is particularly useful with shells that offer programmable Index: sbin/sysctl/sysctl.c diff -u -p sbin/sysctl/sysctl.c.orig sbin/sysctl/sysctl.c --- sbin/sysctl/sysctl.c.orig 2009-08-03 17:13:06.000000000 +0900 +++ sbin/sysctl/sysctl.c 2009-12-09 00:56:01.513715033 +0900 @@ -58,6 +58,11 @@ static const char rcsid[] = #include #include +#define IK_CELSIUS 0 +#define IK_FAHRENHEIT 1 +#define IK_KELVIN 2 +static int ik_unit = IK_CELSIUS; + static int aflag, bflag, dflag, eflag, hflag, Nflag, nflag, oflag; static int qflag, xflag, warncount; @@ -89,7 +94,7 @@ main(int argc, char **argv) setbuf(stdout,0); setbuf(stderr,0); - while ((ch = getopt(argc, argv, "AabdehNnoqwxX")) != -1) { + while ((ch = getopt(argc, argv, "AabcdefhkNnoqwxX")) != -1) { switch (ch) { case 'A': /* compatibility */ @@ -101,15 +106,24 @@ main(int argc, char **argv) case 'b': bflag = 1; break; + case 'c': + ik_unit = IK_CELSIUS; + break; case 'd': dflag = 1; break; case 'e': eflag = 1; break; + case 'f': + ik_unit = IK_FAHRENHEIT; + break; case 'h': hflag = 1; break; + case 'k': + ik_unit = IK_KELVIN; + break; case 'N': Nflag = 1; break; @@ -650,8 +664,11 @@ show_var(int *oid, int nlen) else if (fmt[1] == 'X') printf("%#0*jx", hexlen, umv); else if (fmt[1] == 'K') { - if (mv < 0) + if (mv < 0 || ik_unit == IK_KELVIN) printf("%jd", mv); + else if (ik_unit == IK_FAHRENHEIT) + printf("%.1fF", + (mv - 2732.0) * 9 / 50 + 32.0); else printf("%.1fC", (mv - 2732.0) / 10); } else --Multipart_Wed_Dec__9_01:25:43_2009-1 Content-Type: text/plain; charset=US-ASCII -- Hajimu UMEMOTO @ Internet Mutual Aid Society Yokohama, Japan ume@mahoroba.org ume@{,jp.}FreeBSD.org http://www.imasy.org/~ume/ --Multipart_Wed_Dec__9_01:25:43_2009-1--