Created
January 4, 2016 10:11
-
-
Save flou/2238f3ff0c2583319cfe to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
settings = | |
lang: 'fr' | |
# Locale Strings | |
locale = | |
en: | |
weekdays: [ | |
'Sunday' | |
'Monday' | |
'Tuesday' | |
'Wednesday' | |
'Thursday' | |
'Friday' | |
'Saturday' | |
] | |
months: [ | |
'January' | |
'February' | |
'March' | |
'April' | |
'May' | |
'June' | |
'July' | |
'August' | |
'September' | |
'October' | |
'November' | |
'December' | |
] | |
fr: | |
weekdays: [ | |
'dimanche' | |
'lundi' | |
'mardi' | |
'mercredi' | |
'jeudi' | |
'vendredi' | |
'samedi' | |
] | |
months: [ | |
'janvier' | |
'février' | |
'mars' | |
'avril' | |
'mai' | |
'juin' | |
'juillet' | |
'août' | |
'septembre' | |
'octobre' | |
'novembre' | |
'décembre' | |
] | |
command: """ | |
ps aux | awk 'BEGIN { sum = 0 } { sum += $4 }; END { print sum }' && | |
ps aux | awk 'BEGIN { sum = 0 } { sum += $3 }; END { print sum }' && | |
pmset -g batt | egrep "([0-9]+\%).*" -o | awk -F ';' '{ print $1 } ' | |
""" | |
settings: settings | |
locale: locale | |
refreshFrequency: 10000 # ms | |
style: """ | |
.menubar | |
font-family: Source Code Pro | |
line-height: 1.2em | |
font-size: 1.1em | |
width: 100% | |
position: fixed | |
.menubar .item | |
padding: 0 1em | |
float: right | |
.time | |
color: #569497 | |
.date | |
color: #bf7a98 | |
.battery | |
color: #999 | |
.battery .value | |
color: #fbc64b | |
.cpu_usage | |
color: #999 | |
.cpu_usage .value | |
color: #7aaa7a | |
.memory_usage | |
color: #999 | |
.memory_usage .value | |
color: #a39588 | |
""" | |
render: () -> """ | |
<div class="menubar"> | |
<div class="filler item"> </div> | |
<div class="time item"></div> | |
<div class="date item"></div> | |
<div class="battery item"> | |
pwr <span class="value"></span> | |
</div> | |
<div class="memory_usage item"> | |
mem <span class="value"></span> | |
</div> | |
<div class="cpu_usage item"> | |
cpu <span class="value"></span> | |
</div> | |
</div> | |
""" | |
update: (output, domEl) -> | |
outputs = output.split('\n') | |
$(domEl).find(".time").text(@getTime()) | |
$(domEl).find(".date").text(@getDate()) | |
$(domEl).find(".memory_usage .value").text(outputs[0]) | |
$(domEl).find(".cpu_usage .value").text(outputs[1]) | |
$(domEl).find(".battery .value").text(outputs[2]) | |
# Helper-Functions | |
zeroFill: (value) -> | |
return ('0' + value).slice(-2) | |
getDate: () -> | |
date = new Date() | |
weekday = @locale[@settings.lang].weekdays[date.getDay()] | |
day = @zeroFill(date.getDate()) | |
month = @locale[@settings.lang].months[date.getMonth()] | |
weekday + " " + day + " " + month | |
getTime: () -> | |
date = new Date() | |
hours = @zeroFill(date.getHours()) | |
minutes = @zeroFill(date.getMinutes()) | |
hours + ":" + minutes |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment