Last active
December 11, 2015 17:48
-
-
Save notpratheek/4636522 to your computer and use it in GitHub Desktop.
Tmux Battery Indicator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| #-*- coding:utf-8 -*- | |
| from __future__ import print_function | |
| from subprocess import check_output | |
| heart = '♥' | |
| bolt = '⚡' | |
| def main(): | |
| values = check_output(['acpi']).split(' ')[3] | |
| state = values[:-1] | |
| numb = int(values[:1]) # takes the first digit from the integer form of the percent | |
| wire = check_output(['acpi']).split(' ')[2] | |
| charge = wire[:-1] | |
| if(state == '100%'): | |
| for i in range(1, 11): | |
| print(heart, end='') | |
| else: | |
| for i in range(numb): | |
| print(heart, end='') # Too used to python3 print syntax :) | |
| if(charge == 'Charging' or charge == 'Full'): | |
| print('', values[:-1], bolt, end='') | |
| else: | |
| print('', values[:-1], end='') | |
| if __name__ == '__main__': | |
| main() |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here's a simple battery indicator that I created.
I made this using this script, but the acpi folder isn't present in Fedora (or .rpm based systems) as its present in Debian/Ubuntu based systems. So, I created this one ! :)
Be aware, this works in Fedora (its derivates, and in .rpm based systems).
This was created (and tested) of a Fedora 17 (32-bit)
You will need Python 2.x --> This is a no brainer ! ;)
next you'll need
acpipackage,you can install it by running
su -c "yum install acpi"or
Following the original script's guide, you should add this to your
~/.tmux.conffor added colour
That's about it ! :)