unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Need a function for fbsd-battery-status.
@ 2008-11-23  6:22 anhnmncb
  2008-11-23 14:35 ` Nikolai Nespor
  0 siblings, 1 reply; 3+ messages in thread
From: anhnmncb @ 2008-11-23  6:22 UTC (permalink / raw)
  To: emacs-devel

(display-battery-mode t) doesn't support freebsd, can implement one?

Thank you.





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

* Re: Need a function for fbsd-battery-status.
  2008-11-23  6:22 Need a function for fbsd-battery-status anhnmncb
@ 2008-11-23 14:35 ` Nikolai Nespor
  2008-11-23 23:36   ` anhnmncb
  0 siblings, 1 reply; 3+ messages in thread
From: Nikolai Nespor @ 2008-11-23 14:35 UTC (permalink / raw)
  To: emacs-devel


(defun battery-freebsd-acpi ()
  (let* ((acpi-output (split-string
                       (shell-command-to-string "sysctl -n hw.acpi.battery")))
 	 (battery-life-percentage (nth 0 acpi-output))
 	 (battery-life-time (nth 1 acpi-output))
 	 (battery-status-terse (cond
                                 ((< (string-to-number battery-life-time)
                                     0) "+")
                                 ((> (string-to-number battery-life-percentage)
                                     30) "")
                                 ((< (string-to-number battery-life-percentage)
                                     31) "-")
                                 ((< (string-to-number battery-life-percentage)
                                     15) "!")
                                 (t "?")))
 	 (retval ()))
    (when battery-life-percentage
      (setq retval (cons (cons ?p battery-life-percentage) retval)))
    (when battery-status-terse
      (setq retval (cons (cons ?b battery-status-terse) retval)))
    retval))

HTH, Nikolai

-- 
Ich verwalte sie. Ich zähle sie und zähle sie wieder.
Das ist nicht leicht. Aber ich bin ein ernsthafter Mann.
\\
 ---> Antoine de Saint-Exupery, "Der kleine Prinz"





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

* Re: Need a function for fbsd-battery-status.
  2008-11-23 14:35 ` Nikolai Nespor
@ 2008-11-23 23:36   ` anhnmncb
  0 siblings, 0 replies; 3+ messages in thread
From: anhnmncb @ 2008-11-23 23:36 UTC (permalink / raw)
  To: emacs-devel

Nikolai Nespor <usenet@nespor.at> writes:

> (defun battery-freebsd-acpi ()
>   (let* ((acpi-output (split-string
>                        (shell-command-to-string "sysctl -n hw.acpi.battery")))
>  	 (battery-life-percentage (nth 0 acpi-output))
>  	 (battery-life-time (nth 1 acpi-output))
>  	 (battery-status-terse (cond
>                                  ((< (string-to-number battery-life-time)
>                                      0) "+")
>                                  ((> (string-to-number battery-life-percentage)
>                                      30) "")
>                                  ((< (string-to-number battery-life-percentage)
>                                      31) "-")
>                                  ((< (string-to-number battery-life-percentage)
>                                      15) "!")
>                                  (t "?")))
>  	 (retval ()))
>     (when battery-life-percentage
>       (setq retval (cons (cons ?p battery-life-percentage) retval)))
>     (when battery-status-terse
>       (setq retval (cons (cons ?b battery-status-terse) retval)))
>     retval))
>
> HTH, Nikolai

Nice, thank you :)





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

end of thread, other threads:[~2008-11-23 23:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-23  6:22 Need a function for fbsd-battery-status anhnmncb
2008-11-23 14:35 ` Nikolai Nespor
2008-11-23 23:36   ` anhnmncb

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