Skip to content

Commit

Permalink
No more apple
Browse files Browse the repository at this point in the history
  • Loading branch information
lucapette committed Mar 1, 2013
1 parent a5e93f3 commit 06fc76a
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions bin/battery
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ battery = %w(ExternalConnected CurrentCapacity MaxCapacity IsCharging).inject({}
hash[property.to_sym] = info[/"#{property}" = (.*)$/, 1]; hash hash[property.to_sym] = info[/"#{property}" = (.*)$/, 1]; hash
end end


percentage = (battery[:CurrentCapacity].to_f / battery[:MaxCapacity].to_f * 100).to_i percentage = (battery[:CurrentCapacity].to_f / battery[:MaxCapacity].to_f * 100).to_i
is_charging = battery[:IsCharging] == "Yes" is_charging = battery[:IsCharging] == "Yes"
is_plugged_in = battery[:ExternalConnected] == "Yes" is_plugged_in = battery[:ExternalConnected] == "Yes"


green = "#[fg=green]" green = "#[fg=green]"
Expand All @@ -28,8 +28,6 @@ if is_charging
color = yellow color = yellow
end end


output = color + "(#{percentage}%)" output = color + "#{percentage}%"

output = "#{output} #{ "" if is_charging || is_plugged_in}"


puts output += reset puts output += reset

0 comments on commit 06fc76a

Please sign in to comment.