mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-04-25 07:57:19 +00:00
Added notification for gpu/gputemp
This commit is contained in:
parent
d5a91f566e
commit
1dd3d4090c
3
TODO
3
TODO
@ -1,7 +1,4 @@
|
|||||||
1. Notification on left click (system information):
|
1. Notification on left click (system information):
|
||||||
b) cpu, cpuclock, temp - cpu, cpuclock, temp, processor information
|
|
||||||
c) gpu, gputemp - gpu, gpu temp, gpu information
|
|
||||||
d) memory, swap - memory, swap, memory information
|
|
||||||
e) hdd, hddtemp - hdd, hddtemp, disk information
|
e) hdd, hddtemp - hdd, hddtemp, disk information
|
||||||
f) network - speed, network information
|
f) network - speed, network information
|
||||||
g) battery - battery, ac, acpi information
|
g) battery - battery, ac, acpi information
|
||||||
|
@ -13,6 +13,11 @@ Name=Processor information
|
|||||||
Comment=Processor information
|
Comment=Processor information
|
||||||
Action=Popup
|
Action=Popup
|
||||||
|
|
||||||
|
[Event/graphical]
|
||||||
|
Name=GPU information
|
||||||
|
Comment=GPU information
|
||||||
|
Action=Popup
|
||||||
|
|
||||||
[Event/memory]
|
[Event/memory]
|
||||||
Name=Memory information
|
Name=Memory information
|
||||||
Comment=Memory information
|
Comment=Memory information
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
from PyKDE4.kdecore import KComponentData
|
from PyKDE4.kdecore import KComponentData
|
||||||
from PyKDE4.kdeui import KNotification
|
from PyKDE4.kdeui import KNotification
|
||||||
|
from PyKDE4.plasma import Plasma
|
||||||
import commands
|
import commands
|
||||||
|
|
||||||
|
|
||||||
@ -29,10 +30,8 @@ class PTMNotify:
|
|||||||
|
|
||||||
def createText(self, type):
|
def createText(self, type):
|
||||||
"""function to create text"""
|
"""function to create text"""
|
||||||
content = []
|
|
||||||
if (type == "system"):
|
|
||||||
content.append("system")
|
|
||||||
text = ""
|
text = ""
|
||||||
|
if (type == "system"):
|
||||||
try:
|
try:
|
||||||
text = text + "Kernel: " + commands.getoutput("uname -rsm") + "\n"
|
text = text + "Kernel: " + commands.getoutput("uname -rsm") + "\n"
|
||||||
text = text + "Hostname: " + commands.getoutput("uname -n") + "\n"
|
text = text + "Hostname: " + commands.getoutput("uname -n") + "\n"
|
||||||
@ -40,10 +39,7 @@ class PTMNotify:
|
|||||||
text = text + "Uptime: " + commands.getoutput("uptime")
|
text = text + "Uptime: " + commands.getoutput("uptime")
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
content.append(text)
|
|
||||||
elif (type == "processor"):
|
elif (type == "processor"):
|
||||||
content.append("processor")
|
|
||||||
text = ""
|
|
||||||
try:
|
try:
|
||||||
output = commands.getoutput("grep 'model name' /proc/cpuinfo | head -1")
|
output = commands.getoutput("grep 'model name' /proc/cpuinfo | head -1")
|
||||||
text = text + "Model: " + ' '.join(output.split()[3:]) + "\n"
|
text = text + "Model: " + ' '.join(output.split()[3:]) + "\n"
|
||||||
@ -58,8 +54,60 @@ class PTMNotify:
|
|||||||
text = text + " " + str(round(float(line.split()[-1]), 0)) + "\xb0C"
|
text = text + " " + str(round(float(line.split()[-1]), 0)) + "\xb0C"
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
content.append(text)
|
elif (type == "graphical"):
|
||||||
|
try:
|
||||||
|
output = commands.getoutput("lspci -m | grep 'VGA\|3D'")
|
||||||
|
if (output.lower().find('nvidia') > -1):
|
||||||
|
gpudev = "nvidia"
|
||||||
|
elif (output.lower().find('radeon') > -1):
|
||||||
|
gpudev = "ati"
|
||||||
|
for line in output.split("\n"):
|
||||||
|
text = text + line.split('"')[0] + " "
|
||||||
|
text = text + line.split('"')[5] + "\n"
|
||||||
|
if (gpudev == 'nvidia'):
|
||||||
|
output = commands.getoutput("nvidia-smi -q -d UTILIZATION | grep Gpu | tail -n1")
|
||||||
|
try:
|
||||||
|
value = "%5s" % (str(round(float(output.split()[2][:-1]), 1)))
|
||||||
|
except:
|
||||||
|
value = " N\A"
|
||||||
|
elif (gpudev == 'ati'):
|
||||||
|
output = commands.getoutput("aticonfig --od-getclocks | grep load | tail -n1")
|
||||||
|
try:
|
||||||
|
value = "%5s" % (str(round(float(output.split()[3][:-1]), 1)))
|
||||||
|
except:
|
||||||
|
value = " N\A"
|
||||||
|
else:
|
||||||
|
value = " N\A"
|
||||||
|
text = text + "Load: " + value + "%\n"
|
||||||
|
if (gpudev == 'nvidia'):
|
||||||
|
output = commands.getoutput("nvidia-smi -q -d TEMPERATURE | grep Gpu | tail -n1")
|
||||||
|
try:
|
||||||
|
value = "%5s" % (str(round(float(output.split()[2][:-1]), 1)))
|
||||||
|
except:
|
||||||
|
value = " N\A"
|
||||||
|
elif (gpudev == 'ati'):
|
||||||
|
output = commands.getoutput("aticonfig --od-gettemperature | grep Temperature | tail -n1")
|
||||||
|
try:
|
||||||
|
value = "%5s" % (str(round(float(output.split()[3][:-1]), 1)))
|
||||||
|
except:
|
||||||
|
value = " N\A"
|
||||||
|
else:
|
||||||
|
value = " N\A"
|
||||||
|
text = text + "Temp: " + value + "\xb0C"
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
elif (type == "memory"):
|
||||||
|
try:
|
||||||
|
output = commands.getoutput("free -mo").split("\n")
|
||||||
|
memusage = int(output[1].split()[1]) - (int(output[1].split()[3]) + int(output[1].split()[5]) + int(output[1].split()[6]))
|
||||||
|
text = text + "Memory: " + str(memusage) + " of " + output[1].split()[1] + " (" + str(int(100*memusage/int(output[1].split()[1]))) + "%)\n"
|
||||||
|
text = text + "Swap: " + output[2].split()[2] + " of " + output[2].split()[1] + " (" + str(int(100*int(output[2].split()[2])/int(output[2].split()[1]))) + "%)\n"
|
||||||
|
output = commands.getoutput("swapon --show").split("\n")
|
||||||
|
text = text + "Swap Device: " + output[1].split()[0] + " (" + output[1].split()[1] + ")"
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
content = [type, text]
|
||||||
return content
|
return content
|
||||||
|
|
||||||
|
|
||||||
@ -115,13 +163,13 @@ class PTMNotify:
|
|||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
if (sender == self.parent.parent.label_hdd0):
|
if (sender == self.parent.parent.label_hdd0):
|
||||||
content = self.createText("hdd")
|
content = self.createText("disk")
|
||||||
return content
|
return content
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
if (sender == self.parent.parent.label_hddtemp):
|
if (sender == self.parent.parent.label_hddtemp):
|
||||||
content = self.createText("hdd")
|
content = self.createText("disk")
|
||||||
return content
|
return content
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
@ -133,7 +181,7 @@ class PTMNotify:
|
|||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
if (sender == self.parent.parent.label_bat):
|
if (sender == self.parent.parent.label_bat):
|
||||||
content = self.createText("acpi")
|
content = self.createText("battery")
|
||||||
return content
|
return content
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
@ -19,6 +19,7 @@ class NewPlasmaLabel(Plasma.Label):
|
|||||||
|
|
||||||
def mousePressEvent(self, event):
|
def mousePressEvent(self, event):
|
||||||
"""mouse click event"""
|
"""mouse click event"""
|
||||||
|
if (event.button() == Qt.LeftButton):
|
||||||
self.notify.init()
|
self.notify.init()
|
||||||
|
|
||||||
|
|
||||||
@ -220,7 +221,7 @@ class Reinit():
|
|||||||
elif (order == "9"):
|
elif (order == "9"):
|
||||||
if (self.parent.gpuBool > 0):
|
if (self.parent.gpuBool > 0):
|
||||||
self.parent.gpuFormat = str(settings.get('gpuFormat', '[gpu: $gpu%]'))
|
self.parent.gpuFormat = str(settings.get('gpuFormat', '[gpu: $gpu%]'))
|
||||||
self.parent.label_gpu = Plasma.Label(self.parent.applet)
|
self.parent.label_gpu = NewPlasmaLabel(self.parent.applet, self.parent)
|
||||||
if (self.parent.gpuFormat.split('$gpu')[0] != self.parent.gpuFormat):
|
if (self.parent.gpuFormat.split('$gpu')[0] != self.parent.gpuFormat):
|
||||||
line = self.parent.gpuFormat.split('$gpu')[0] + '-----' + self.parent.gpuFormat.split('$gpu')[1]
|
line = self.parent.gpuFormat.split('$gpu')[0] + '-----' + self.parent.gpuFormat.split('$gpu')[1]
|
||||||
else:
|
else:
|
||||||
@ -231,7 +232,7 @@ class Reinit():
|
|||||||
elif (order == "a"):
|
elif (order == "a"):
|
||||||
if (self.parent.gputempBool > 0):
|
if (self.parent.gputempBool > 0):
|
||||||
self.parent.gputempFormat = str(settings.get('gputempFormat', '[gpu temp: $gputemp°C]'))
|
self.parent.gputempFormat = str(settings.get('gputempFormat', '[gpu temp: $gputemp°C]'))
|
||||||
self.parent.label_gputemp = Plasma.Label(self.parent.applet)
|
self.parent.label_gputemp = NewPlasmaLabel(self.parent.applet, self.parent)
|
||||||
if (self.parent.gputempFormat.split('$gputemp')[0] != self.parent.gputempFormat):
|
if (self.parent.gputempFormat.split('$gputemp')[0] != self.parent.gputempFormat):
|
||||||
line = self.parent.gputempFormat.split('$gputemp')[0] + '----' + self.parent.gputempFormat.split('$gputemp')[1]
|
line = self.parent.gputempFormat.split('$gputemp')[0] + '----' + self.parent.gputempFormat.split('$gputemp')[1]
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user