Here is the beginning of the applet suite - a drive tray for the tray
Code: Select all
#!/bin/sh
#move these to an rc file for easier config and just source it
ICONPATH="/usr/share/midi-icons"
DRIVES="1"
BATTERY=""
CPUTEMP="1"
CPULOAD=""
NETWORK=""
cputemp(){
for x in /proc/acpi/thermal_zone/*; do
ZONE=${x##*/}
awk '{BG = "#00FF00"
if ($2 > 65) BG = "#FFFF00"
if ($2 > 80) BG = "#FF0000"
printf "<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"> \
<rect width=\"32\" height=\"22\" x=\"0\" y=\"0\" \
style=\"font-size:%d;fill:%s;fill-opacity:0.75;fill-rule:evenodd;stroke-width:3pt;\" id=\"rect1\" /> \
<text x=\"0\" y=\"18\" style=\"font-size:%d;font-weight:normal;fill-opacity:0.75;stroke-width:3pt;font-family:helvetica;\" id=\"text1\"> \
<tspan id=\"tspan1\">%d°C</tspan> \
</text> \
</svg>",14,BG,14,$2}' /proc/acpi/thermal_zone/$ZONE/temperature >/tmp/sit/$ZONE.svg
done
}
mkdir /tmp/sit 2>/dev/null
SITICONS="sit"
[ "$DRIVES" ] && for UEVENT in /sys/dev/block/*/uevent ; do
. $UEVENT
case "${DEVNAME}" in
sd*|hd*) REMOVABLE="0" NOTSWAP="1" LOGICAL=1
[ -e ${UEVENT//uevent/"../removable"} ] && read REMOVABLE <${UEVENT//uevent/"../removable"}
[ $REMOVABLE = 1 ] && ICON=usbdrv48.png || ICON=drive48.png #possibly have something here for devicehandler?
#logical partitions have a size of 2
read LOGICAL <${UEVENT//uevent/size}
LINE=""
while read LINE || [ "$LINE" ]; do
case $LINE in
"/dev/"$DEVNAME*)NOTSWAP=""
esac
done < /proc/swaps
[ ${DEVTYPE} = "partition" ] && [ $NOTSWAP ] && [ ! $LOGICAL = 2 ] && {
[ -d /mnt/$DEVNAME ] && ICON=${ICON/48/_mntd48}
ln -sf ${ICONPATH}/${ICON} /tmp/sit/${DEVNAME}.png 2>/dev/null
SITICONS=${SITICONS}' 1000 "'/tmp/sit/${DEVNAME}.png'" "'${DEVNAME}'" "'mount=${DEVNAME}'" "'umount=${DEVNAME}'" '
}
;;
mm*) [ ${DEVTYPE} = "partition" ] && {
[ -d /mnt/$DEVNAME ] && ICON=card_mntd48.png || ICON=card48.png
ln -sf ${ICONPATH}/${ICON} /tmp/sit/${DEVNAME}.png 2>/dev/null
SITICONS=${SITICONS}' 1000 "'/tmp/sit/${DEVNAME}.png'" "'${DEVNAME}'" "'mount=${DEVNAME}'" "'umount=${DEVNAME}'" '
}
;;
sr*)[ -d /mnt/$DEVNAME ] && ICON=optical_mntd48.png || ICON=optical48.png
ln -sf ${ICONPATH}/${ICON} /tmp/sit/${DEVNAME}.png 2>/dev/null
SITICONS=${SITICONS}' 1000 "'/tmp/sit/${DEVNAME}.png'" "'${DEVNAME}'" "'mount=${DEVNAME}'" "'umount=${DEVNAME}'" '
;;
fd*)[ -d /mnt/$DEVNAME ] && ICON=floppy_mntd48.png || ICON=floppy48.png
ln -sf ${ICONPATH}/${ICON} /tmp/sit/${DEVNAME}.png 2>/dev/null
SITICONS=${SITICONS}' 1000 "'/tmp/sit/${DEVNAME}.png'" "'${DEVNAME}'" "'mount=${DEVNAME}'" "'umount=${DEVNAME}'" '
;;
esac
done
if [ "$CPUTEMP" ];then
cputemp
for x in /proc/acpi/thermal_zone/*; do
ZONE=${x##*/}
SITICONS=${SITICONS}' 5000 "'/tmp/sit/$ZONE.svg'" "'$ZONE'" "'leftclick=$ZONE'" "'rightclick=$ZONE'" '
done
fi
eval "$SITICONS" |while read LINE; do
case "$LINE" in
mount=*)
eval $LINE
if [ ! -d /mnt/$mount ]; then
mkdir /mnt/$mount
busybox mount /dev/$mount /mnt/$mount
ln -sf `readlink /tmp/sit/$mount.png |sed "s/48/_mntd48/"` /tmp/sit/$mount.png
else
rox /mnt/$mount
fi
;;
umount=*)eval $LINE
busybox umount /dev/$umount && \
rmdir /mnt/$umount && \
ln -sf `readlink /tmp/sit/$umount.png |sed "s/_mntd48/48/"` /tmp/sit/$umount.png || \
xmessage error unmounting $umount
;;
*)echo $LINE unused >/dev/stderr
esac
done &
while :; do
sleep 1
[ "$CPUTEMP" ] && cputemp
done
TODO - use awk for the following:
this gives %memused
Code: Select all
awk '/MemTot/{tot = $2} /MemFree/{free = $2; printf "%.0f\n", 100*(1-(free/tot)) " " sum}' /proc/meminfo
battery
/proc/acpi/battery/*/{info,state}
charging/discharging/charged/remaining capacity ...
temperature
/proc/acpi/temperature/*/{trip_points,temperature}
volume
/proc/asound/card0/oss_mixer
webcam
capture image with ffmpeg
network
/proc/net/dev (compare tx and rx with last value)
icon from url
(use wget/other to get file/updates/mail/news... and update icon accordingly)
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].