Skip to content

Instantly share code, notes, and snippets.

@notpratheek
Last active December 11, 2015 17:48
Show Gist options
  • Select an option

  • Save notpratheek/4636522 to your computer and use it in GitHub Desktop.

Select an option

Save notpratheek/4636522 to your computer and use it in GitHub Desktop.
Tmux Battery Indicator
#!/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()
@notpratheek
Copy link
Author

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 acpi package,

you can install it by running

su -c "yum install acpi" 

or

sudo yum install acpi

Following the original script's guide, you should add this to your ~/.tmux.conf

set -g status-right '#(~/bin/tmuxing.py)'

for added colour

set -g status-right '#[fg=colour61] #(~/bin/tmuxing.py)'

That's about it ! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment