unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Evgeny Zajcev <lg.zevlg@gmail.com>
Cc: emacs-devel <emacs-devel@gnu.org>
Subject: Re: [PATCH] battery.el, upower fixes
Date: Mon, 27 Jan 2020 09:43:32 -0500	[thread overview]
Message-ID: <jwvh80hj7r7.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <CAO=W_ZoP8EH8+wjuzjDjKPzmVSfw7JDsOi_ECkHJMh8H=UZ6QA@mail.gmail.com> (Evgeny Zajcev's message of "Mon, 27 Jan 2020 02:04:30 +0300")

> 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




  reply	other threads:[~2020-01-27 14:43 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-26 23:04 [PATCH] battery.el, upower fixes Evgeny Zajcev
2020-01-27 14:43 ` Stefan Monnier [this message]
2020-01-27 18:23 ` Eli Zaretskii
2020-01-29  7:05   ` Evgeny Zajcev
2020-01-29  8:37     ` Andreas Schwab
2020-01-30 10:22       ` Evgeny Zajcev
2020-02-04 19:55         ` Stefan Monnier
2020-02-04 20:16           ` Michael Albinus
2020-02-04 23:10             ` Stefan Monnier
2020-06-11 16:12             ` Basil L. Contovounesios
2020-02-05  0:22           ` Evgeny Zajcev
2020-02-05  1:27             ` Stefan Monnier
2020-02-05  2:24               ` Evgeny Zajcev
2020-02-05  3:03                 ` Stefan Monnier
2020-02-06  0:55                   ` Richard Stallman
2020-02-06 18:27                     ` Eli Zaretskii
2020-02-06  7:48                   ` Evgeny Zajcev
2020-02-06 14:18                     ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvh80hj7r7.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.org \
    --cc=lg.zevlg@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).