Skip to content

Instantly share code, notes, and snippets.

@ngty
Last active December 17, 2015 04:48
Show Gist options
  • Save ngty/5552730 to your computer and use it in GitHub Desktop.
Save ngty/5552730 to your computer and use it in GitHub Desktop.
Generating battery status
#!/bin/bash
if [ "$(acpi -a | awk '{print $3}' | tr [a-z] [A-Z])" == "ON-LINE" ]; then
if [ "$(acpi -b | awk '{print $4}')" == "100%" ]; then
echo -n "100%"
else
echo -n "$(
acpi -b | \
awk '{gsub(",",""); print $4 "(+" $5}' | \
awk -F: '{print $1 ":" $2 ")"}'
)"
fi
else
echo -n "$(
acpi -b | \
awk '{gsub(",",""); print $4 "(-" $5}' | \
awk -F: '{print $1 ":" $2 ")"}'
)"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment