aboutsummaryrefslogtreecommitdiffstats
path: root/.i3/py3status/40-power.py
diff options
context:
space:
mode:
authorAaron LI <aaronly.me@gmail.com>2016-01-06 15:11:44 +0800
committerAaron LI <aaronly.me@gmail.com>2016-01-06 15:11:44 +0800
commitdba767e8ff1599a0b4cf8fb3dc06ac0cce727748 (patch)
tree1c85bbf6409e1cb398da0dcb4cd5ad8a78644354 /.i3/py3status/40-power.py
parentc07a9bd96fde28c0f672af8d1b4d345c2e34f1b3 (diff)
downloaddotfiles-dba767e8ff1599a0b4cf8fb3dc06ac0cce727748.tar.bz2
i3: update configuration for i3wm
* Update i3 wm config * Add i3blocks.conf * Remove py3status
Diffstat (limited to '.i3/py3status/40-power.py')
-rw-r--r--.i3/py3status/40-power.py73
1 files changed, 0 insertions, 73 deletions
diff --git a/.i3/py3status/40-power.py b/.i3/py3status/40-power.py
deleted file mode 100644
index 96b8ce5..0000000
--- a/.i3/py3status/40-power.py
+++ /dev/null
@@ -1,73 +0,0 @@
-#!/usr/bin/env python3
-# -*- coding: utf-8 -*-
-#
-# Weitian LI <liweitianux@gmail.com>
-# 2014/05/15
-
-"""
-power module for py3status
-"""
-
-## Get output of shell command:
-## python 3.x:
-## >>> subprocess.getoutput(cmd)
-## >>> subprocess.getstatusoutput(cmd)
-## python 2.7.x:
-## >>> subprocess.Popen(cmd, shell=True, stderr=subprocess.PIPE)
-
-import re
-import subprocess
-import time
-
-
-POSITION = 0
-
-BAT_PRESENT = '/sys/class/power_supply/BAT0/present'
-# regex to match the '1' at the beginning
-one_p = re.compile(r'(^1).*')
-
-
-class Py3status:
- """
- Power module to show whether AC/battery is online.
-
- ac_status: online, offline
- bat_status: present, na
- """
-
- def power(self, i3status_output_json, i3status_config):
- """
- Display power status.
- """
- response = {
- 'full_text': '',
- 'name': 'power',
- 'instance': 'first',
- }
- # AC online
- ac_cmd = 'on_ac_power'
- ac_cmd_out = subprocess.getstatusoutput(ac_cmd)
- if ac_cmd_out[0] == 0:
- ac_text = '' # Icons: uF237 (ac-online)
- self.ac_status = 'online'
- response['color'] = i3status_config['color_good']
- else:
- ac_text = '' # Icons: uF236 (ac-offline)
- self.ac_status = 'offline'
- response['color'] = i3status_config['color_bad']
- # Battery present
- with open(BAT_PRESENT, 'r') as bat_present_f:
- bat_present_c = bat_present_f.read()
- bat_m = one_p.match(bat_present_c)
- if bat_m.group(1):
- bat_text = ' ' # Icons: uF3CF (battery-vertical)
- self.bat_status = 'present'
- else:
- bat_text = ''
- self.bat_status = 'na'
- #
- response['full_text'] = '{0} {1}'.format(ac_text, bat_text)
- # cache status for 5 seconds
- response['cached_until'] = time.time() + 5
- return (POSITION, response)
-