#!/bin/bash # this script will be executed when the widget will be drawn # so make it short and fast OUTPUTFLDR="/tmp/skinflatplus/widgets/system_information" mkdir -p ${OUTPUTFLDR} OUTPUTFLDRTEMP="/tmp/skinflatplus/widgets/temperatures" OUTPUTFLDRSUPD="/tmp/skinflatplus/widgets/system_updatestatus" # enable/disable items SHOW_SYS_VERSION=0 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="/media/video" # force english output for filters LANG=en_EN # Get own Path SELF="$(readlink -m /proc/$$/fd/255)" # $0 MY_DIR="$(dirname $SELF)" # Path # delete all files rm -f ${OUTPUTFLDR}/[0-99]* if [ $SHOW_SYS_VERSION = 1 ]; then cat /etc/os-release | grep "PRETTY_NAME=" | cut -d"\"" -f 2 > ${OUTPUTFLDR}/${SYS_VERSION_POS}_sys_version fi if [ $SHOW_KERNEL_VERSION = 1 ]; then uname -r > ${OUTPUTFLDR}/${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" > ${OUTPUTFLDR}/${UPTIME_POS}_uptime else [ $STD -ge 1 ] && echo -n "${STD} Std. " > ${OUTPUTFLDR}/${UPTIME_POS}_uptime echo "${MIN} Min." >> ${OUTPUTFLDR}/${UPTIME_POS}_uptime fi fi if [ $SHOW_LOAD = 1 ]; then LOADAVG=($(cat /proc/loadavg)) # Zeile in Array echo "${LOADAVG[0]//./,}" > ${OUTPUTFLDR}/${LOAD_POS}_load fi if [ $SHOW_PROCESSES = 1 ]; then PROCS=($(ls -d /proc/[0-9]*/)) echo "${#PROCS[@]}" > ${OUTPUTFLDR}/${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}%" > ${OUTPUTFLDR}/${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}%" > ${OUTPUTFLDR}/${SWAP_USAGE_POS}_swap_usage else echo "0,0%" > ${OUTPUTFLDR}/${SWAP_USAGE_POS}_swap_usage fi fi fi if [ $SHOW_ROOT_USAGE = 1 ]; then df -h / | awk '/\// {print $(NF-1)}' > ${OUTPUTFLDR}/${ROOT_USAGE_POS}_root_usage fi if [ $SHOW_VIDEO_USAGE = 1 ] && [ -d ${VIDEO_MOUNT} ]; then df -h ${VIDEO_MOUNT} | awk '/\// {print $(NF-1)}' > ${OUTPUTFLDR}/${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}%" > ${OUTPUTFLDR}/${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}%" > ${OUTPUTFLDR}/${VDR_MEM_USAGE_POS}_vdr_mem_usage fi fi if [ $SHOW_TEMPERATURES = 1 ]; then TEMPERATURES_DIR="$(readlink -m $MY_DIR/../temperatures)" bash $TEMPERATURES_DIR/temperatures if [ -f ${OUTPUTFLDRTEMP}/cpu ]; then cp ${OUTPUTFLDRTEMP}/cpu ${OUTPUTFLDR}/${TEMP_CPU_POS}_cpu fi if [ -f ${OUTPUTFLDRTEMP}/pccase ]; then cp ${OUTPUTFLDRTEMP}/pccase ${OUTPUTFLDR}/${TEMP_PCCASE_POS}_pccase fi if [ -f ${OUTPUTFLDRTEMP}/gpu ]; then cp ${OUTPUTFLDRTEMP}/gpu ${OUTPUTFLDR}/${TEMP_GPU_POS}_gpu fi fi if [ $SHOW_SYSUPDATES = 1 ]; then if [ -f ${OUTPUTFLDRSUPD}/updates ]; then cp ${OUTPUTFLDRSUPD}/updates ${OUTPUTFLDR}/${SYSUPD_POS}_updates fi if [ -f ${OUTPUTFLDRSUPD}/security_updates ]; then cp ${OUTPUTFLDRSUPD}/security_updates ${OUTPUTFLDR}/${SYSSECUPD_POS}_security_updates fi fi