Skip to content

Instantly share code, notes, and snippets.

@alexandregz
Created January 12, 2016 14:50
Show Gist options
  • Save alexandregz/9b5007853833c83e39fe to your computer and use it in GitHub Desktop.
Save alexandregz/9b5007853833c83e39fe to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# <bitbar.title>Battery Apple Bluetooth keyboard</bitbar.title>
# <bitbar.version>1.0</bitbar.version>
# <bitbar.author>Alexandre Espinosa Menor</bitbar.author>
# <bitbar.author.github>alexandregz</bitbar.author.github>
# <bitbar.desc>Show vagrant images running, from vagrant global-status command</bitbar.desc>
#
# command from https://github.com/matryer/bitbar-plugins/issues/84 by @keithamus
#
require 'yaml'
output = YAML.load(`system_profiler SPBluetoothDataType`);
output['Bluetooth']['Devices (Paired, Configured, etc.)'].each do |device|
puts "Keyboard: "+device[1]['Battery Level'].to_s if device[1]['Minor Type'].eql?('Keyboard') && device[1].has_key?('Battery Level')
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment