Module: Bluemoon

Defined in:
lib/bluemoon.rb,
lib/bluemoon/area.rb,
lib/bluemoon/help.rb,
lib/bluemoon/notify.rb,
lib/bluemoon/version.rb,
lib/bluemoon/location.rb,
lib/bluemoon/bluetooth.rb

Defined Under Namespace

Classes: Area, Bluetooth, Help, Location, Notify

Constant Summary collapse

VERSION =
'0.0.1'

Class Method Summary collapse

Class Method Details

.bootupObject



8
9
10
# File 'lib/bluemoon.rb', line 8

def self.bootup
  system "sleepwatcher --displaywakeup 'bluemoon run'"
end

.runObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/bluemoon.rb', line 12

def self.run
  # We disable Bluetooth up here,
  # because disabling it helps us connect to wifi faster
  just_disabled = Bluetooth.off

  if Area.all.any? { |area| area.contains?(Location.current) }
    Bluetooth.on

    just_disabled or  Notify.success('Enabling Bluetooth')
  else
    just_disabled and Notify.success('Disabling Bluetooth')
  end
rescue
  Bluetooth.on
  Notify.handle($!)
end