You are not logged in.
Hey,
I got this script to show the battery life of my laptop in my PS1:
#!/bin/bash
BATTERY=/sys/class/power_supply/BAT1
REM_CAP=`cat $BATTERY/energy_now`
FULL_CAP=`cat $BATTERY/energy_full`
BATSTATE=`cat $BATTERY/status`
CHARGE=`echo $(( $REM_CAP * 100 / $FULL_CAP ))`
NON='\033[00m'
BLD='\033[01m'
RED='\033[01;31m'
GRN='\033[01;32m'
YEL='\033[01;33m'
COLOUR="$RED"
case "${BATSTATE}" in
'Charged')
BATSTT="$BLD=$NON"
;;
'Charging')
BATSTT="$BLD+$NON"
;;
'Discharging')
BATSTT="$BLD-$NON"
;;
esac
if [ "$CHARGE" -gt "99" ]
then
CHARGE=100
fi
if [ "$CHARGE" -gt "30" ]
then
COLOUR="$GRN"
fi
if [ "$CHARGE" -gt "15" ]
then
COLOUR="$YEL"
fi
echo -e "${COLOUR}${CHARGE}%${NON} ${BATSTT}"I made it executable: chmod +x /home/kanikuleet/scripts/battery_status.sh
Put this in my .bashrc file: PS1="[ \$(/home/kanikuleet/scripts/battery_status.sh) ] \u@\h:\w \$ "
Built it: source ~/.bashrc
Now I get this errors:
/home/kanikuleet/scripts/battery_status.sh: Line 30: [: echo $(( $REM_CAP * 100 / $FULL_CAP )): integer expression expected
/home/kanikuleet/scripts/battery_status.sh: Line 35: [: echo $(( $REM_CAP * 100 / $FULL_CAP )): integer expression expected
/home/kanikuleet/scripts/battery_status.sh: Line 40: [: echo $(( $REM_CAP * 100 / $FULL_CAP )): integer expression expectedMy bash promt currently looks like this:
[ echo $(( $REM_CAP * 100 / $FULL_CAP ))% ] kanikuleet@arch: ~ $I have acpi installed and BAT1 is my battery, I checked it.
Can anyone help??
Last edited by kanikuleet (2012-12-28 22:21:10)
Offline
I modified your script a little bit. Try this
http://pastebin.com/19hhf6su
EDIT: replace BAT0 with your battery.
Last edited by illusionist (2012-12-27 17:45:41)
Never argue with stupid people,They will drag you down to their level and then beat you with experience.--Mark Twain
@github
Offline
Works! Thank you ![]()
Offline
Works! Thank you
In that case, please mark your thread as [solved] by editing the title of your post.
Never argue with stupid people,They will drag you down to their level and then beat you with experience.--Mark Twain
@github
Offline