Skip to content

Instantly share code, notes, and snippets.

@dettmering
Created January 30, 2019 08:12
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dettmering/49ae72611d0f63e87ceb86f1521ee88d to your computer and use it in GitHub Desktop.
Save dettmering/49ae72611d0f63e87ceb86f1521ee88d to your computer and use it in GitHub Desktop.
BitBar plugin for showing host availability
#!/usr/local/bin/python3
import os
hosts = [
'google.com',
'microsoft.com'
]
header = []
menu = []
for host in hosts:
response = os.system("ping -c 1 -t 1 " + host + " > /dev/null 2>&1")
if response == 0:
menu.append('💚 ' + host)
header.append('💚')
else:
menu.append('💔 ' + host)
header.append('💔')
print(''.join(header))
print('---')
for entry in menu:
print(entry)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment