The time now is Wed 20 Jan 2021, 09:29
All times are UTC - 4 |
Page 1 of 11 [164 Posts] |
Goto page: 1, 2, 3, ..., 9, 10, 11 Next |
Author |
Message |
technosaurus

Joined: 18 May 2008 Posts: 4878 Location: Blue Springs, MO
|
Posted: Thu 01 Mar 2012, 18:13 Post subject:
simple icon tray |
|
I just finished my simple icon tray tool that will allow unlimited number of trayicons with user defined icons,refresh intervals, left and right click actions. all you have to do to update icons is change a symlink and popups can be anything you want (including a gtkdialog script)
This will allow a single tray applet to do as many functions as you would like, network monitor, temperature monitor, volume control, load, battery, clipboard, ... pretty much anything you can dump into an icon. This means less resource usage than running multiple tray applets.
here is a template for using it: Code: | sit 1000 /usr/share/mini-icons/mini-dog.xpm "sit test" "dogleftclick" "dogrightclick" \
1000 /usr/share/mini-icons/mini-cd.xpm "sit test" "cdleftclick" "cdrightclick" \
2>/dev/null | \
while read LINE; do
case "$LINE" in
#statusicon specific actions here based on its left/right click action
*)Xdialog --under-mouse --infobox "action=$LINE" 0 0 &
;;
esac
done |
Description |
|
Filesize |
6.52 KB |
Viewed |
7027 Time(s) |

|
Description |
contains source, build script and binary
|

Download |
Filename |
sit-1.0.tar.gz |
Filesize |
2.87 KB |
Downloaded |
2063 Time(s) |
_________________ Check out my github repositories. I may eventually get around to updating my blogspot.
Last edited by technosaurus on Fri 02 Mar 2012, 03:14; edited 1 time in total
|
Back to top
|
|
 |
technosaurus

Joined: 18 May 2008 Posts: 4878 Location: Blue Springs, MO
|
Posted: Thu 01 Mar 2012, 21:46 Post subject:
|
|
Here is the beginning of the applet suite - a drive tray for the tray
Code: | #!/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: | 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 github repositories. I may eventually get around to updating my blogspot.
|
Back to top
|
|
 |
snayak
Joined: 14 Sep 2011 Posts: 422
|
Posted: Fri 02 Mar 2012, 06:18 Post subject:
|
|
Dear technosaurus,
It is an excellent try.
I fought a whole day lot to get my CPU temperature on my desktop.
I had to tweak Pwidgets.
Actually, I was looking for something similar to this.
I have an idea. Hope, I'll discuss it in Idea discussion sub-forum.
http://www.murga-linux.com/puppy/viewtopic.php?t=76451
Sincerely,
Srinivas Nayak
_________________ [Precise 571 on AMD Athlon XP 2000+ with 512MB RAM]
[Fatdog 720 on Intel Pentium B960 with 4GB RAM]
http://srinivas-nayak.blogspot.com/
|
Back to top
|
|
 |
SFR

Joined: 26 Oct 2011 Posts: 1802
|
Posted: Fri 02 Mar 2012, 07:27 Post subject:
|
|
@technosaurus:
This is what I've been waiting for.
I've combined your "sit" with my "SIT", and everything works flawlessly at last.
Just one question:
In your build-script's test routine there's presented a way to get actions when clicking tray icon.
In my script I haven't got click actions handled (no need to); there's refreshing loop instead.
But, for future reference, how to combine both of them (in one script)?
Thanks for the good job and...
Greetings!
_________________ [O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource
Omnia mea mecum porto.
|
Back to top
|
|
 |
technosaurus

Joined: 18 May 2008 Posts: 4878 Location: Blue Springs, MO
|
Posted: Fri 02 Mar 2012, 12:54 Post subject:
|
|
this is currently a developer tool not an application (though I may provide some examples that actually get used, I prefer to mentor other devs in building the things that prompted me to start this in the first place)
My intent is to provide something simple yet robust that will allow us to build a sort of "pwidgets for the tray ". When/if we get enough applets those will be released as a separate package(s)
Note: If you are having issues with svg, it may be your gtk toolchain
Here is a template for an svg battery (or whatever)
Code: | <svg
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
version="1.0"
x="0"
y="0"
width="12"
height="24"
id="svg1">
<rect
width="12"
height="24.0000000"
rx="6"
ry="3"
x="0"
y="0"
style="font-size:12;opacity:0.5;fill-opacity:0.999999;fill-rule:evenodd;stroke-width:3pt;"
id="rect1" />
<rect
width="12"
height="12.0000000"
rx="6"
ry="3"
x="0"
y="12"
style="font-size:12;opacity:0.5;fill:#00ff00;fill-opacity:0.999999;fill-rule:evenodd;stroke-width:3pt;"
id="rect2" />
</svg> |
Description |
this is what the svg above looks like feel free to adjust as necessary, I release it into Public Domain |
Filesize |
390 Bytes |
Viewed |
6970 Time(s) |

|
_________________ Check out my github repositories. I may eventually get around to updating my blogspot.
|
Back to top
|
|
 |
seaside
Joined: 11 Apr 2007 Posts: 937
|
Posted: Mon 05 Mar 2012, 18:19 Post subject:
|
|
technosaurus,
I just checked this out. What a clever and concise job you've done!
Now the tray can be used for just about anything - generate an icon on the fly - throw it into the tray with left/right click options and have the icons update dynamically by changing links. Very nice.
Tried it in Racy522 and all went perfectly - in Pup431, the SITICONS variable was not set (I guess the structure is somewhat different).
For those with gtk's greater than 2.16 who want to use text in their icons, your program "text2xpm" will do the job instead of using an .svg file.
Great job and thanks,
s
(I guess the .pupevent directory would have to be monitored for newly inserted or removed usb drives as well)
|
Back to top
|
|
 |
technosaurus

Joined: 18 May 2008 Posts: 4878 Location: Blue Springs, MO
|
Posted: Tue 06 Mar 2012, 10:07 Post subject:
|
|
seaside wrote: | (I guess the .pupevent directory would have to be monitored for newly inserted or removed usb drives as well) | It was just an example anyways; however, the daemon process could monitor /var/log/messages for *usb-storage: device scan complete* and simply restart
_________________ Check out my github repositories. I may eventually get around to updating my blogspot.
|
Back to top
|
|
 |
technosaurus

Joined: 18 May 2008 Posts: 4878 Location: Blue Springs, MO
|
Posted: Wed 11 Apr 2012, 12:10 Post subject:
|
|
Another great part about using svg, is that you can embed other images (png etc...) and overlay shapes, text, lines etc...
Here is an example using the default drive icon in Wary:
Code: | <svg version="1.0" x="0" y="0" width="48" height="48" id="svg1"
xmlns:xlink="http://www.w3.org/1999/xlink">
<image xlink:href="/usr/share/midi-icons/drive48.png"
width="48" height="48" style="font-size:12;" id="image1" />
<ellipse cx="24" cy="22" rx="10" ry="6" style="fill:yellow"/>
</svg> |
As you can see it draws a yellow ellipse over the top of the image, but it is not limited to simple circles, you can overlay pretty much any svg element. This is useful for identifying a status (mounted/unmounted/unformatted/...) or to have additional information embedded in a small area (better use of screen space for tablets/netbooks)
Description |
here is a png exported from inkscapelite |
Filesize |
4.1 KB |
Viewed |
6471 Time(s) |

|
_________________ Check out my github repositories. I may eventually get around to updating my blogspot.
|
Back to top
|
|
 |
technosaurus

Joined: 18 May 2008 Posts: 4878 Location: Blue Springs, MO
|
Posted: Wed 11 Apr 2012, 17:06 Post subject:
|
|
part 2 of svg icons - using a radial gradient
Code: | <svg width="48" height="48" id="svg1" xmlns:xlink="http://www.w3.org/1999/xlink">
<defs id="defs1">
<linearGradient id="LG1">
<stop style="stop-color:#ffffff;stop-opacity:1;" id="stop1"/>
<stop style="stop-color:#ffff00;stop-opacity:1;" offset="1" id="stop2"/>
</linearGradient>
<radialGradient xlink:href="#LG1" id="RG1" cx="0.5" cy="0.5" r="0.5" fx="0.5" fy="0.5"/>
</defs>
<image xlink:href="/usr/share/midi-icons/drive48.png" width="48" height="48" id="image1"/>
<ellipse cx="24" cy="22" rx="10" ry="6" style="fill:url(#RG1);" id="ellipse1"/>
</svg> |
_________________ Check out my github repositories. I may eventually get around to updating my blogspot.
|
Back to top
|
|
 |
technosaurus

Joined: 18 May 2008 Posts: 4878 Location: Blue Springs, MO
|
Posted: Thu 12 Apr 2012, 01:36 Post subject:
|
|
part 3 svg icons with embedded text and shapes with gradients
Code: | <svg width="48" height="48" id="svg1" xmlns:xlink="http://www.w3.org/1999/xlink">
<defs id="defs1">
<linearGradient id="LG1">
<stop style="stop-color:#ffff00;stop-opacity:1;" id="stop1"/>
<stop style="stop-color:#cccccc;stop-opacity:1;" offset="1" id="stop2"/>
</linearGradient>
<radialGradient xlink:href="#LG1" id="RG1" cx="0.5" cy="0.5" r="0.5" fx="0.5" fy="0.5"/>
</defs>
<image xlink:href="/usr/share/midi-icons/drive48.png" width="48" height="48" id="image1"/>
<ellipse cx="24" cy="22" rx="10" ry="6" style="fill:url(#RG1);" id="ellipse1"/>
<text style="fill:red;" x="12" y="26" id="text1">sda1</text>
</svg> |
Description |
|
Filesize |
4.49 KB |
Viewed |
6562 Time(s) |

|
_________________ Check out my github repositories. I may eventually get around to updating my blogspot.
|
Back to top
|
|
 |
seaside
Joined: 11 Apr 2007 Posts: 937
|
Posted: Fri 13 Apr 2012, 19:57 Post subject:
|
|
technosaurus,
Thanks for the tips on overlaying.
It prompted me to see if I could get some text into a svg with a Gttk higher than 2.16 and apparently it works when using the entire inkscape coding . (Perhaps not all needed, but I'm not sure what isn't)
Here's a stock-ticker using sit. (Left-Click to edit stocks and Right-click to stop)
Code: | #!/bin/sh -a
# stock ticker- seaside April 14, 2012
# stock retrieval ideas from technosaurus
symlist="/root/.stocklist"
# set sample stock info
[[ ! -f $symlist ]] && echo 'ibm
dis
goog ' >$symlist
sit 1000 /tmp/stockicon.svg "Stock-Ticker" "EDIT" "STOP" 2>/dev/null | \
while read ITEM; do
case "$ITEM" in
EDIT)geany "$symlist" & ;;
STOP) ps | grep stock | grep -v grep | awk '{print $1}'|xargs kill ;;
esac
done &
LINE=1
while true; do
STK=`sed -n "${LINE}p" $symlist`
[ "$STK" = "" ] && LINE=1 && STK=`sed -n "${LINE}p" $symlist` #ran out of lines
QUOTE=`wget -q -O - "http://download.finance.yahoo.com/d/quotes.csv?f=sb3c1&s=$STK"`
#returns "IBM",180.27,-1.77
oldIFS=$IFS
IFS=","
read STOCK BID CHANGE<<<"$QUOTE"
IFS=$oldIFS
STOCK="${STOCK//\"/}"
STOCK="${STOCK:0:4}"
BID="${BID:0:6}"
case $CHANGE in
-*) BG=#FF6F55 ;; #light red
+*) BG=#90EE90 ;; #light green
*) BG=#C7E7F1 ;; #light blue
esac
# technosaurus' use of svg for icons
echo '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<!-- Created with Inkscape ("http://www.inkscape.org/") -->
<svg
id="svg1"
sodipodi:version="0.32"
inkscape:version="0.36"
width="64"
height="64"
sodipodi:docname="/tmp/stockicon.svg"
sodipodi:docbase="/tmp"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:xlink="http://www.w3.org/1999/xlink">
<defs
id="defs8" />
<sodipodi:namedview
id="base" />
<rect
width="64"
height="64"
x="0.150467"
y="0.257804"
style="fill:'"$BG"'"
id="rect2" />
<text
x="-0.02790701"
y="23.8785315"
style="font-size:32;font-family:Nimbus Mono L;font-weight:bold;font-style:normal;text-anchor:start;writing-mode:lr;"
id="text3"
transform="scale(0.893866,1.000000)"
sodipodi:linespacing="100%">
<tspan
x="-0.02790701"
y="23.8785324"
sodipodi:role="line"
id="tspan11">'"$STOCK"'</tspan>
</text>
<text
x="0.70210701"
y="43.4028667"
style="font-size:20;font-family:Nimbus Mono L;font-weight:bold;font-style:normal;text-anchor:start;writing-mode:lr;"
id="text5"
transform="scale(0.861163,1.371361)"
sodipodi:linespacing="100%">
<tspan
x="0.70210701"
y="43.4028664"
sodipodi:role="line"
id="tspan13">'"$BID"'</tspan>
</text>
</svg>
' >/tmp/stockicon-new.svg
cp /tmp/stockicon-new.svg /tmp/stockicon.svg
LINE=$[LINE+1]
sleep 3 # Wait before checking again.
done |
EDITED: April 14, 2012 improved
Regards,
s
Last edited by seaside on Sat 14 Apr 2012, 23:50; edited 1 time in total
|
Back to top
|
|
 |
ka9qlq
Joined: 22 Aug 2007 Posts: 13 Location: Columbus, IN USA
|
Posted: Fri 13 Apr 2012, 22:09 Post subject:
|
|
IS there a step by step guide to get this up and running with Lucid 5.28?
_________________ Thanks
Alvin
Thanks be unto God for His wonderful gift:
Jesus Christ, the only begotten Son of God
is the object of our faith; the only faith
that saves is faith in Him.
|
Back to top
|
|
 |
technosaurus

Joined: 18 May 2008 Posts: 4878 Location: Blue Springs, MO
|
Posted: Fri 13 Apr 2012, 23:06 Post subject:
|
|
@seaside - cool - the stripped down svgs I posted worked in an older wary with gtk 2.20 so it seemed safe - glad to see it being used
@ ka9qlq - like much of my work, right now it is _just_ a developer tool with some "examples" to help get new developers started building tray applets ... I _could_ write them myself, but I would much rather mentor others that want to learn how to write actual programs ... yeah it takes more of my time to debug someone else's code, but it is more rewarding for me to witness a transition from newbie to intermediate to advanced to master programmer. too many people who could have been code contributors, give up because they just get a bunch of useless "hello world" garbage. What kind of tray applet did you want to have up and running?
_________________ Check out my github repositories. I may eventually get around to updating my blogspot.
|
Back to top
|
|
 |
zigbert

Joined: 29 Mar 2006 Posts: 6629 Location: Valåmoen, Norway
|
Posted: Sat 14 Apr 2012, 00:21 Post subject:
|
|
technosaurus
This WILL be helpful one day. - That is for sure.
Thank you!
Sigmund
_________________ Stardust resources
|
Back to top
|
|
 |
ka9qlq
Joined: 22 Aug 2007 Posts: 13 Location: Columbus, IN USA
|
Posted: Sat 14 Apr 2012, 01:10 Post subject:
|
|
I'd like to know my cpu speed/temp/%use sounds like I should just install gkrellm
_________________ Thanks
Alvin
Thanks be unto God for His wonderful gift:
Jesus Christ, the only begotten Son of God
is the object of our faith; the only faith
that saves is faith in Him.
|
Back to top
|
|
 |
|
Page 1 of 11 [164 Posts] |
Goto page: 1, 2, 3, ..., 9, 10, 11 Next |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|