Author Topic: Battery charge notification  (Read 850 times)

0 Members and 1 Guest are viewing this topic.

Offline Holmes

  • Mirror Support Team
  • ***
  • Posts: 2039
  • Brazilian and Hispanic Support Team
    • Manjaro Brasil
  • Branch: Stable
  • Desktop: Manjaro XFCE
  • GPU Card: Mobile Intel (R) 945
  • GPU driver: Non-free
  • Kernel: kernellinux
  • Skill: Novice
Battery charge notification
« on: 31. January 2016, 19:58:06 »
hi guys, i found an interesting script for battery charge notification:

Code: [Select]
#!/bin/bash
#
# -*- ENCODING: UTF-8 -*-
# Este programa es software libre. Puede redistribuirlo y/o
# modificarlo bajo los términos de la Licencia Pública General
# de GNU según es publicada por la Free Software Foundation,
# bien de la versión 2 de dicha Licencia o bien (según su
# elección) de cualquier versión posterior.
#
# Si usted hace alguna modificación en esta aplicación,
# deberá siempre mencionar al autor original de la misma.
#
# DesdeLinux.net CC-BY-SA 2015
# Autor: ELAV 

BATLVL=$(cat /sys/class/power_supply/BAT1/capacity)

if [ $BATLVL -ge 80 ]; then

    if [ ! -a /tmp/batwarn ]; then
        notify-send --urgency=critical --expire-time=5000 --app-name=Bateria --icon=battery "Notificación de Batería" "Desconecta la corriente eléctrica por favor" ;
        touch /tmp/batwarn ;
    elif [ $BATLVL -le 40 ]; then

        if [ ! -a /tmp/batwarn ]; then
            notify-send --urgency=critical --expire-time=5000 --app-name=Bateria --icon=battery "Notificación de Batería" "Conecta la corriente eléctrica por favor"
            touch /tmp/batwarn ;
        fi
    else
        if [ -a /tmp/batwarn ]; then
            rm -f /tmp/batwarn ;
        fi
   fi     
fi

ps: in http://bit.ly/1KPSrBi.

vlw fwi, Holmes :)
« Last Edit: 31. January 2016, 20:03:04 by Holmes »


==> Manjaro Brasil I Manjaro Hispano
==> IRC Manjaro Brasil: #manjaro-br I IRC Manjaro Hispano: #manjaro-es

Offline montagdude

  • Jr. Mitglied
  • **
  • Posts: 85
  • I'm new. Be nice!
  • Branch: stable
  • Desktop: KDE
  • Skill: Intermediate
Re: Battery charge notification
« Reply #1 on: 01. February 2016, 01:56:23 »
You can also get info on the current power draw from the power_now file in the same directory (actually, for me it's BAT0, not BAT1). At least, it's present for my Thinkpad; I'm not sure if it is in general. I find that info to be very useful, so I actually modified conky to display it.
« Last Edit: 01. February 2016, 02:15:57 by montagdude »

Offline Chrysostomus

  • Maintainer
  • ***
  • Posts: 1634
  • Neckbeards are cool
    • Git
  • Branch: unstable
  • Desktop: Gnome, bspwm
  • GPU Card: Intel HD4000
  • GPU driver: free
  • Kernel: linux44-x64
  • Skill: Intermediate
Re: Battery charge notification
« Reply #2 on: 01. February 2016, 06:50:27 »
How about using variable that checks what battery is present? Semething like:
Code: [Select]
BAT=$(ls /sys/class/power_supply/ | grep -o "BAT.")
BATLVL=$(cat /sys/class/power_supply/$BAT/capacity)
Then just make it somehow check for the battery just once instead of every time...

Only downside is that it fails for computers with several batteries (thinkpads).
« Last Edit: 01. February 2016, 06:52:13 by Chrysostomus »

Offline Holmes

  • Mirror Support Team
  • ***
  • Posts: 2039
  • Brazilian and Hispanic Support Team
    • Manjaro Brasil
  • Branch: Stable
  • Desktop: Manjaro XFCE
  • GPU Card: Mobile Intel (R) 945
  • GPU driver: Non-free
  • Kernel: kernellinux
  • Skill: Novice
Re: Battery charge notification
« Reply #3 on: 01. February 2016, 22:36:25 »
has the option jbattery, here http://bit.ly/20kpWYL.

in Manjaro JWM Edition 16.dev combined ibam with this script http://bit.ly/20kqgqq.

vlw fwi, Holmes :)


==> Manjaro Brasil I Manjaro Hispano
==> IRC Manjaro Brasil: #manjaro-br I IRC Manjaro Hispano: #manjaro-es