diff --git a/themes/twain/charge.py b/themes/twain/charge.py index 5c492f12..28d49f09 100755 --- a/themes/twain/charge.py +++ b/themes/twain/charge.py @@ -7,23 +7,27 @@ import sys """ Config """ output_length = 10 -hide_when_charge_is_above = 95 +hide_when_charge_is_above = 90 blank_when_battery_full = True filled_char, empty_char = u'▪', u'▫' """ Read battery charge """ def read_battery_percent (sp, regex): + """ Reads the battery charge as an integer between 0 and 100, using a given process and regex. """ import subprocess, re process = subprocess.Popen(sp, stdout=subprocess.PIPE) output = process.communicate()[0].strip() - return int(re.search(regex,output).group(1)) + return int(re.search(regex, output, re.MULTILINE).group(1)) if sys.platform.startswith('darwin'): - """ Reads the battery charge as an integer between 0 and 100, using 'pmset -g batt' """ - charge = read_battery_percent(["pmset", "-g", "batt"], "^.+([\d]+)\%") + """ OSX - 'pmset -g batt' """ + charge = read_battery_percent(["pmset", "-g", "batt"], "^.+\t([\d]+)\%") +elif sys.platform.startswith('freebsd'): + """ Freebsd - 'acpiconf -i 0' """ + charge = read_battery_percent(["acpiconf", "-i", "0"], "") else: - """ Reads the battery charge as an integer between 0 and 100, using 'acpi -b' """ + """ Linux - 'acpi -b' """ charge = read_battery_percent(["acpi", "-b"], "^Battery 0: .+, ([\d]+)\%") """ Output """ diff --git a/themes/twain/prompt_twain_setup b/themes/twain/prompt_twain_setup index e25de9a9..ca6b9950 100644 --- a/themes/twain/prompt_twain_setup +++ b/themes/twain/prompt_twain_setup @@ -1,11 +1,22 @@ # -# A light theme showing only the needed information. +# A light theme showing only minimal information in colour: +# - Current directory, optionally prefixed with the user and host +# - Git repo and branch, with markers for staged and unstaged changes. +# - Battery change meter on the right, with colour based on charge, +# and only appearing when battery is below 90% charge. # # Authors: # Samuel Clements # -# Screenshot: -# http://i.imgur.com/JSFRj.png +# Screenshots: +# http://misc.borntyping.co.uk/twain-screenshots/Twain.png +# +# http://misc.borntyping.co.uk/twain-screenshots/Repo.png +# http://misc.borntyping.co.uk/twain-screenshots/Repo%20%28with%20markers%29.png +# +# http://misc.borntyping.co.uk/twain-screenshots/Charge25.png +# http://misc.borntyping.co.uk/twain-screenshots/Charge50.png +# http://misc.borntyping.co.uk/twain-screenshots/Charge75.png # function battery_charge {