Last active
January 31, 2021 17:24
-
-
Save syxanash/118032c14e49d0bbe28ce110588e6900 to your computer and use it in GitHub Desktop.
little scripts that checks when amazon dash is connected to wifi network
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Demo: