Skip to content

Instantly share code, notes, and snippets.

@syxanash
Last active January 31, 2021 17:24
Show Gist options
  • Save syxanash/118032c14e49d0bbe28ce110588e6900 to your computer and use it in GitHub Desktop.
Save syxanash/118032c14e49d0bbe28ce110588e6900 to your computer and use it in GitHub Desktop.
little scripts that checks when amazon dash is connected to wifi network
require 'arp_scan'
# the following variables may need to be edited
dash_mac = '00:00:00:00:00:00'
interface = 'en0'
already_checked = false;
loop do
#puts "scanning network..."
is_online = false
report = ARPScan("-I #{interface} -l")
report.hosts.each do |host|
#puts "#{host.mac} with #{host.ip_addr}"
if host.mac == dash_mac
is_online = true
end
end
if is_online
if not already_checked
puts "dash button clicked!"
# you can place here the code you want to execute
# after you press the button. The following one is
# just an example
system('open https://www.youtube.com/watch?v=dQw4w9WgXcQ')
already_checked = true
end
else
already_checked = false
end
end
@syxanash
Copy link
Author

syxanash commented Feb 7, 2018

Demo:

K0ieTDvZpDA

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment