Date: Wed, 09 Dec 2009 01:25:43 +0900 From: Hajimu UMEMOTO <ume@freebsd.org> To: Taku YAMAMOTO <taku@tackymt.homeip.net> Cc: freebsd-acpi@freebsd.org Subject: Re: ACPI temperature Message-ID: <ygemy1th1q0.wl%ume@mahoroba.org> In-Reply-To: <20091208041000.1d2f75f8.taku@tackymt.homeip.net> References: <200912042337.04403.freebsd@insightbb.com> <20091208041000.1d2f75f8.taku@tackymt.homeip.net>
index | next in thread | previous in thread | raw e-mail
[-- Attachment #1 --]
Hi,
>>>>> On Tue, 8 Dec 2009 04:10:00 +0900
>>>>> Taku YAMAMOTO <taku@tackymt.homeip.net> 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,
[-- Attachment #2 --]
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 <string.h>
#include <unistd.h>
+#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
[-- Attachment #3 --]
--
Hajimu UMEMOTO @ Internet Mutual Aid Society Yokohama, Japan
ume@mahoroba.org ume@{,jp.}FreeBSD.org
http://www.imasy.org/~ume/
help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?ygemy1th1q0.wl%ume>
