Signed-off-by: Jeroen Oudshoorn <oudshoorn.jeroen@gmail.com>
This commit is contained in:
Jeroen Oudshoorn
2023-09-18 09:17:01 +02:00
parent d550427756
commit 6145655c66

View File

@ -35,13 +35,12 @@ class InternetConnectionPlugin(plugins.Plugin):
text_font=fonts.Small))
def on_ui_update(self, ui):
with ui._lock:
# check if there is an active Internet connection
try:
# use the 'ping' command to check if we can reach a well-known website
output = subprocess.check_output(['ping', '-c', '1', 'google.com'])
# if the command was successful, it means there is an active Internet connection
ui.set('connection_status', ' connected')
except subprocess.CalledProcessError:
# if the command failed, it means there is no active Internet connection
ui.set('connection_status', ' disconnected')
# check if there is an active Internet connection
try:
# use the 'ping' command to check if we can reach a well-known website
output = subprocess.check_output(['ping', '-c', '1', 'google.com'])
# if the command was successful, it means there is an active Internet connection
ui.set('connection_status', ' connected')
except subprocess.CalledProcessError:
# if the command failed, it means there is no active Internet connection
ui.set('connection_status', ' disconnected')