aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Fincham <michael@hotplate.co.nz>2017-01-17 10:09:18 +1300
committerGitHub <noreply@github.com>2017-01-17 10:09:18 +1300
commit69b9d1ab09c29246cc84c2d909227f7f6582d582 (patch)
treef0b8afb2121ff14ad44880234479b77651980ffd
parentcb432f0a217ac5e5ca5060af06ba91e5dd81cfb1 (diff)
downloadbattery-69b9d1ab09c29246cc84c2d909227f7f6582d582.tar.gz
battery-69b9d1ab09c29246cc84c2d909227f7f6582d582.tar.bz2
battery-69b9d1ab09c29246cc84c2d909227f7f6582d582.zip
Maybe there is no battery!
-rwxr-xr-xbattery10
1 files changed, 7 insertions, 3 deletions
diff --git a/battery b/battery
index e908b33..38f6a9b 100755
--- a/battery
+++ b/battery
@@ -48,9 +48,13 @@ if __name__ == '__main__':
state = device.get_state()
percentage = round(device.get_property('Percentage'))
- m = divmod(device.get_time(), 60)[0]
- h, m = divmod(m, 60)
- time = " %i:%i" % (h, m)
+ time = device.get_time()
+ if time:
+ m = divmod(device.get_time(), 60)[0]
+ h, m = divmod(m, 60)
+ time = " %i:%i" % (h, m)
+ else:
+ time = ''
print("%s %s%%%s" % (state, percentage, time))