forked from herrbischoff/nerdbar.widget
-
Notifications
You must be signed in to change notification settings - Fork 0
/
battery.coffee
39 lines (34 loc) · 894 Bytes
/
battery.coffee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
command: "pmset -g batt | egrep '([0-9]+\%).*' -o --colour=auto | cut -f1 -d';'"
refreshFrequency: 15000 # ms
render: (output) ->
"""
<link rel="stylesheet" href="./assets/font-awesome/css/font-awesome.min.css" />
<div class="battery"
<span></span>
<span class="icon"></span>
</div>
"""
update: (output, el) ->
bat = parseInt(output)
$(".battery span:first-child", el).text(" #{output}")
$icon = $(".battery span.icon", el)
$icon.removeClass().addClass("icon")
$icon.addClass("fa #{@icon(bat)}")
icon: (output) =>
return if output > 90
"fa-battery-full"
else if output > 70
"fa-battery-three-quarters"
else if output > 40
"fa-battery-half"
else if output > 20
"fa-battery-quarter"
else
"fa-battery-empty"
style: """
-webkit-font-smoothing: antialiased
font: 12px Input
top: 6px
right: 160px
color: #f7ca88
"""