diff --git a/.config/xfce4/panel/genmon-12.rc b/.config/xfce4/panel/genmon-12.rc index 5ebe96d..c781b32 100644 --- a/.config/xfce4/panel/genmon-12.rc +++ b/.config/xfce4/panel/genmon-12.rc @@ -1,4 +1,4 @@ -Command=/home/adam/.bin/netstatus.sh +Command=/home/adam/.config/xfce4/panel/scripts/netstatus.sh UseLabel=0 Text=(genmon) UpdatePeriod=2000 diff --git a/.config/xfce4/panel/genmon-15.rc b/.config/xfce4/panel/genmon-15.rc index da6aead..4e78b4b 100644 --- a/.config/xfce4/panel/genmon-15.rc +++ b/.config/xfce4/panel/genmon-15.rc @@ -1,4 +1,4 @@ -Command=/home/adam/.bin/sensors-monitor.py +Command=/home/adam/.config/xfce4/panel/scripts/sensors-monitor.py UseLabel=0 Text=(genmon) UpdatePeriod=5000 diff --git a/.config/xfce4/panel/scripts/netstatus.sh b/.config/xfce4/panel/scripts/netstatus.sh new file mode 100755 index 0000000..e6eccb6 --- /dev/null +++ b/.config/xfce4/panel/scripts/netstatus.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +function doPing () { + # $1 = target + # $2 = letter + ping -c1 -W1 "$1" | \ + (grep "bytes from" || echo "$2:Down") | \ + sed 's/.*time=\([0-9\.]*\).*/'"$2"':\1ms/' +} + +if [[ "$@" -ne "" ]] +then + interfaces=$(ip -4 -o a | grep "$@") +else + interfaces=$(ip -4 -o a) +fi +ip=$(echo "$interfaces" | \ + sed 's/^[0-9]*: \([^ ]*\) inet \([0-9.]*\).*/\1:\2/g' | \ + grep -v lo | \ + tr '\n' ' ') + +echo -n "${ip}$(doPing 8.8.8.8 G)" diff --git a/.config/xfce4/panel/scripts/sensors-monitor.py b/.config/xfce4/panel/scripts/sensors-monitor.py new file mode 100755 index 0000000..7747caf --- /dev/null +++ b/.config/xfce4/panel/scripts/sensors-monitor.py @@ -0,0 +1,41 @@ +#!/usr/bin/python2 +import sensors +import subprocess +from glob import glob +import re + +sensorsToShow = {'Physical id 0': ["C", 70,100], + 'temp1' : ["C", 70,100], + 'Left side ' : ["RPM", 3000,5000]} + +cpuGovernors = { "powersave" : 's', + "performance": 'p', + "ondemand": 'o'} + +out = "" +cpuGovernor = "" +sensors.init() +try: + for chip in sensors.iter_detected_chips(): + for feature in chip: + if feature.label in sensorsToShow: + color = ("#00B000" if feature.get_value() < sensorsToShow[feature.label][1] + else ("yellow" if feature.get_value() < sensorsToShow[feature.label][2] + else "red")) + out += '%.f%s ' % (color, feature.get_value(), sensorsToShow[feature.label][0]) + + CPUFreq = 0 + for line in open("/proc/cpuinfo"): + if "cpu MHz" in line: + speed = float(line.replace("cpu MHz : ", "").replace("\n", "")) + CPUFreq = max(speed, CPUFreq) + #print CPUFreq + out += '%.2fGHz' % (CPUFreq/1000) + + out += " " + for i in glob("/sys/devices/system/cpu/cpu[0-9]/cpufreq/scaling_governor"): + out += cpuGovernors[open(i).read().replace("\n", "")] + + print "" + out + "" +finally: + sensors.cleanup()