Adding Battery Widget and ACPI Notification in Awesome

TurnToJPG -->

For keeping the “Clean Desktop”, the cleaner in my office unpluged my laptop’s powerline, and the laptop suddenly going to black when I was coding, so I want to write some scripts for calculating the battery’s power percentage and got notification when the power of the battery is too low. ###Add an indicator in Awesome Desktop Awesome have a very good 3rd-party library called “Vicious”, its page is at, following the guideline for install and configure it. Install the library:

	$ cd ~/.config/awesome
	$ git clone

Modify the rc.lua to add following lines:

-- Using vicious
-- Vicious is a modular widget library for awesome, derived from the Wicked widget library. 
vicious = require("vicious")

-- Add the Battery 
mybattery = wibox.widget.textbox()
vicious.register(mybattery, vicious.widgets.bat, "||Battery: $2% ", 30, "BAT0")

-- We add mybattery here!

After modification, save the rc.lua and restart the awesome desktop, you will see the following pictures. /images/awesomebattery.jpg ###Add notification when battery is too low We can use acpi for getting the battery and power supply information, so first let’s install it:

	$ sudo pacman -S  acpi

Then we can write an script named, put it under the /bin folder:

battery_level=`acpi -b | grep -P -o '[0-9]+(?=%)'`
if [ $battery_level -le 10 ]
    notify-send "Battery low" "Battery level is ${battery_level}%!"

Then we add an item under crotab:

	$ crontab -e
	# crontab's configuration:
	2 * * * * /bin/

Now we can got an indication when battery is less than 10%. you can adjust the number to whatever you want.