all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [PATCH] battery.el, upower fixes
@ 2020-01-26 23:04 Evgeny Zajcev
  2020-01-27 14:43 ` Stefan Monnier
  2020-01-27 18:23 ` Eli Zaretskii
  0 siblings, 2 replies; 18+ messages in thread
From: Evgeny Zajcev @ 2020-01-26 23:04 UTC (permalink / raw)
  To: emacs-devel


[-- Attachment #1.1: Type: text/plain, Size: 114 bytes --]

Fixes problems users experiencing with `battery-upower'.

Also checks fore UPower is availability

Thanks

-- 
lg

[-- Attachment #1.2: Type: text/html, Size: 312 bytes --]

[-- Attachment #2: 0001-fix-battery.el-battery-upower-prop.patch --]
[-- Type: text/x-patch, Size: 2588 bytes --]

From 124ca9d38ae6752f32b88a7c45111ea1bb423829 Mon Sep 17 00:00:00 2001
From: Zajcev Evgeny <zevlg@yandex.ru>
Date: Mon, 27 Jan 2020 01:26:26 +0300
Subject: [PATCH] [fix] battery.el (battery-upower-prop)

- 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.

All this makes `M-x battery RET' to work out-of-box using upower
interface in case of its availability
---
 lisp/battery.el | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/lisp/battery.el b/lisp/battery.el
index 49b01d5b54..057629318e 100644
--- a/lisp/battery.el
+++ b/lisp/battery.el
@@ -23,10 +23,11 @@
 ;;; Commentary:
 
 ;; 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.
 
 ;;; Code:
 
@@ -45,14 +46,18 @@
   :type 'regexp
   :group 'battery)
 
-(defcustom battery-upower-device "battery_BAT1"
+(defcustom battery-upower-device "DisplayDevice"
   "Upower battery device name."
   :version "26.1"
   :type 'string
   :group '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)
+        ((and (eq system-type 'gnu/linux)
 	      (file-readable-p "/proc/apm"))
 	 #'battery-linux-proc-apm)
 	((and (eq system-type 'gnu/linux)
@@ -547,7 +552,7 @@ The following %-sequences are provided:
    :system
    "org.freedesktop.UPower"
    (concat "/org/freedesktop/UPower/devices/" (or device battery-upower-device))
-   "org.freedesktop.UPower"
+   "org.freedesktop.UPower.Device"
    pname))
 
 (defun battery-upower ()
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2020-06-11 16:12 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-01-26 23:04 [PATCH] battery.el, upower fixes Evgeny Zajcev
2020-01-27 14:43 ` Stefan Monnier
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

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.