Code Monkey home page Code Monkey logo

svg-battery-indicator's Introduction

svg-battery-indicator.el

This is a simple package for generating an SVG battery indicator for us in the mode-line or tab-bar. It’s not on MELPA or Gnu Elpa, so you’ll have to install it manually, or using a GitHub helper like straight. See the top right of the screen-shot below:

./svg-battery-indicator.jpg

This package requires Emacs to be built with SVG support. You can test this by running (image-type-available-p 'svg). If you get t, you have SVG support.

Usage

The indicator takes advantage of display-battery-mode (and the battery.el library generally). It uses advice to add an extra expando to battery-mode-line-format. To use, add svg-battery-indicator-status-advice as :filter-return advice to battery-status-function (whatever battery-status-function is on your machine). The expando %i will then be available in battery-mode-line-format, and expands to an a battery SVG.

You might have something like this in your init.el:

(advice-add
 ;; NOTE that `battery-status-function' is UNQUOTED. It's a variable,
 ;; which battery.el requires to point at a function, with a return
 ;; value which `svg-battery-indicator-status-advice' can handle.
 battery-status-function
 :filter-return
 #'svg-battery-indicator-status-advice)

(display-battery-mode)

(setq battery-mode-line-format "%p%% %i")

;; To display in the mode-line
(add-to-list 'mode-line-format
	       'battery-mode-line-string)

;; To display in the tab-bar
(add-to-list 'tab-bar-format
	       'battery-mode-line-string)

Customization

The variable svg-battery-indicator-length sets the length of the indicator. Otherwise all customization is through battery.el. The indicator uses the threshholds set in battery-load-low and battery-load-critical, and represents them with the foreground colours from the faces battery-load-low and battery-load-critical.

svg-battery-indicator's People

Contributors

hugo-heagren avatar syohex avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

syohex swflint

svg-battery-indicator's Issues

Error message on wake-from-suspend

When I wake my machine from suspend, I see the following error in the minibuffer:

Error running timer ‘battery-update-handler’: (wrong-type-argument number-or-marker-p N/A)

I suspect that this is because percentage is occasionally a string, but am not positive, and may be a quirk of the battery backend that I'm am using (battery-upower).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.