From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] battery.el, upower fixes Date: Mon, 27 Jan 2020 09:43:32 -0500 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="92791"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: emacs-devel To: Evgeny Zajcev Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Jan 27 15:48:04 2020 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1iw5gK-000O6d-3Z for ged-emacs-devel@m.gmane-mx.org; Mon, 27 Jan 2020 15:48:04 +0100 Original-Received: from localhost ([::1]:46380 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iw5gJ-0002su-4c for ged-emacs-devel@m.gmane-mx.org; Mon, 27 Jan 2020 09:48:03 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:37956) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iw5cA-0005RV-AY for emacs-devel@gnu.org; Mon, 27 Jan 2020 09:43:47 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iw5c8-0004n4-DH for emacs-devel@gnu.org; Mon, 27 Jan 2020 09:43:45 -0500 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:26641) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iw5c8-0004lr-4w for emacs-devel@gnu.org; Mon, 27 Jan 2020 09:43:44 -0500 Original-Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 15A14101347; Mon, 27 Jan 2020 09:43:43 -0500 (EST) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 0357B10028B; Mon, 27 Jan 2020 09:43:40 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1580136220; bh=4+YUBD8fqT0FFdu0ixB+LGTOtFU/v028GxihTgoICpI=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=eT+oXQLBTp91Oa8P3EhRB7w5PUB9q+3aW7hTU5rzdY7RRgPIU2th5wA4tQQnqXDgF Ml1Fgi+Fqxvw9AARzcon5rAhbGkDwpjvD9Rw4DLZcBXq3WTwOIDkpzvzMSSZHx/3Fa 9uNja6rUy0PRWzrIeO9W/VlS7pAj6FvE+QWH+jd3qCxoqRYYk+74+7wsHHmRs5CQVa aBbERJarBdqUc+G6YnnRP0MAUpwggShNxq+Qsavazg0xVzDuFQypSDtE/EgUDfNY5f 7sn701ejvKRLKFcu8yorWObNeOFmuEkDcM+FdMVDvKqMmHFtTK6YnUqgJfQh3vAQy+ ID+ekdWZHwL0Q== Original-Received: from pastel (unknown [45.72.243.7]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 978CE12093F; Mon, 27 Jan 2020 09:43:39 -0500 (EST) In-Reply-To: (Evgeny Zajcev's message of "Mon, 27 Jan 2020 02:04:30 +0300") X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 132.204.25.50 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:244672 Archived-At: > Fixes problems users experiencing with `battery-upower'. > Also checks fore UPower is availability Thanks, Evgeny. I'm on a desktop right now so can't test it, but here are some comments: > Subject: [PATCH] [fix] battery.el (battery-upower-prop) Fine. > - Commentary about UPower support > > - Interface typofix, use "org.freedesktop.UPower.Device" interface > instead of "org.freedesktop.UPower" > > - Use "DisplayDevice" as `battery-upower-device'. Making > `battery-upower' to work out-of-box for most users. > > - Detect upower availability. Set `battery-status-function' to > `battery-upower' in case upower is available. Here, please try and use the ChangeLog format. E.g. * lisp/battery.el (battery-upower-device): Use "DisplayDevice". Should make `battery-upower' work out-of-box for most users. (battery-upower-prop): Interface typofix, use "org.freedesktop.UPower.Device" interface instead of "org.freedesktop.UPower". (battery-status-function): Detect upower availability. Use `battery-upower' in case UPower is available. > ;; There is at present support for GNU/Linux, macOS and Windows. This > -;; library supports both the `/proc/apm' file format of Linux version > -;; 1.3.58 or newer and the `/proc/acpi/' directory structure of Linux > -;; 2.4.20 and 2.6. Darwin (macOS) is supported by using the `pmset' > -;; program. Windows is supported by the GetSystemPowerStatus API call. > +;; library supports UPower (https://upower.freedesktop.org) via D-Bus > +;; API or the `/proc/apm' file format of Linux version 1.3.58 or newer > +;; and the `/proc/acpi/' directory structure of Linux 2.4.20 and 2.6. > +;; Darwin (macOS) is supported by using the `pmset' program. Windows > +;; is supported by the GetSystemPowerStatus API call. Not a criticism, but I just notice that this doesn't mention the /sys/class/power_supply interface used in more recent kernels. If you can update this comment accordingly it would be even better (but if you don't, that's fine as well). > -(defcustom battery-upower-device "battery_BAT1" > +(defcustom battery-upower-device "DisplayDevice" Could add some comment explaining why "DisplayDevice" is a good choice (and what it means)? Maybe a simple URL pointing to some UPower documentation? Intuitively, without any knowledge of UPower (or D-Bus for that matter), this choice of name sounds rather odd (sounds like the it's talking about the screen rather than the battery). > +(declare-function dbus-list-known-names "dbus.el" (bus)) > + > (defcustom battery-status-function > - (cond ((and (eq system-type 'gnu/linux) > + (cond ((member "org.freedesktop.UPower" (dbus-list-known-names :system)) > + #'battery-upower) Since causes an error when I try it because `dbus` is not yet loaded when we call this function. Also, please make sure it still behaves properly if Emacs was built without D-Bus support. > (concat "/org/freedesktop/UPower/devices/" (or device battery-upower-device)) > - "org.freedesktop.UPower" > + "org.freedesktop.UPower.Device" Here, as well, if you happen to have a URL handy that documents this part of the UPower interface, it would make a good comment. Stefan