blob: 727b20c184ddaa6db0d550187eaa369e845a5cdd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
|
#!/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=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=0
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 ${OUTPUTFLDR}/[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//\"/}" > ${OUTPUTFLDR}/${SYS_VERSION_POS}_sys_version
fi
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
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]}" > ${OUTPUTFLDR}/${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]}" > ${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/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
|