summaryrefslogtreecommitdiff
path: root/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'widgets')
-rwxr-xr-xwidgets/system_information/system_information.g2v175
-rwxr-xr-xwidgets/temperatures/temperatures9
-rwxr-xr-xwidgets/temperatures/temperatures.g2v32
-rw-r--r--widgets/weather/GetLatLangFromCity.php25
-rw-r--r--widgets/weather/README9
-rw-r--r--widgets/weather/update_weather.config15
-rw-r--r--widgets/weather/update_weather.php38
7 files changed, 272 insertions, 31 deletions
diff --git a/widgets/system_information/system_information.g2v b/widgets/system_information/system_information.g2v
new file mode 100755
index 00000000..56480fa3
--- /dev/null
+++ b/widgets/system_information/system_information.g2v
@@ -0,0 +1,175 @@
+#!/bin/bash
+
+# this script will be executed when the widget will be drawn
+# so make it short and fast
+
+# enable/disable items
+SHOW_SYS_VERSION=1
+SHOW_KERNEL_VERSION=0
+SHOW_UPTIME=1
+SHOW_LOAD=1
+SHOW_PROCESSES=1
+SHOW_MEM_USAGE=1
+SHOW_SWAP_USAGE=1
+SHOW_ROOT_USAGE=1
+SHOW_VIDEO_USAGE=1
+SHOW_VDR_CPU_USAGE=1
+SHOW_VDR_MEM_USAGE=1
+
+SHOW_TEMPERATURES=0
+SHOW_SYSUPDATES=0
+
+# Position of items
+# sys_version & kernel_version are drawn in one line
+# all others will be drawn in two column
+# for example
+# System Version: Ubuntu 14.04.1 LTS
+# Uptime: 1:20 5m Load: 0.41
+
+# must begin with 01
+SYS_VERSION_POS="01"
+KERNEL_VERSION_POS="02"
+UPTIME_POS="03"
+LOAD_POS="04"
+PROCESSES_POS="05"
+MEM_USAGE_POS="06"
+SWAP_USAGE_POS="07"
+ROOT_USAGE_POS="08"
+VIDEO_USAGE_POS="09"
+VDR_CPU_USAGE_POS="10"
+VDR_MEM_USAGE_POS="11"
+
+TEMP_CPU_POS=15
+TEMP_PCCASE_POS=16
+TEMP_GPU_POS=17
+
+SYSUPD_POS=20
+SYSSECUPD_POS=21
+
+# mount point of vdr video disk
+VIDEO_MOUNT="/video"
+
+# force english output for filters
+LANG=en_EN
+
+# Release-File (PRETTY_NAME & VERSION)
+REL_FILE="/etc/g2v-release"
+
+# delete all files
+rm -f [0-99]*
+
+if [ $SHOW_SYS_VERSION = 1 ]; then
+ if [ -e $REL_FILE ] ; then
+ while IFS= read -r; do
+ [[ ${REPLY} =~ PRETTY_NAME ]] && declare "${REPLY}" # locale Variable
+ [[ ${REPLY} =~ VERSION ]] && declare "${REPLY}" # locale Variable
+ done < $REL_FILE
+ [ -n "$PRETTY_NAME" ] && echo "${PRETTY_NAME//\"/} ${VERSION//\"/}" > ./${SYS_VERSION_POS}_sys_version
+ fi
+fi
+
+if [ $SHOW_KERNEL_VERSION = 1 ]; then
+ uname -r > ./${KERNEL_VERSION_POS}_kernel_version
+fi
+
+if [ $SHOW_UPTIME = 1 ]; then
+ UPTIME=($(cat /proc/uptime)) # UpTime in Array
+ UPTIME[0]=${UPTIME[0]%.*} # .* entfernen (UpTime in Sekunden)
+ TAGE=$((UPTIME[0] / 86400)) ; STD=$((UPTIME[0] % 86400 / 3600))
+ MIN=$((UPTIME[0] % 3600 / 60)) ; SEK=$((UPTIME[0] % 60))
+ if [ $TAGE -ge 1 ] ; then
+ echo "${TAGE}T ${STD}S ${MIN}M" > ./${UPTIME_POS}_uptime
+ else
+ [ $STD -ge 1 ] && echo -n "${STD} Std. " > ./${UPTIME_POS}_uptime
+ echo "${MIN} Min." >> ./${UPTIME_POS}_uptime
+ fi
+fi
+
+if [ $SHOW_LOAD = 1 ]; then
+ LOADAVG=($(cat /proc/loadavg)) # Zeile in Array
+ echo "${LOADAVG[0]//./,}" > ./${LOAD_POS}_load
+fi
+
+if [ $SHOW_PROCESSES = 1 ]; then
+ PROCS=($(ls -d /proc/[0-9]*/))
+ echo "${#PROCS[@]}" > ./${PROCESSES_POS}_processes
+fi
+
+if [ $SHOW_MEM_USAGE = 1 ]; then
+ mapfile -t < <(free -m) # Ausgabe von free in Array (Vier Zeilen)
+ MEM=(${MAPFILE[1]}) # 2. Zeile
+ BUF=(${MAPFILE[2]}) # 3. Zeile
+ MEM_USAGE=$((${BUF[2]} * 1000 / ${MEM[1]}))
+ [ $MEM_USAGE -lt 10 ] && MEM_USAGE="0${MEM_USAGE}"
+ MEM_DEC=${MEM_USAGE: -1}
+ echo "${MEM_USAGE:0: -1},${MEM_DEC}%" > ./${MEM_USAGE_POS}_mem_usage
+fi
+
+if [ $SHOW_SWAP_USAGE = 1 ]; then
+ mapfile -t < <(free -m) # Ausgabe von free in Array (Vier Zeilen)
+ SWAP=(${MAPFILE[3]}) # 4. Zeile
+ if [ ${SWAP[1]} -gt 0 ]; then # Swap Total
+ if [ ${SWAP[2]} -gt 0 ]; then # Swap Used
+ SWP=$((${SWAP[2]} * 1000 / ${SWAP[1]}))
+ [ $SWP -lt 10 ] && SWP="0${SWP}"
+ SWP_DEC=${SWP: -1} ; SWP=${SWP:0: -1},${SWP_DEC}
+ echo "${SWP}%" > ./${SWAP_USAGE_POS}_swap_usage
+ else
+ echo "0,0%" > ./${SWAP_USAGE_POS}_swap_usage
+ fi
+ fi
+fi
+
+if [ $SHOW_ROOT_USAGE = 1 ]; then
+ mapfile -t < <(df -Ph /) # Ausgabe von df in Array (Zwei Zeilen)
+ ROOTUSAGE=(${MAPFILE[1]}) # 2. Zeile in Array
+ # Beispiel 2. Zeile: tmpfs 128M 30M 99M 23% /root
+ echo "${ROOTUSAGE[4]}" > ./${ROOT_USAGE_POS}_root_usage
+fi
+
+if [ $SHOW_VIDEO_USAGE = 1 ] && [ -d ${VIDEO_MOUNT} ]; then
+ mapfile -t < <(df -Ph ${VIDEO_MOUNT}) # Ausgabe von df in Array (Zwei Zeilen)
+ VIDEOUSAGE=(${MAPFILE[1]}) # 2. Zeile in Array
+ # Beispiel 2. Zeile: tmpfs 128M 30M 99M 23% /root
+ echo "${VIDEOUSAGE[4]}" > ./${VIDEO_USAGE_POS}_video_usage
+fi
+
+if [ $SHOW_VDR_CPU_USAGE = 1 ]; then
+ vdr_pid=$(pidof vdr)
+ if [ $? = 0 ]; then
+ mapfile -t < <(ps -p ${vdr_pid} -o %cpu) # Ausgabe von ps in Array (Zwei Zeilen)
+ CPU_USAGE=${MAPFILE[1]/./,} # 24.2 -> 24,2
+ echo "${CPU_USAGE}%" > ./${VDR_CPU_USAGE_POS}_vdr_cpu_usage
+ fi
+fi
+
+if [ $SHOW_VDR_MEM_USAGE = 1 ]; then
+ vdr_pid=$(pidof vdr)
+ if [ $? = 0 ]; then
+ mapfile -t < <(ps -p ${vdr_pid} -o %mem) # Ausgabe von ps in Array (Zwei Zeilen)
+ VDR_MEM_USAGE=${MAPFILE[1]/./,} # 24.2 -> 24,2
+ echo "${VDR_MEM_USAGE}%" > ./${VDR_MEM_USAGE_POS}_vdr_mem_usage
+ fi
+fi
+
+if [ $SHOW_TEMPERATURES = 1 ]; then
+ ./../temperatures/temperatures
+ if [ -f ./cpu ]; then
+ mv ./cpu ${TEMP_CPU_POS}_cpu
+ fi
+ if [ -f ./pccase ]; then
+ mv ./pccase ${TEMP_PCCASE_POS}_pccase
+ fi
+ if [ -f ./gpu ]; then
+ mv ./gpu ${TEMP_GPU_POS}_gpu
+ fi
+fi
+
+if [ $SHOW_SYSUPDATES = 1 ]; then
+ if [ -f ./../system_updatestatus/updates ]; then
+ cp ./../system_updatestatus/updates ${SYSUPD_POS}_updates
+ fi
+ if [ -f ./../system_updatestatus/security_updates ]; then
+ cp ./../system_updatestatus/security_updates ${SYSSECUPD_POS}_security_updates
+ fi
+fi
diff --git a/widgets/temperatures/temperatures b/widgets/temperatures/temperatures
index 75a35796..56259ddd 100755
--- a/widgets/temperatures/temperatures
+++ b/widgets/temperatures/temperatures
@@ -6,7 +6,7 @@
# if the script is executed from system_information script set the locale back for "°C"
LANG=de_DE.UTF-8
-# there can be 3 files, cpu, gpu, case
+# there can be 4 files, cpu, gpu, pccase, motherboard
rm -f ./cpu ./pccase ./gpu
@@ -14,9 +14,12 @@ rm -f ./cpu ./pccase ./gpu
sensors -A coretemp-isa-0000 | grep "Core 0" | awk '{print $3}' | tr -d "+" > ./cpu
# pc case temp
-sensors -A acpitz-virtual-0 | grep "temp1" | awk '{print $2}' | tr -d "+" > ./pccase
+#sensors -A acpitz-virtual-0 | grep "temp1" | awk '{print $2}' | tr -d "+" > ./pccase
+
+# motherboard temp
+sensors -A acpitz-virtual-0 | grep "temp1" | awk '{print $2}' | tr -d "+" > ./motherboard
# nvidia gpu temp
# nvidia-settings must be run as the user of the x server
GPU=`nvidia-settings -c :0 -t -query GPUCoreTemp | head -n 1`
-echo "$GPU°C" > ./gpu
+echo "${GPU}°C" > ./gpu
diff --git a/widgets/temperatures/temperatures.g2v b/widgets/temperatures/temperatures.g2v
new file mode 100755
index 00000000..7da4d68e
--- /dev/null
+++ b/widgets/temperatures/temperatures.g2v
@@ -0,0 +1,32 @@
+#!/bin/bash
+
+# please update this script to fit your needs
+# this script is call every time the widget will be drawn, so keep it short and fast ;)
+
+# if the script is executed from system_information script set the locale back for "°C"
+LANG=de_DE.UTF-8
+
+# there can be 4 files, cpu, gpu, pccase, motherboard
+
+rm -f ./cpu ./pccase ./gpu
+
+# intel core-i cpu temp
+#sensors -A coretemp-isa-0000 | grep "Core 0" | awk '{print $3}' | tr -d "+" > ./cpu
+
+# cpu temp
+CPUTEMP=($(sensors -A | grep "CPU Temperature"))
+CPUTEMP[2]=${CPUTEMP[2]/+}
+#echo "${CPUTEMP[2]/./,}" > ./cpu # 36,0°C
+echo "${CPUTEMP[2]%.*}°C" > ./cpu # 36°C
+
+# pc case temp
+#sensors -A acpitz-virtual-0 | grep "temp1" | awk '{print $2}' | tr -d "+" > ./pccase
+MBTEMP=($(sensors -A | grep "MB Temperature"))
+MBTEMP[2]=${MBTEMP[2]/+}
+#echo "${MBTEMP[2]/./,}" > ./pccase # 36,0°C
+echo "${MBTEMP[2]%.*}°C" > ./pccase # 36°C
+
+# nvidia gpu temp
+# nvidia-settings must be run as the user of the x server
+GPU=$(nvidia-settings -c :0 -t -query GPUCoreTemp | head -n 1)
+echo "${GPU}°C" > ./gpu
diff --git a/widgets/weather/GetLatLangFromCity.php b/widgets/weather/GetLatLangFromCity.php
new file mode 100644
index 00000000..e05c1bc8
--- /dev/null
+++ b/widgets/weather/GetLatLangFromCity.php
@@ -0,0 +1,25 @@
+<?php
+
+$handle = fopen ("php://stdin","r");
+echo "Country (like DE for Germany): ";
+$country = fgets($handle);
+echo "City (like Berlin): ";
+$city = fgets($handle);
+
+// get lat & long from google maps
+$MAPSURL = "http://maps.googleapis.com/maps/api/geocode/json?address=".$city.",".$country."&sensor=false";
+$json = file_get_contents($MAPSURL);
+$data = json_decode($json, true);
+
+if( !isset($data['results'][0]) ) {
+ echo "no latitude and longitude find for: ".$city.",".$country." !\n";
+ exit;
+}
+$latitude = $data['results'][0]['geometry']['location']['lat'];
+$longitude = $data['results'][0]['geometry']['location']['lng'];
+
+echo "latitude: ".$latitude."\n";
+echo "longitude: ".$longitude."\n";
+echo "put these values in update_weather.config\n";
+
+?>
diff --git a/widgets/weather/README b/widgets/weather/README
new file mode 100644
index 00000000..956c7a26
--- /dev/null
+++ b/widgets/weather/README
@@ -0,0 +1,9 @@
+This widget provide information about weather for a defined location.
+
+Since the command usually needs long time to execute this is not called from skin flatPlus.
+You have to call the command from the system via cron or at system start.
+For example call the command from cron.daily.
+
+You need php5 with command line support for this widget. For example in Ubuntu you need the package "php5-cli".
+
+Please configur your location and others in update_weather.config. Use php-script "GetLatLangFromCity.php" to get latitude & longitude from your location.
diff --git a/widgets/weather/update_weather.config b/widgets/weather/update_weather.config
new file mode 100644
index 00000000..4a749212
--- /dev/null
+++ b/widgets/weather/update_weather.config
@@ -0,0 +1,15 @@
+[main]
+# use GetLatLangFromCity.php to get latitude/langitude
+Latitude = 52.5200066
+Longitude = 13.404954
+# location shown in Skin
+LocationSkin = "Berlin"
+# Can be set to 'us', 'si', 'ca', 'uk' or 'auto' (see forecast.io API); default is auto
+Units = "si"
+DegreeSign = "°C"
+# Can be set to 'en', 'de', 'pl', 'es', 'fr', 'it', 'tet' or 'x-pig-latin' (see forecast.io API); default is 'en'
+Lang = "de"
+# We have only 1000 api calls per day, so please only do one update per day!
+# Or request an own key for free at forecast.io
+ApiKey = "137f2d85a1f1db5762e5e073103541d2"
+
diff --git a/widgets/weather/update_weather.php b/widgets/weather/update_weather.php
index 8d2d8be9..d2d38c1e 100644
--- a/widgets/weather/update_weather.php
+++ b/widgets/weather/update_weather.php
@@ -1,38 +1,20 @@
<?php
-/*
- * USER CONFIG
- */
-$city = "Berlin";
-$country = "DE";
-$locationSkin = "Berlin"; // location shown in skin
-$units = 'si'; // Can be set to 'us', 'si', 'ca', 'uk' or 'auto' (see forecast.io API); default is auto
-$degree_sign = "°C";
-$lang = 'de'; // Can be set to 'en', 'de', 'pl', 'es', 'fr', 'it', 'tet' or 'x-pig-latin' (see forecast.io API); default is 'en'
-// We have only 1000 api calls per day, so please only do one update per day!
-// Or request an own key for free at forecast.io
-$api_key = '137f2d85a1f1db5762e5e073103541d2';
-
-/*
- * DO NOT CHANGE ANYTHING FROM HERE
- */
+$ini_array = parse_ini_file("./update_weather.config");
+
+$latitude = $ini_array['Latitude'];
+$longitude = $ini_array['Longitude'];
+$locationSkin = $ini_array['LocationSkin'];
+$units = $ini_array['Units'];
+$degree_sign = $ini_array['DegreeSign'];
+$lang = $ini_array['Lang'];
+$api_key = $ini_array['ApiKey'];
+
include('lib/forecast.io.php');
// delete old files
array_map('unlink', glob("weather.*"));
-// get lat & long from google maps
-$MAPSURL = "http://maps.googleapis.com/maps/api/geocode/json?address=".$city.",".$country."&sensor=false";
-$json = file_get_contents($MAPSURL);
-$data = json_decode($json, true);
-
-if( !isset($data['results'][0]) ) {
- echo "no latitude and longitude find for: ".$city.",".$country." !\n";
- exit;
-}
-$latitude = $data['results'][0]['geometry']['location']['lat'];
-$longitude = $data['results'][0]['geometry']['location']['lng'];
-
// forecast query
$forecast = new ForecastIO($api_key);