Created
November 25, 2016 20:19
-
-
Save artursapek/cc06685e6bf3968838b082093717038c to your computer and use it in GitHub Desktop.
This file contains 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
# for tmux status bar | |
info = `pmset -g batt`.split("\n") | |
perc = info[1].split(" ")[1].gsub(";","") | |
charging = info[0].include? "AC Power" | |
as_f = perc.to_f | |
if as_f > 75 | |
status = "green" | |
bars = 4 | |
elsif as_f > 50 | |
status = "yellow" | |
bars = 3 | |
elsif as_f > 25 | |
status = "yellow" | |
bars = 2 | |
else | |
status = "red" | |
bars = 1 | |
end | |
if charging | |
status = "blue" | |
end | |
puts "#[fg=#{status}][#{"|" * bars}#{" " * (4 - bars)}] #{perc}#{charging ? "*":""}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment