[solved] show battery status in PS1 not working correctly (script)

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 expected
My 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)

kanikuleet wrote:Works! Thank you
In that case, please mark your thread as [solved] by editing the title of your post.

Similar Messages

  • [solved] NFS client will not work correctly

    I have all my $HOME on an NFS Server. So long I used suse and debian, now I want switch to arch but the nfs-client ist not working correctly:
    I start "portmap nfslock nfsd netfs" over rc.conf. When I do a "rpcinfo -p <ip-arch-system>" I got the following
    stefan:/home/stefan # rpcinfo -p 192.168.123.3
       Program Vers Proto   Port
        100000    2   tcp    111  portmapper
        100000    2   udp    111  portmapper
        100021    1   udp  32768  nlockmgr
        100021    3   udp  32768  nlockmgr
        100021    4   udp  32768  nlockmgr
        100003    2   udp   2049  nfs
        100003    3   udp   2049  nfs
        100003    4   udp   2049  nfs
        100021    1   tcp  48988  nlockmgr
        100021    3   tcp  48988  nlockmgr
        100021    4   tcp  48988  nlockmgr
        100003    2   tcp   2049  nfs
        100003    3   tcp   2049  nfs
        100003    4   tcp   2049  nfs
        100005    3   udp    891  mountd
        100005    3   tcp    894  mountd
    As you see "status" is missing, so the statd is not running. It sould look like the result on my suse box:
    stefan:/home/stefan # rpcinfo -p 192.168.123.2
       Program Vers Proto   Port
        100000    2   tcp    111  portmapper
        100000    2   udp    111  portmapper
        100024    1   udp  32768  status
        100021    1   udp  32768  nlockmgr
        100021    3   udp  32768  nlockmgr
        100021    4   udp  32768  nlockmgr
        100024    1   tcp  35804  status
        100021    1   tcp  35804  nlockmgr
        100021    3   tcp  35804  nlockmgr
        100021    4   tcp  35804  nlockmgr
    There is the "status" line and so the statd is running.
    How can I fix that problem, so that statd ist running on my arch box too?
    Last edited by stka (2007-06-10 15:59:48)

    The Problem ist solved.
    I use ldap for authentication. During the setup of the ldapclient I copied the nsswitch.ldap to nsswitch.conf. But the line for "hosts:" was:
    hosts:          dns ldap
    but in my dns ist no localhost entry. After I changed this line to:
    hosts:          files dns ldap
    everything was ok. The statd is now running and I can start to migrate to archlinux ;-)

  • Satellite L50-A-10Q: Win8.1 Pro Wi-Fi status LED is not working

    Hello,
    I have an Toshiba L50-10-A-10Q Notebook running BIOS Version 1.30 and EC Version 1.10.
    I recently updated from Windows 8 to Windows 8.1 Pro.
    I followed the update instructions found on the Driver Download page.
    All function keys and modules (Wifi, Bluetooth, etc.) work fine.
    However, the status LEDs do not work properly.
    The status LED for Wifi is always off, even when Wifi is activated and connected.
    The status LED for the Touch Pad is also always off, even when it is deactivated.
    Power LED and charge indicator work fine.
    All status LED were working properly before the update to WIN 8.1.
    Is there a solution for this problem?
    Kind Regards
    Niko

    Why you dont try to update or reinstall the Intel WLan driver and Toshiba System Driver again?
    Since this procedure helped to solve the touchpad issue and I guess this would solve problem with the WLan indicator too.
    [Intel Wireless Lan Driver 16.0.2.1.0.s64 for Windows 8.1 - 64 Bit|http://www.toshiba.eu/innovation/download_driver_details.jsp?service=EU&selCategory =2&selFamily=2&selSeries=178&selProduct=7948&selSh ortMod=3983&language=13&selOS=46&selType=all&yearu pload=&monthupload=&dayupload=&useDate=null&mode=a llMachines&search=&action=search&macId=&country=al l&selectedLanguage=13&type=all&page=2&ID=88542&OSI D=46&driverLanguage=42]

  • Every time I open a pdf file which includes a javascript, a dialogue box pops up. I have a question why 'Do not show this message again' is not working even I checked on the checkbox. It should block the dialogue next time when I open the same pdf file bu

    Every time I open a pdf file which includes a javascript, a dialogue box pops up. I have a question why 'Do not show this message again' is not working even I checked on the checkbox. It should block the dialogue next time when I open the same pdf file but not working. What is the matter and how can I deal with it?

    I am trying it on Adobe Acrobat Reader 9.2.1. Tried to fix Hex code, and also tried 'edit-preference-trust manager'. I focusing on Adobe registries but still couldn't fix the problem.

  • HT201263 my ipod touch 4th gen isnt work after a long time with 0 percent battery power.Then its not working. computer doesnt respond to my ipod .only black screen is appearing it even not wake up after reset it what can i do please help me

    my ipod touch 4th gen isnt work after a long time with 0 percent battery power.Then its not working. computer doesnt respond to my ipod .only black screen is appearing it even not wake up after reset it what can i do please help me

    After being connected to a charging source overnight try:
    - iOS: Not responding or does not turn on
    - Also try DFU mode after try recovery mode
    How to put iPod touch / iPhone into DFU mode « Karthik's scribblings
    - If not successful and you can't fully turn the iOS device fully off, let the battery fully drain. After charging for an least an hour try the above again.
    - Try on another computer
    - If still not successful that usually indicates a hardware problem and an appointment at the Genius Bar of an Apple store is in order.
      Apple Retail Store - Genius Bar

  • Why does it show my officejet 4622 as not working with an app when it shows it does in the info.help

    My printer is an hp officejet 4622.  I'm sorry to say I need step to step info as I am self taught 70 yr old trying to move forward. Thanks

    Hi vitamary;
    Hope you are doing well welcome to the HP forums
    can you be more specific in what is the problem that you are having, what app is showing that the printer is not working?
    Is your computer running Windows or is a Apple computer,
    letm e know this information and I will do my best to help you.
    Regards;
    RobertoR

    You can say THANKS by clicking the KUDOS STAR. If my suggestion resolves your issue Mark as a "SOLUTION" this way others can benefit Thanks in Advance!

  • Why do the "SHOW THE PREVIOUS PAGE arrows not work on some websites such as when I try to return to the previous page the arrows at the top right of the page are not dark black they are light grey and do nothing---HELPPPP

    why do the "SHOW THE PREVIOUS PAGE arrows not work on some websites such when I try yto return to a previous page the arrows at the top right of the page do not work instead they are light grey instead black and do nothing---this is frustrating to not be able to return to the page before--HELP

    If a page you go to opens in a new tab, there is no 'back' to go to. If that is the case, just close the tab and you'll be at the page you came from.

  • My laptop numerical light shows "on",but number keys not working?

    This problem started a week ago!

    Hello , Welcome back to the HP Support Forums!  To help you get the most out of the HP Forums, I would like to direct your attention to the HP Forums Guide First Time Here? Learn How to Post and More. I read your post about the Number Keys, and wanted to help! Please review the following documents, as they may help to resolve the issue for you:HP Notebook PCs - Notebook Keyboard Troubleshooting (Windows 7)HP Notebook PCs - Some Function Keys or Keyboard Shortcuts Do Not Work Correctly with Windows 7 Please let me know if this information was helpful by clicking the thumbs up below.
    Regards!

  • Function keys are not working correctly

    I've been looking all over the various threads and I can't find an answer that solves my problem.
    Here are the details:
    I bought the computer in the U.S. where I live.
    I have a iMac 2.4GHz intel Core 2 Duo  EMC 2133 with a 20" screen. Bought it new in February 2008.
    I have Mac OS X 10.5.8  (I am waiting for my order for OS Snow Leopard to come in!!)
    I have been using a wireless mouse and Keyboard (Love not having cords!)
    Recently, my wireless keyboard got a short and quit working. I went down to the apple store and got a new wireless keyboard.
    I had the computer with me at the genius bar so, yes, the apple employee saw exactly what I have.
    I took it all home got the thing all put back together and got the new keyboard paired up and working with the computer.
    Here are the problems:
    Went to go use the function keys while using iTunes and found they weren't working properly. The F10, F11 and F12 do not control the volume of sound as the keyboard indicates they would, they instead activate dashboard, spaces, and application windows. 
    Following the advice of other threads, I looked over in the system preferences and made sure the "Use all F1, F2 etc." box was unchecked (it was unchecked), things still didn't work.
    I tried the fn key but it appears to not work at all it has no effect on the functioning of the function keys.
    I went under keyboard shortcuts in system preferences and found the F10, F11 and F12 keys, it confirms that those keys control spaces, dashboard and application windows as they are performing but shows no options to either reassign to volume control (as marked on the keyboard) or make the fn key work.
    I've gone back and forth trying various combinations of checked and unchecked boxes to see if anything would work, so far I've come up with nothing.
    A couple more important or interesting facts:
    Yes I have turned off and taken the batteries out of the old keyboard. My bluetooth connection currently shows it as disconnected.
    I have restarted the computer.
    One thing I find odd; when I go under preferences and go to Keyboard and Mouse when I go under the section "Bluetooth" it shows Bluetooth mouse with the name of the mouse and the battery level. BUT nothing is showing up under bluetooth Keyboard, I can't figure out how to change this and don't know if it is contributing to the problem.
    When I go under the bluetooth logo on the top bar I find the mouse and both keyboards referenced, the old keyboard is shown as disconnected and the other two are connected. I have tried to update the device's name but it doesn't seem to let me.
    I have double clicked on the device under bluetooth and it shows the new keyboard as discoverable, paired and connected. Hence, I am using the new keyboard to write this inquiry.
    Please, any assistance would be of great help. I have tried to be thorough in order help narrow the possible problem. Thanks!!

    Hendry
    Just thought I'd let you know.  Our suspicions were correct, it was the OS. After I installed Snow Leopard (10.6.8) all the problems were corrected.  I also updated the RAM from 1 gb to 6 gb. The mac is working all around better. Sorry it took so long to get back to everyone. My superdrive had pooped out. Rather than replace it I got an external drive from OWC connected with firewire 800.  So far everything is running very well, as far as I can tell this external drive is better than the original superdrive. My superdrive has always acted funny, infact I returned the first mac I got after a week because its superdrive was also malfunctioning. Anyway, all that to say everything seems to be fully functioning again.
    Roy
    Re: Function keys are not working correctly 

  • Cooling fan not work correctly

    my computer says the cooling fan not work correctly plase visit www.hp.com.go/teachcenter/startup

    Dear Customer,
    Welcome to HP Support Forum and we are glad to assist you
    It looks like you are having difficulties with regards to the Cooling Fan of your Netbook
    We will surely assist you with this
    According to the message you have posted I suspect this is purely a hardware issue where in your getting "System Fan(90B) - The system has detected that a cooling fan is not operating correctly" message. This is a mechanical fault and the Cooling Fan on your Notebook and needs to be replaced before the Notebook starts up with an Overheating Issue.
    Causes/Reason for this Issue:
    1. Sometimes this is just because of Dust, Pet Animals Hair slowing down the fan
    Perform the  below shown troubleshooting steps:
    Step 01. Turn OFF the Notebook
    Step 02. Un-plug the Power/AC Adapter and also remove the Battery too
    Step 03. Press and Hold the Power Button of the Notebook for a full minute
    Step 04. Now let's re-insert the battery back in and plug back the Power/AC Adapter
    Step 05. Start the Notebook and keep tapping F10 Key during the startup to access the BIOS
    Step 06. Once you get to the BIOS, Please press F5 Key to load setup defaults for the BIOS
    Step 07. Now let's press Esc/Escape Key. Save Changes and Exit - Yes
    Step 08. Now please wait till Unit loads Windows and then Shut down the Netbook again
    Step 09. You should clean all the Vents and Openings really good with a can of compressed air
    Note: If you are still getting the same error we need to replace the fan
    I strongly recommend you to immediately Contact HP Technical Support over the Phone for further assistance without any delay to get your Netbook Fan replaced and serviced by an authorized HP Certified Engineer
    You can also Check your warranty Here to verify the warranty status
    Hope this helps, for any further queries reply to the post and feel free to join us again
     **Click the KUDOS star on left to say Thanks**
    Make it easier for other people to find solutions by marking a Reply 'Accept as Solution' if it solves your problem.
    Thank You,
    K N R K
    Although I am an HP employee, I am speaking for myself and not for HP

  • Keyboard not working correctly after updating to 8.1 64bit pro.

    Keyboard not working correctly after updating to 8.1 64bit pro.
    After I updated, everything seemed ok and then all of the sudden I rebooted and only the f1 – f12 row would work. I resorted to resorted to unplugging and removing the battery and it would work for a short amount of time. This has been reported on other laptops as well, see here.
    http://answers.microsoft.com/en-us/windows/forum/w​indows8_1-hardware/windows-81-keyboard-problem-cou​...
    I think it can be solved with a driver update from hp or the keyboard builder but none is online.

    Hi,
    Please put the units product no. in the link and check if your PC is tested by HP with Windows 8.1
    http://www8.hp.com/us/en/ad/windows-8/upgrade.html
    Let me know if you need more help.
    I am an HP employee.
    Make it easier for other people to find solutions, by marking my answer “Accept as Solution” if it solves your problem.
    ***Click on “Kudos” STAR to say thanks!***

  • Canon MG3550 is not working correctly

    Hello,
    I have recently bought Canon MG3550. I installed the driver etc but the printer is not working correctly. Sometimes it prints without any issues but other times it:
    - does not pick the printer - saying it's offline even though it's not (this is from laptop, iPad, phone...not just from one device)
    - does not print - the error message appears after a while saying that the printer is not responding
    - prints half of the page...or just picks up a paper but doesn't print at all
    I tried to de-install and re-install the driver etc. but it did not help. The printer is still behaving the same unpredictable way.
    Do you have any ideas how to solve it? It is a faulty device or am I doing something wrong? 
    Thank you

    Your tags show iPad. You need the iPad 3 or newer in order to have Siri. What iPad do you have?
    There are a number of apps that are compatible with Word....Documents to Go, Pages, Quick Office Pro .... You need an app that will read, save and Word files on the iPad and if you don't have such an app, all that you can do is email the file and read it in the email. You will not be able to save or edit the files.
    After you download one of this apps, you can use email, DropBox, and IOS file sharing in order to transfer the documents back and forth. You can use iCloud as described above with Pages or any other app that works with iCloud.
    Read this to learn more about file sharing.
    http://support.apple.com/kb/HT4094

  • Blackberry Curve 8520 not working correctly

    My Blackberry Curve 8520 is not working correctly. It has worked on and off for about 2 days now.
    The first thing to stop was the media files - at first it said the SD card was inserted, but couldn't find any files. I've tried repairing the card. Then it is said there was no card inserted. Have taken out and re-entered the card, and formatted it. It now says there is no card inserted again. 
    Also, Whatsapp and BBM are not working. I can open them, and can type a message, and press send, but no message actually sends. 
    Plus the screen keeps freezing, will only work again through a battery pull. 
    I've had the phone for about 3 months.
    Please help!

    Hello Sarahhelen,
    I would suggest backing up and doing a clean reload of the BlackBerry® device software as shown here: http://btsc.webapps.blackberry.com/btsc/KB11320. Please test before restoring any data to the device.
    If this resolves the issue do a selective restore of essential data (Address Book, Calendar, Task, Memos, BBM contacts etc.)
    How to use BlackBerry® Desktop Software to restore data to a BlackBerry® smartphone from a backup file
    http://btsc.webapps.blackberry.com/btsc/KB10339.
    If the issue still persists after the reload, further investigation might be required. To help further diagnose the cause, contact your wireless service provider or BlackBerry® Technical Support Services for further review and support.
    Thank you.
    -HB
    Come follow your BlackBerry Technical Team on twitter! @BlackBerryHelp
    Be sure to click Kudos! for those who have helped you.Click Solution? for posts that have solved your issue(s)!

  • HT201365 my text to send messages is now not working correctly after upgrading

    Since upgrading last week my text is not working  correctly it is very slow does not show the letter being used and takes seconds to be put in

    Looking into the Diagnostics and Usage Reports in 'Settings' -> 'General' -> 'About' I see nine different "ExcResource_MobileMail_DATE" reports. Looking at the report I see a SysInfoCrashReport that indicates that the CPU was pegged at over 50% (mostly over 75%) for over 180 seconds using the MobileMail app.
    I also see a "MobileMail_DATE" report that indicates that there was an 'Exception raised during monitored invocation of _loadMoreMessagesWithMaxVisibleIndexPath:maximumIndexPathsBySource:, exception: ** -[__NSArrayM objectAtIndex:]: index 4294967295 beyond bounds for empty array"
    And finally I see three "stacks+MobileMail-DATE" reports with "Power assertion timeout for 'com.apple.message.fetchMobileSynchronously...' Simply resetting it now." and "Power assertion timeout for 'com.apple.mobilemail.messagebodyloader' Simply resetting it now" reports.
    I updated to iOS 7.0.4 and decided to try and delete the account in my Mail settings and recreate it and set it to manual instead of the non-working fetch. Now, when I try to check my mail it still takes up to five minutes to respond, pulling the screen to refresh brings up the spinner for about one second and then disappears and no indications of activity occur until about three minutes later when I see the spinner in the status bar near the clock and then see a notification that it's downloading X of Y messages. At that point, message headers come in very quick and then about a minute later message previews come in. At random times, opening the mail app I get a "Password incorrect" error, even though the password works on other attempts.

  • If statement within a view is not working correctly ?

    Hi all,
    maybe i am wrong but i think the if statement within a view is not working correctly. See code down below.
    I would like to use the Hallo World depending on the page attribute isFrame with or without all the neccessary html tags. Therefore i have embedded the htmlb tags in an if statement. But for any reason if isframe is initial it isn't working. It would be great if anybody could help me.
    <%@page language="abap"%>
    <%@extension name="htmlb" prefix="htmlb"%>
    <% if not isframe is initial. %>
      <htmlb:content design="design2003">
         <htmlb:page title = "Top Level Navigation view">
    <% endif. %>
    hallo world
    <% if not isframe is initial. %>
         </htmlb:page>
      </htmlb:content>
    <% endif. %>
    thanks in advance and best regards
    Matthias Hlubek

    Matthias,
    The short answer: your example is <b>NOT</b> going to work. The long answer will probably 5 pages to describe. So first let me rewrite the example so that it could work, and then give a short version of the long answer. Do not be disappointed if it is not totally clear. It is rather complicated. (See the nice form of IF statements that are possible since 620.)
    <%@page language="abap"%>
    <%@extension name="htmlb" prefix="htmlb"%>
    <% if isframe is <b>NOT</b> initial. %>
    <htmlb:content design="design2003">
      <htmlb:page title = "Top Level Navigation view">
        hallo world
      </htmlb:page>
    </htmlb:content>
    <% else. %>
      hallo world
    <% endif. %>
    So why does your example not work? Let us start with a simple tag:
      <htmlb:page title = "Top Level Navigation view">
      </htmlb:page>
    Now, for each tag, we have effectively the opening part (<htmlb:page>), an optional body, and then the closing part (</htmlb:page>). We are now at the level of the BSP runtime processing one tag. What the runtime does not know, is whether the tag wants to process its body or not. Each tag can decide dynamically at runtime whether the body should be processed. So the BSP compiler generates the following code:
      DATA: tag TYPE REF TO cl_htmlb_page.
      CREATE OBJECT tag.
      tag->title = 'Top Level Navigation view'.
      IF tag->DO_AT_BEGINNING( ) = CONTINUE.
      ENDIF.
      tag->DO_AT_END( ).
    You should actually just debug your BSP code at ABAP level, and then you will immediately see all of this. Now, let us mix in your example with our code generation. First you simplified example:
    <% if isframe is NOT initial. %>
      <htmlb:page title = "Top Level Navigation view">
    <% endif. %>
    <% if isframe is NOT initial. %>
      </htmlb:page>
    <% endif. %>
    And then with our generated code. Look specifically at how the IF/ENDIF blocks suddenly match!
    if isframe is NOT initial.
      DATA: tag TYPE REF TO cl_htmlb_page.
      CREATE OBJECT tag.
      tag->title = 'Top Level Navigation view'.
      IF tag->DO_AT_BEGINNING( ) = CONTINUE.
    endif.
    if isframe is NOT initial.
      ENDIF.
      tag->DO_AT_END( ).
    endif.
    You can see that your ENDIF statements are closing IF blocks generated by the BSP compiler. Such a nesting will not work. This is a very short form of the problem, there are a number of variations, and different types of the same problem.
    The only way to solve this problem, is probably to put the body into a page fragment and include it like I did above with the duplicate HelloWorld strings. But this duplicates source code. Better is to put body onto a view, that can be processed as required.
    brian

Maybe you are looking for