mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-04-24 23:47:20 +00:00
Added network, hdd/hddtemp and battery notification
This commit is contained in:
parent
1dd3d4090c
commit
d55d478243
6
TODO
6
TODO
@ -1,8 +1,4 @@
|
|||||||
1. Notification on left click (system information):
|
1. Tooltip (graphical information):
|
||||||
e) hdd, hddtemp - hdd, hddtemp, disk information
|
|
||||||
f) network - speed, network information
|
|
||||||
g) battery - battery, ac, acpi information
|
|
||||||
2. Tooltip (graphical information):
|
|
||||||
a) cpu, %
|
a) cpu, %
|
||||||
b) cpuclock, mhz
|
b) cpuclock, mhz
|
||||||
c) memory, %
|
c) memory, %
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
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
|
||||||
|
|
||||||
|
|
||||||
@ -33,25 +32,25 @@ class PTMNotify:
|
|||||||
text = ""
|
text = ""
|
||||||
if (type == "system"):
|
if (type == "system"):
|
||||||
try:
|
try:
|
||||||
text = text + "Kernel: " + commands.getoutput("uname -rsm") + "\n"
|
text = text + "Kernel: %s\n" %(commands.getoutput("uname -rsm"))
|
||||||
text = text + "Hostname: " + commands.getoutput("uname -n") + "\n"
|
text = text + "Hostname: %s\n" %(commands.getoutput("uname -n"))
|
||||||
text = text + "Whoami: " + commands.getoutput("whoami") + "\n"
|
text = text + "Whoami: %s\n" %(commands.getoutput("whoami"))
|
||||||
text = text + "Uptime: " + commands.getoutput("uptime")
|
text = text + "Uptime: %s\n" %(commands.getoutput("uptime"))
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
elif (type == "processor"):
|
elif (type == "processor"):
|
||||||
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: %s\n" %(' '.join(output.split()[3:]))
|
||||||
output = commands.getoutput("sar -u | tail -1")
|
output = commands.getoutput("sar -u | tail -1")
|
||||||
text = text + "CPU Usage: " + str(100-float(output[-1])) + "%\n"
|
text = text + "CPU Usage: %s%%\n" %(str(100-float(output.split()[-1])))
|
||||||
output = commands.getoutput("grep MHz /proc/cpuinfo | head -1")
|
output = commands.getoutput("grep MHz /proc/cpuinfo | head -1")
|
||||||
text = text + "CPU Freq: " + str(int(float(output.split()[-1]))) + " MHz\n"
|
text = text + "CPU Freq: %s MHz\n" %(str(int(float(output.split()[-1]))))
|
||||||
output = commands.getoutput("sensors -u")
|
output = commands.getoutput("sensors -u")
|
||||||
text = text + "Temps:"
|
text = text + "Temps:"
|
||||||
for line in output.split("\n"):
|
for line in output.split("\n"):
|
||||||
if (line.find("_input") > -1):
|
if (line.find("_input") > -1):
|
||||||
text = text + " " + str(round(float(line.split()[-1]), 0)) + "\xb0C"
|
text = text + " %s\xb0C" %(str(round(float(line.split()[-1]), 0)))
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
elif (type == "graphical"):
|
elif (type == "graphical"):
|
||||||
@ -62,8 +61,7 @@ class PTMNotify:
|
|||||||
elif (output.lower().find('radeon') > -1):
|
elif (output.lower().find('radeon') > -1):
|
||||||
gpudev = "ati"
|
gpudev = "ati"
|
||||||
for line in output.split("\n"):
|
for line in output.split("\n"):
|
||||||
text = text + line.split('"')[0] + " "
|
text = text + "%s %s\n" %(line.split('"')[0], line.split('"')[5])
|
||||||
text = text + line.split('"')[5] + "\n"
|
|
||||||
if (gpudev == 'nvidia'):
|
if (gpudev == 'nvidia'):
|
||||||
output = commands.getoutput("nvidia-smi -q -d UTILIZATION | grep Gpu | tail -n1")
|
output = commands.getoutput("nvidia-smi -q -d UTILIZATION | grep Gpu | tail -n1")
|
||||||
try:
|
try:
|
||||||
@ -78,7 +76,7 @@ class PTMNotify:
|
|||||||
value = " N\A"
|
value = " N\A"
|
||||||
else:
|
else:
|
||||||
value = " N\A"
|
value = " N\A"
|
||||||
text = text + "Load: " + value + "%\n"
|
text = text + "Load: %s%%\n" %(value)
|
||||||
if (gpudev == 'nvidia'):
|
if (gpudev == 'nvidia'):
|
||||||
output = commands.getoutput("nvidia-smi -q -d TEMPERATURE | grep Gpu | tail -n1")
|
output = commands.getoutput("nvidia-smi -q -d TEMPERATURE | grep Gpu | tail -n1")
|
||||||
try:
|
try:
|
||||||
@ -93,17 +91,45 @@ class PTMNotify:
|
|||||||
value = " N\A"
|
value = " N\A"
|
||||||
else:
|
else:
|
||||||
value = " N\A"
|
value = " N\A"
|
||||||
text = text + "Temp: " + value + "\xb0C"
|
text = text + "Temp: %s\xb0C\n" %(value)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
elif (type == "memory"):
|
elif (type == "memory"):
|
||||||
try:
|
try:
|
||||||
output = commands.getoutput("free -mo").split("\n")
|
output = commands.getoutput("free -m -o").split("\n")
|
||||||
memusage = int(output[1].split()[1]) - (int(output[1].split()[3]) + int(output[1].split()[5]) + int(output[1].split()[6]))
|
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 + "Memory: %s of %s (%s%%)\n" %(str(memusage), output[1].split()[1], str(int(100*memusage/int(output[1].split()[1]))))
|
||||||
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"
|
text = text + "Swap: %s of %s (%s%%)\n" %(output[2].split()[2], output[2].split()[1], str(int(100*int(output[2].split()[2])/int(output[2].split()[1]))))
|
||||||
output = commands.getoutput("swapon --show").split("\n")
|
output = commands.getoutput("swapon --show").split("\n")
|
||||||
text = text + "Swap Device: " + output[1].split()[0] + " (" + output[1].split()[1] + ")"
|
text = text + "Swap Device: %s (%s)" %(output[1].split()[0], output[1].split()[1])
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
elif (type == "disk"):
|
||||||
|
try:
|
||||||
|
output = commands.getoutput("df -h --output='source,target,used,size,pcent' --exclude-type=fuseblk --exclude-type=tmpfs --exclude-type=devtmpfs").split("\n")[1:]
|
||||||
|
for line in output:
|
||||||
|
text = text + "%s (to %s): %s of %s (%s)\n" %(line.split()[0], line.split()[1], line.split()[2], line.split()[3], line.split()[4])
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
elif (type == "network"):
|
||||||
|
try:
|
||||||
|
output = commands.getoutput("ifconfig -a -s").split("\n")[1:]
|
||||||
|
text = text + "Devices:"
|
||||||
|
for line in output:
|
||||||
|
text = text + " %s" %(line.split()[0])
|
||||||
|
output = commands.getoutput("ifconfig -a -s " + self.parent.parent.netdev + " && sleep 0.2 && ifconfig -a -s " + self.parent.parent.netdev).split("\n")
|
||||||
|
download = int((int(output[3].split()[2]) - int(output[1].split()[2])) / (0.2 * 1024))
|
||||||
|
upload = int((int(output[3].split()[6]) - int(output[1].split()[6])) / (0.2 * 1024))
|
||||||
|
text = text + "\n%s: %s/%s KB/s\n" %(self.parent.parent.netdev, download, upload)
|
||||||
|
output = commands.getoutput("ifconfig " + self.parent.parent.netdev + " | grep 'inet '").split()[1]
|
||||||
|
text = text + "IP: %s\n" %(output[:-1])
|
||||||
|
output = commands.getoutput("wget http://checkip.dyndns.org/ -q -O - | awk '{print $6}' | sed 's/<.*>//g'")
|
||||||
|
text = text + "External IP: %s" %(output[:-1])
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
elif (type == "battery"):
|
||||||
|
try:
|
||||||
|
text = text + "%s" %(commands.getoutput("acpi -abi"))
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user