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
Expand Up @@ -7,8 +7,8 @@ battery = %w(ExternalConnected CurrentCapacity MaxCapacity IsCharging).inject({}
hash[property.to_sym] = info[/"#{property}" = (.*)$/, 1]; hash
end

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

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

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

output = "#{output} #{ "" if is_charging || is_plugged_in}"
output = color + "#{percentage}%"

puts output += reset

0 comments on commit 06fc76a

Please sign in to comment.