1414
1515UPDATE_INTERVAL_MS = 5000
1616
17- currpath = os .path .dirname (os .path .realpath (__file__ ))
18- APP_NETWORK_ON = currpath + '/gtk-connect.svg'
19- APP_NETWORK_OFF = currpath + '/gtk-disconnect.svg'
2017COLLATE = "utf-8"
2118STATUS_UP = "up"
2219STATUS_DOWN = "down"
2320
21+ currpath = os .path .dirname (os .path .realpath (__file__ ))
22+ FALLBACK_APP_NETWORK_ON = currpath + '/gtk-connect.svg'
23+ FALLBACK_APP_NETWORK_OFF = currpath + '/gtk-disconnect.svg'
24+
25+
26+ def get_current_icon_theme ():
27+ return Gtk .Settings .get_default ().get_property ("gtk-icon-theme-name" )
28+
29+
30+ def set_icons ():
31+ theme = get_current_icon_theme ()
32+ iconpath = "/usr/share/icons/" + theme + "/scalable/status/"
33+ APP_NETWORK_ON = iconpath + 'network-idle.svg'
34+ APP_NETWORK_OFF = iconpath + 'network-offline.svg'
35+ if os .path .exists (APP_NETWORK_ON ) and os .path .exists (APP_NETWORK_OFF ):
36+ return APP_NETWORK_ON , APP_NETWORK_OFF
37+ else :
38+ return FALLBACK_APP_NETWORK_ON , FALLBACK_APP_NETWORK_OFF
39+
2440
2541def get_ifaces ():
2642 i = os .listdir ("/sys/class/net/" )
@@ -29,6 +45,7 @@ def get_ifaces():
2945
3046
3147def update ():
48+ APP_NETWORK_ON , APP_NETWORK_OFF = set_icons ()
3249 ADDRINFO = []
3350 n_up = 0
3451 for IFACE in IFACES :
@@ -52,6 +69,7 @@ def update():
5269
5370
5471if __name__ == "__main__" :
72+ APP_NETWORK_ON , APP_NETWORK_OFF = set_icons ()
5573 icon = Gtk .StatusIcon ()
5674 icon .set_from_file (APP_NETWORK_OFF )
5775 icon .set_visible (True )
0 commit comments