SEARCH

Enter your search query in the box above ^, or use the forum search tool.

You are not logged in.

#1 2009-09-07 10:09:08

tawan
#! Junkie
Registered: 2009-01-30
Posts: 385
Website

conky low battery warning

from here conky low battery warning

${battery_bar 6,60 BAT0}
${battery BAT0}${if_match ${battery_percent BAT0} <= 12}LOWBATWARN${endif}${if_match ${battery_percent BAT0} <= 8}SHUTDOWNCOMMAND${endif}

This uses conky to warn of low battery status and run commands as needed.

Add colour and calls to commands as required.

~~~
~~~

Full Implementation..

${battery_bar 6,60 BAT0}
${battery BAT0}${if_match ${battery_percent BAT0} <= 20}${color orange} LOW BATERY!${color}${endif}${if_match ${battery_percent BAT0} <= 8}${if_match ${battery_percent BAT0} > 5}${execi 200 terminator -e ~/mybin/warn-shutdown}${endif}${endif}${if_match ${battery_percent BAT0} <= 5}${execi 200 terminator -e ~/mybin/shutdown-now}${endif}

calls this script on low power:

*warn-shutdown*

#!/bin/bash
echo "Low power. Do you want to shutdown? y or n"
read userconfirm
if [ "$userconfirm" != "y" ]; then
echo "Please connect power soon"
sleep 6s
exit 1
else
echo "ok, will shut down in 30 seconds. Rember to save smile"
sleep 30s
sudo shutdown -h now
fi
exit


and calls this script on VERY low power:

*shutdown-now*

#!/bin/bash
echo "Very low power. You need to shutdown."
echo "if you have connected power then press y to skip shutdown"
read -t 60 userconfirm
if [ "$userconfirm" != "y" ]; then
echo "ok, have to shutdown soon, 30 second warning..."
sleep 30s
sudo shutdown -h now
exit 1
else
echo "Ok, you say power is connected so shutdown skipped"
sleep 6s
fi
exit
___

Note: Any coder can tell that I am not one wink so please improve and share.

Last edited by tawan (2009-09-08 03:56:21)


I blog too much....       geek stuff LinuxMintDebian | linux noob stuff LinuxMintNoob | spiritual stuff Daily Cup of Tao

Offline

Be excellent to each other!

#2 2009-09-10 21:58:09

arpinux
#! Die Hard
From: Montréal, France
Registered: 2009-01-15
Posts: 687
Website

Re: conky low battery warning

a good way to customize a little more conky config, even if i don't use scripts to warm me, from now on, the colors of my cpu/battery bars change with power/cpu state... thx for sharing smile

Offline

#3 2009-09-11 02:23:14

tawan
#! Junkie
Registered: 2009-01-30
Posts: 385
Website

Re: conky low battery warning

arpinux wrote:

a good way to customize a little more conky config, even if i don't use scripts to warm me, from now on, the colors of my cpu/battery bars change with power/cpu state... thx for sharing smile

Yeah sure it has that application too smile

I just could not bare to have the gnome or any other power monitor on a lightweight system and conky does the work for a few kb.


I blog too much....       geek stuff LinuxMintDebian | linux noob stuff LinuxMintNoob | spiritual stuff Daily Cup of Tao

Offline

#4 2009-09-11 10:36:20

tawan
#! Junkie
Registered: 2009-01-30
Posts: 385
Website

Re: conky low battery warning

this seems like a lot of text to achieve this but...

on AC or full battery the color is your default, then as the battery drops, green, yellow, orange, flashing red


${if_match ${battery_percent BAT0} <= 9}${color red}${blink ${battery_bar 6,60 BAT0}}${color}${endif}${if_match ${battery_percent BAT0} >= 10}${if_match ${battery_percent BAT0} <=49}${color orange}${battery_bar 6,60 BAT0}${color}${endif}${endif}${if_match ${battery_percent BAT0} >= 50}${if_match ${battery_percent BAT0} <=79}${color yellow}${battery_bar 6,60 BAT0}${color}${endif}${endif}${if_match ${battery_percent BAT0} >= 80}${if_match ${battery_percent BAT0} <=99}${color green}${battery_bar 6,60 BAT0}${color}${endif}${endif}${if_match ${battery_percent BAT0} >= 100}${battery_bar 6,60 BAT0}${endif}

EDIT, it would be cute and something i'm doing now to have the ${battery_bar 6,60 BAT0} bar change in length as it charges/discharges

${if_match ${battery_percent BAT0} <= 9}${color red}${battery_bar 14,40 BAT0}${color}${endif}${if_match ${battery_percent BAT0} >= 10}${if_match ${battery_percent BAT0} <=49}${color orange}${battery_bar 14,60 BAT0}${color}${endif}${endif}${if_match ${battery_percent BAT0} >= 50}${if_match ${battery_percent BAT0} <=79}${color yellow}${battery_bar 14,80 BAT0}${color}${endif}${endif}${if_match ${battery_percent BAT0} >= 80}${if_match ${battery_percent BAT0} <=99}${color green}${battery_bar 14,100 BAT0}${color}${endif}${endif}${if_match ${battery_percent BAT0} >= 100}${battery_bar 14,14 BAT0} FullPower${endif}

Last edited by tawan (2009-09-11 14:20:16)


I blog too much....       geek stuff LinuxMintDebian | linux noob stuff LinuxMintNoob | spiritual stuff Daily Cup of Tao

Offline

#5 2009-10-31 20:39:24

etech
Member
Registered: 2009-10-17
Posts: 12

Re: conky low battery warning

tawan, very nice battery script #2, running great my on Mini 9.  Many thanks wink


Billy - etech, Sugar Land, TX
Panasonic CF-72
#! Crunchbang Statler
Love Xfce - Debian

Offline

#6 2009-11-09 16:31:48

uden
New Member
Registered: 2009-06-15
Posts: 4

Re: conky low battery warning

As i use my laptop a lot without power, i added the folllowing code in .conkyrc:

BATTERY ${hr 2}
${battery BAT0}${if_match ${battery_percent BAT0} <= 20}${color orange} LOW BATTERY!${color}${endif}${if_match ${battery_percent BAT0} <= 8}${if_match ${battery_percent BAT0} > 5}${execi 200 terminator -e ~/mybin/warn-shutdown}${endif}${endif}${if_match ${battery_percent BAT0} <= 5}${execi 200 terminator -e ~/mybin/shutdown-now}${endif}

Results after the text "BATTERY" is a text "unknown", then "95%", followed by the text "{if_match}LOW BATTERY!{if_match}{if_match}{if_match}"

Looks to me some of the commands like ${battery BAT0} are not known. Which version of Conky is needed for this script? Or am i doing something else wrong?
I am running a fresh install of Crunchbang 9.04.

thanks for your help

Offline

#7 2009-11-09 22:15:09

tawan
#! Junkie
Registered: 2009-01-30
Posts: 385
Website

Re: conky low battery warning

You may not have all the scripts to activate shutdown. What you most need is the warning.

${if_match ${battery_percent BAT0} <= 19}${color red}Battery: ${battery}${else}${color2}${battery}${endif}


I blog too much....       geek stuff LinuxMintDebian | linux noob stuff LinuxMintNoob | spiritual stuff Daily Cup of Tao

Offline

#8 2009-11-21 01:07:25

wcs
New Member
Registered: 2009-11-21
Posts: 1

Re: conky low battery warning

Hi, all.

I'm not actually using Crunchbang, but thought I could share my conky battery monitor.
The only difference from the previous examples is that I'm using the system notifications to warn me of the low battery status as well (I'm on a small netbook screen, and don't always pay attention to conky underneath). The notifications are done in two tiny python scripts.

Also, it would be silly to have the low battery notifications while charging, so I have conky first check to see if we're on AC power. Notifications (and colour changes) only happen when on battery.

This example does a notification every 2 minutes (and an orange bar) when battery is between 5% and 10%, then a more "urgent" notification every minute (and a red bar) when it's between 3% and 5%, and finally I have conky hibernating the system when it reaches 3% (code is structured rather than in a line, for easy reading):

${if_existing /sys/class/power_supply/ACAD/online 0}
    ${if_match ${battery_percent BAT1} <= 10}
        ${if_match ${battery_percent BAT1} <= 5}
            ${if_match ${battery_percent BAT1} <= 3}
                ${color red}                
                ${exec /usr/sbin/pm-hibernate}
            $else
                ${color red}
                ${execi 60 /usr/local/bin/criticalbat.py}
            $endif
        $else
            ${color orange}
            ${execi 120 /usr/local/bin/lowbat.py}
        $endif
    $endif
$endif
${battery_bar 6,150 BAT1}
$color

And these are the python scripts. This is lowbat.py:

#!/usr/bin/env python
import pynotify
pynotify.init("foo")
pynotify.Notification("Power warning", "Battery capacity is low.", "battery-low").show()

And criticalbat.py:

#!/usr/bin/env python
import pynotify
pynotify.init("foo")
pynotify.Notification("POWER WARNING!", "Battery capacity is critically low!", "battery-caution").show()

Of course, for the whole thing to work, you need to: (1) have python-notify installed; (2) put the python scripts in the right place and make them executable; (3) make sure you have the battery-low and battery-caution icons in your system; (4) allow the user to hibernate in sudoers; (5) check to make sure of the path of the AC file; and (6) replace BAT1 with your battery.

Apologies if for some reason it doesn't apply to Crunchbang... but I guess it should.

Thanks!

Last edited by wcs (2009-11-21 01:10:24)

Offline

#9 2009-11-21 10:42:27

tawan
#! Junkie
Registered: 2009-01-30
Posts: 385
Website

Re: conky low battery warning

Hi wcs. That's great to see a more clean and professional approach.


I blog too much....       geek stuff LinuxMintDebian | linux noob stuff LinuxMintNoob | spiritual stuff Daily Cup of Tao

Offline

#10 2010-11-02 16:05:51

melclic1988
New Member
Registered: 2010-11-02
Posts: 1

Re: conky low battery warning

I have written a two small scripts to help me auto-shutdown my laptop at a certain battery percentage. Like the previous post I have not used crunchbag.

I have an old laptop with an old battery. With Ubuntu 10.10 there is an auto-shutdown program, but once its starts the battery runs out before it properly shuts down. As well it was annoying when I plugged in a power source but the computer shuts down anyway.

I liked the idea the proposed scripts above, but wanted more out of them. So I decided to write my own and tweak theirs.

This is the first time a write scripts like this so: -1: be nice -2: please post any improvements you have.


Here it goes (I suggest that you save and create all of these files in the same place):

The first thing to do was to write a script with a popup window with a warning and a countdown until shut down.

I chose a progress bar in zenity:

#!/bin/sh
sudo shutdown -t 60 -h +1 &
        (
        echo "1" ; sleep 0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "2" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "3" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "4" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "5" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "6" ; sleep 0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "7" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "8" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "9" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "10" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "11" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "12" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "13" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "14" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "15" ; sleep 0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "16" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "17" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "18" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "19" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "20" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "21" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "22" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "23" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "24" ; sleep 0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "25" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "26" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "27" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "28" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "29" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "30" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "31" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "32" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "33" ; sleep 0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "34" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "35" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "36" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "37" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "38" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "39" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "40" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "41" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "42" ; sleep 0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "43" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "44" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "45" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "46" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "47" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "48" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "49" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "50" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "51" ; sleep 0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "52" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "53" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "54" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "55" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "56" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "57" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "58" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "59" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "60" ; sleep 0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "61" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "62" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "63" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "64" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "65" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "66" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "67" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "68" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "69" ; sleep 0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "70" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "71" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "72" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "73" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "74" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "75" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "76" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "77" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "78" ; sleep 0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "79" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "80" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "81" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "82" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "83" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "84" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "85" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "86" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "87" ; sleep 0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "88" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "89" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "90" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "91" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "92" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "93" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "94" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "95" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "96" ; sleep 0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "97" ; sleep  0.3
        echo "# Low Battery:               Plug Power Source" ; sleep  0.3
        echo "98" ; sleep  0.3
        echo "# Shutting Down now..." ; sleep  0.3
        echo "99" ; sleep  0.3
        echo "# Shutting Down now..." ; sleep  0.3
        echo "100" ; sleep  0.3
        ) |  if   zenity --progress --width 350 --progress --title="Low Battery" --text="Doing important things..." --percentage=100
then
zenity --error --text="Ok, Ok, I'm shutting down now!"
else
sudo shutdown -c
exit
        fi

As you can see the progress bar is for aesthetics only, but the bar and the countdown are coordinated. The timer is one minute. I don't know how to have it less than that.

Then it was important to me that this countdown was stopped if I managed to plug in a power source fast enough. So I wrote the second script. (by the way I hope you are not running zenity programs on your laptop or this script will kill them):

#!/bin/bash
until  grep -q "1" "/sys/class/power_supply/ACAD/online"
do
{ if grep -q "1" "/sys/class/power_supply/ACAD/online"
    then
    sudo shutdown -c & sudo killall conkyfinal.
    sudo killall zenity
    fi }
    done

You need to give these scripts permission to run as programs. So right click on the scripts, choose properties, permission tab and tick the allow to run as program box. As well you will probably notice that you need root access to shutdown your laptop. This means that you need to give these files root access.

www.tuxation.com/setuid-on-shell-scripts.html

What you want to do is open your favorite text editor and paste this:

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>

int main()
{
   setuid( 0 );
   system( "/path/to/script.sh" );

   return 0;
}

Save it as runscript.c (or any other name)

Now open a terminal and find your way to the file you saved runscript.c with the other files. And execute these commands:

gcc runscript.c -o runscript
sudo chown root:root runscript
sudo chmod 4755 runscript

Now remember that you need to do this for each script. Just change the runcript.c to runscript2.c and the rest of the commands as well. Remember to change the path name to the second file.

Now that we have the scripts we need to make conky execute them when we want. Paste this at the end of your conky script. (normally gedit ~/.conkyrc)

${if_existing /sys/class/power_supply/ACAD/online 0} 
${if_match ${battery_percent BAT1} <= 20}${color2}${exec /path/to/runscript}${endif}${endif}

Change the values of BAT1 to BAT0 or any other according to your laptops battery. To find out execute this in your terminal and the output should be your battery name:

ls /proc/acpi/battery

                   
I have chosen 20% of battery because my laptops battery is that bad.                     

Now I came across a problem at that point because I could not execute two scripts at the same time in conky. So we need to create another conky to be executed on start up with, to execute the second script.

First we need to create a new conky file with to execute the second script. Mine displays a single sentence on the far left corner to make sure that that conky is actually working. It looks like this:

######################
# - Conky settings - #
######################
update_interval 1
total_run_times 0
net_avg_samples 1
cpu_avg_samples 1

imlib_cache_size 0
double_buffer yes
no_buffers yes

format_human_readable

#####################
# - Text settings - #
#####################
use_xft yes
xftfont Droid Sans:size=9
override_utf8_locale yes
text_buffer_size 2048

#############################
# - Window specifications - #
#############################
own_window_class Conky
own_window yes
own_window_type override
own_window_transparent yes
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager

alignment top_left
gap_x 7
gap_y 32
minimum_size 182 0
maximum_width 182

default_bar_size 85 5
#########################
# - Graphics settings - #
#########################
draw_shades no

default_color cccccc

color0 white
color1 white
color2 white
color3 2B893E
color4 A05A06
color5 A09A06

TEXT
${font Droid Sans:style=Bold:size=9}StopShut activated ${font}

${if_existing /sys/class/power_supply/ACAD/online 0}
${if_match ${battery_percent BAT1} <= 21}${color2}${exec /home/melclic1988/Documents/mybin/runscript2}${endif}${endif}

But the important lines are:

${if_existing /sys/class/power_supply/ACAD/online 0} 
${if_match ${battery_percent BAT1} <= 21}${color2}${exec /path/to/runscript2}${endif}${endif}

It is important that this script lunches before the other one. So for the battery percentage put the percentage slightly higher for this script compared to the other one.

Now you need to change your start up application script so that both these conky files are executed at the startup of your laptop. So change the start up conky file to this one:

#!/bin/bash
sleep 15 &&
conky -d -c /path/to/firstscript &
sleep 15 &&
conky -d -c /path/to/secondscriptt &
exit

Remember I am not responsible if these scripts do not work. And don't forget that making any file have auto-root access may be dangerous for your system.

Have fun.

Last edited by melclic1988 (2010-11-07 16:21:25)

Offline

Board footer

Powered by FluxBB

Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.

Debian Logo