Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I don't really know about scripts but I'm trying to create one to display battery level when a key is pressed.

I've done this:

battery_level=`acpi -b | grep -P -o '[0-9]+(?=%)'`
ac_power=`acpi -a | grep -P -o 'off-line'`
notify-send "Battery: $battery_level %" "AC: $ac_power" --icon=$ico -a "Power" -u critical -t 100

I would like it to change display "on-line" when AC Power is connected. I would also like to change icon depending on battery_level

If ac_power = off-line
  if batery_level > 0 and battery_level < 20 then ico=critical.png
  if batery_level > 20 then ico=full.png

If ac_power = on-line
  if batery_level > 0 and battery_level < 20 then ico=ACcritical.png
  if batery_level > 20 then ico=ACfull.png
share|improve this question

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.