From owner-svn-src-all@freebsd.org Sat Dec 21 12:15:10 2019 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id AEF781D2B56; Sat, 21 Dec 2019 12:15:10 +0000 (UTC) (envelope-from ronald-lists@klop.ws) Received: from smarthost1.greenhost.nl (smarthost1.greenhost.nl [195.190.28.88]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 47g4Lj05K3z4Cv9; Sat, 21 Dec 2019 12:15:08 +0000 (UTC) (envelope-from ronald-lists@klop.ws) Received: from smtp.greenhost.nl ([213.108.110.112]) by smarthost1.greenhost.nl with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1iidez-0007xN-44; Sat, 21 Dec 2019 13:15:05 +0100 Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org, "Philip Paeps" Subject: Re: svn commit: r355978 - head/usr.bin/top References: <201912210503.xBL53LCh072168@repo.freebsd.org> Date: Sat, 21 Dec 2019 13:15:08 +0100 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: "Ronald Klop" Message-ID: In-Reply-To: <201912210503.xBL53LCh072168@repo.freebsd.org> User-Agent: Opera Mail/12.16 (FreeBSD) X-Authenticated-As-Hash: 398f5522cb258ce43cb679602f8cfe8b62a256d1 X-Virus-Scanned: by clamav at smarthost1.samage.net X-Spam-Level: / X-Spam-Score: -0.2 X-Spam-Status: No, score=-0.2 required=5.0 tests=ALL_TRUSTED, BAYES_50 autolearn=disabled version=3.4.2 X-Scan-Signature: 3cea6f85c46863b7448b52c7b19d39b8 X-Rspamd-Queue-Id: 47g4Lj05K3z4Cv9 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of ronald-lists@klop.ws designates 195.190.28.88 as permitted sender) smtp.mailfrom=ronald-lists@klop.ws X-Spamd-Result: default: False [-2.54 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; R_SPF_ALLOW(-0.20)[+ip4:195.190.28.64/27]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(0.00)[klop.ws]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; TO_DN_SOME(0.00)[]; IP_SCORE(-0.75)[ip: (-0.84), ipnet: 195.190.28.0/24(-0.31), asn: 47172(-2.62), country: NL(0.03)]; RCVD_IN_DNSWL_NONE(0.00)[88.28.190.195.list.dnswl.org : 127.0.10.0]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MID_RHS_NOT_FQDN(0.50)[]; ASN(0.00)[asn:47172, ipnet:195.190.28.0/24, country:NL]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 Dec 2019 12:15:10 -0000 nice addition On Sat, 21 Dec 2019 06:03:21 +0100, Philip Paeps wrote: > Author: philip > Date: Sat Dec 21 05:03:21 2019 > New Revision: 355978 > URL: https://svnweb.freebsd.org/changeset/base/355978 > > Log: > top: display battery capacity remaining > Submitted by: Antranig Vartanian > Reviewed by: imp, philip > Differential Revision: https://reviews.freebsd.org/D22871 > > Modified: > head/usr.bin/top/display.c > head/usr.bin/top/display.h > head/usr.bin/top/machine.c > head/usr.bin/top/machine.h > head/usr.bin/top/top.c > > Modified: head/usr.bin/top/display.c > ============================================================================== > --- head/usr.bin/top/display.c Sat Dec 21 04:44:17 2019 (r355977) > +++ head/usr.bin/top/display.c Sat Dec 21 05:03:21 2019 (r355978) > @@ -1322,6 +1322,15 @@ i_uptime(struct timeval *bt, time_t *tod) > } > } > +void > +i_battery(int nbat, int batt) > +{ > + > + if (nbat > 0) { > + printf("; battery: %d%%", batt); > + } > +} > + > #define SETUPBUFFER_MIN_SCREENWIDTH 80 > #define SETUPBUFFER_REQUIRED_ADDBUFSIZ 2 > > Modified: head/usr.bin/top/display.h > ============================================================================== > --- head/usr.bin/top/display.h Sat Dec 21 04:44:17 2019 (r355977) > +++ head/usr.bin/top/display.h Sat Dec 21 05:03:21 2019 (r355978) > @@ -14,6 +14,7 @@ void i_header(const char *text); > void display_header(int t); > int display_init(struct statics *statics); > void i_arc(int *stats); > +void i_battery(int nbat, int batt); > void i_carc(int *stats); > void i_cpustates(int *states); > void i_loadave(int mpid, double *avenrun); > > Modified: head/usr.bin/top/machine.c > ============================================================================== > --- head/usr.bin/top/machine.c Sat Dec 21 04:44:17 2019 (r355977) > +++ head/usr.bin/top/machine.c Sat Dec 21 05:03:21 2019 (r355978) > @@ -211,6 +211,10 @@ static long *pcpu_cp_old; > static long *pcpu_cp_diff; > static int *pcpu_cpu_states; > +/* Battery units and states */ > +static int battery_units; > +static int battery_life; > + > static int compare_swap(const void *a, const void *b); > static int compare_jid(const void *a, const void *b); > static int compare_pid(const void *a, const void *b); > @@ -373,6 +377,12 @@ machine_init(struct statics *statics) > pcpu_cpu_states = calloc(ncpus * CPUSTATES, sizeof(int)); > statics->ncpus = ncpus; > + /* Allocate state of battery units reported via ACPI. */ > + battery_units = 0; > + size = sizeof(int); > + sysctlbyname("hw.acpi.battery.units", &battery_units, &size, NULL, 0); > + statics->nbatteries = battery_units; > + > update_layout(); > /* all done! */ > @@ -579,6 +589,12 @@ get_system_info(struct system_info *si) > } else { > si->boottime.tv_sec = -1; > } > + > + battery_life = 0; > + if (battery_units > 0) { > + GETSYSCTL("hw.acpi.battery.life", battery_life); > + } > + si->battery = battery_life; > } > #define NOPROC ((void *)-1) > > Modified: head/usr.bin/top/machine.h > ============================================================================== > --- head/usr.bin/top/machine.h Sat Dec 21 04:44:17 2019 (r355977) > +++ head/usr.bin/top/machine.h Sat Dec 21 05:03:21 2019 (r355978) > @@ -30,6 +30,7 @@ struct statics > const char * const *carc_names; > const char * const *swap_names; > const char * const *order_names; > + int nbatteries; > int ncpus; > }; > @@ -50,6 +51,7 @@ struct system_info > int *carc; > int *swap; > struct timeval boottime; > + int battery; > int ncpus; > }; > > Modified: head/usr.bin/top/top.c > ============================================================================== > --- head/usr.bin/top/top.c Sat Dec 21 04:44:17 2019 (r355977) > +++ head/usr.bin/top/top.c Sat Dec 21 05:03:21 2019 (r355978) > @@ -619,6 +619,9 @@ restart: > (*d_loadave)(system_info.last_pid, > system_info.load_avg); > + /* display the battery info (if any) */ > + i_battery(statics.nbatteries, system_info.battery); > + > /* display the current time */ > /* this method of getting the time SHOULD be fairly portable */ > time(&curr_time); > _______________________________________________ > svn-src-all@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/svn-src-all > To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"