Last active
February 16, 2023 03:59
-
-
Save apiarian/23e1d06f67345525bd976616b0aa659a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
pingcheck = hs.menubar.new() | |
function pingUpdate() | |
pingcheck:setTitle('⥌'..pingcheck:title()) | |
local p = hs.network.ping('example.com', 3) | |
hs.timer.doAfter(4, function() | |
p:cancel() | |
local avg = p:summary():match('%/(%d+)%.%d+%/') | |
if avg == nil or avg == '0' then | |
pingcheck:setTitle('∞') | |
else | |
pingcheck:setTitle(avg..'ms') | |
end | |
end) | |
end | |
pingcheck:setTitle('ping') | |
hs.timer.doEvery(5, pingUpdate) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment