mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-04-24 23:47:20 +00:00
edited update netdevice
This commit is contained in:
parent
e04430e36c
commit
9f392c3a19
@ -116,6 +116,7 @@ class pyTextWidget(plasmascript.Applet):
|
||||
self.ptm['dataengine']['system'], SLOT("forceImmediateUpdateOfAllVisualizations()"))
|
||||
QObject.connect(self.ptmActions['update'], SIGNAL("triggered(bool)"),
|
||||
self.ptm['dataengine']['time'], SLOT("forceImmediateUpdateOfAllVisualizations()"))
|
||||
QObject.connect(self.ptmActions['update'], SIGNAL("triggered(bool)"), self.updateNetdev)
|
||||
|
||||
|
||||
def contextualActions(self):
|
||||
@ -311,6 +312,11 @@ class pyTextWidget(plasmascript.Applet):
|
||||
self.updateTooltip()
|
||||
|
||||
|
||||
def updateNetdev(self):
|
||||
"""function to update netdev"""
|
||||
self.ptm['names']['net'] = self.setNetdev()
|
||||
|
||||
|
||||
def updateTooltip(self):
|
||||
"""function to update tooltip"""
|
||||
self.tooltipView.resize(100.0*(len(self.ptm['vars']['tooltip']['required']) - self.ptm['vars']['tooltip']['required'].count('up')), 100.0)
|
||||
@ -597,8 +603,7 @@ class pyTextWidget(plasmascript.Applet):
|
||||
def reInit(self):
|
||||
"""function to run reinit"""
|
||||
self.reinit.reinit()
|
||||
if (self.ptm['vars']['adv']['netdevBool'] == 0):
|
||||
self.ptm['names']['net'] = self.setNetdev()
|
||||
self.updateNetdev()
|
||||
self.resize(10, 10)
|
||||
|
||||
# create dataengines
|
||||
@ -611,18 +616,19 @@ class pyTextWidget(plasmascript.Applet):
|
||||
|
||||
def setNetdev(self):
|
||||
"""function to set network device"""
|
||||
if (self.ptm['vars']['adv']['netdevBool'] > 0):
|
||||
return self.ptm['vars']['adv']['netdev']
|
||||
netdev = "lo"
|
||||
netdir = self.ptm['vars']['adv']['netDir']
|
||||
interfaces = QDir.entryList(QDir(netdir), QDir.Dirs | QDir.NoDotAndDotDot)
|
||||
for device in interfaces:
|
||||
if (str(device) != "lo"):
|
||||
#try:
|
||||
if True:
|
||||
try:
|
||||
with open(netdir + '/' + str(device) + '/operstate', 'r') as stateFile:
|
||||
if (stateFile.readline() == "up\n"):
|
||||
netdev = str(device)
|
||||
#except:
|
||||
#pass
|
||||
except:
|
||||
pass
|
||||
return netdev
|
||||
|
||||
|
||||
|
@ -45,6 +45,7 @@ class Reinit():
|
||||
ptmVars['adv']['customTime'] = str(settings.get('custom_time', '$hh:$mm'))
|
||||
ptmVars['adv']['customUptime'] = str(settings.get('custom_uptime', '$dd,$hh,$mm'))
|
||||
ptmVars['adv']['netdevBool'] = settings.get('netdevBool', 0).toInt()[0]
|
||||
ptmVars['adv']['netdev'] = str(settings.get('custom_netdev', 'lo'))
|
||||
ptmVars['adv']['netDir'] = str(settings.get('netdir', '/sys/class/net'))
|
||||
ptmVars['adv']['player'] = str(settings.get('player_name', "amarok"))
|
||||
|
||||
@ -74,10 +75,6 @@ class Reinit():
|
||||
ptmNames['disk'] = str(settings.get('disk', 'disk/sda_(8:0)')).split('@@')
|
||||
ptmNames['hdd'] = str(settings.get('mount', '/')).split('@@')
|
||||
ptmNames['hddtemp'] = str(settings.get('hdd', '/dev/sda')).split('@@')
|
||||
if (ptmVars['adv']['netdevBool'] > 0):
|
||||
ptmNames['net'] = str(settings.get('custom_netdev', 'lo'))
|
||||
else:
|
||||
ptmNames['net'] = ""
|
||||
ptmNames['temp'] = str(settings.get('temp_device', '')).split('@@')
|
||||
self.parent.applySettings('names', ptmNames)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user