Module: Caff
- Defined in:
- lib/caff.rb,
lib/caff/version.rb
Constant Summary collapse
- VERSION =
"0.0.2"
Instance Method Summary collapse
Instance Method Details
#execute(on_off) ⇒ Object
2 3 4 5 6 7 8 9 |
# File 'lib/caff.rb', line 2 def execute on_off if %w{on off}.include? on_off tell_caffeine "turn #{on_off}" else puts 'usage: caff [on|off]' end show_status end |
#show_status ⇒ Object
11 12 13 14 |
# File 'lib/caff.rb', line 11 def show_status current = tell_caffeine('active') == 'true' ? 'on' : 'off' puts "caffeine is now #{current}" end |
#tell_caffeine(command) ⇒ Object
16 17 18 |
# File 'lib/caff.rb', line 16 def tell_caffeine command `osascript -e 'tell application \"Caffeine\" to #{command}'`.chomp end |