that was exactly the kind of thing I had in mind when I wrote this. Things like partview, battview, tempview... Then I found out how to do the same thing in svg much easier, but it is still good for xcb/X11+xpm only apps I guess.
text2xpm in shell
- technosaurus
- Posts: 4853
- Joined: Mon 19 May 2008, 01:24
- Location: Blue Springs, MO
- Contact:
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].
Another one,
cpuicon
There's a difference, no thread topic, this is just a link to the source code and support files including a build script.
You could say I'm going a bit mad on tray icons! But I find them more useful than widgets or conky as I actually use them! They don't look fantastic but they are functional.
techno, care to share the svg knowledge?
cpuicon
There's a difference, no thread topic, this is just a link to the source code and support files including a build script.
You could say I'm going a bit mad on tray icons! But I find them more useful than widgets or conky as I actually use them! They don't look fantastic but they are functional.
techno, care to share the svg knowledge?
Puppy Linux Blog - contact me for access
- technosaurus
- Posts: 4853
- Joined: Mon 19 May 2008, 01:24
- Location: Blue Springs, MO
- Contact:
Try playing with this:
(save as <something>.svg and open with viewnior)
you can add as many rectangles as you want, or you can save some svgS from inklite (uncompressed) for other shapes etc... (crap, now Iremember where I posted this before - it was in the project management / planner thread ... covered lines too)
(save as <something>.svg and open with viewnior)
Code: Select all
<svg>
<rect width="100"
height="50"
x="0"
y="0"
style="font-size:12;fill:#0000ff;fill-opacity:0.75;fill-rule:evenodd;stroke-width:3pt;"
id="rect1" />
<rect
width="50"
height="50"
x="0"
y="0"
style="font-size:12;fill:#ff00ff;fill-opacity:0.75;fill-rule:evenodd;stroke-width:3pt;"
id="rect2" />
<text
x="0"
y="50"
style="font-size:12;font-weight:normal;fill-opacity:0.75;stroke-width:3pt;font-family:helvetica;"
id="text1">
<tspan
id="tspan1">test</tspan>
</text>
</svg>
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].
- technosaurus
- Posts: 4853
- Joined: Mon 19 May 2008, 01:24
- Location: Blue Springs, MO
- Contact:
this just requires echo and variables to generate svg
simply edit the fixed parameters in place and then just replace the rest with single quoted variables. ex.
... width="50" .... becomes ... width="'${WIDTH}'" ...
Code: Select all
echo '<svg>
<rect width="100" height="50" x="0" y="0" id="rect1" style="font-size:12;fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke-width:3pt;"/>
<rect width="50" height="50" x="0" y="0" id="rect2" style="font-size:12;fill:#ff00ff;fill-opacity:0.75;fill-rule:evenodd;stroke-width:3pt;"/>
<ellipse cx="24" cy="24" rx="24" ry="24" style="font-size:12;fill:#ff0000;fill-opacity:0.75;fill-rule:evenodd;stroke-width:3pt;"/>
<ellipse cx="74" cy="24" rx="24" ry="24" style="font-size:12;fill:#00ff00;fill-opacity:0.75;fill-rule:evenodd;stroke-width:3pt;"/>
<text x="12" y="25" id="text1" style="font-size:12;font-weight:normal;fill-opacity:0.75;stroke-width:3pt;font-family:helvetica;">test</text>
<path d="M 50 25 L 100.0 25.0 " style="font-size:12;fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:#000000;stroke-width:1pt;"/>
</svg>' >$FILE
... width="50" .... becomes ... width="'${WIDTH}'" ...
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].
cpu-usage with Eterm
wrapper (toggle from tray):
wrapper (toggle from tray):
Code: Select all
#/bin/sh
var="$(pidof cpu)"
if [ "$var" ]; then
kill -9 "$var"
else
Eterm --trans --no-cursor --buttonBar no --scrollBar no -x -f WHITE -g 10x2+890+682 -e cpu &
fi
- Attachments
-
- cpu.png
- (29.7 KiB) Downloaded 510 times
Interesting. Will have to find a use for this.
I tried putting a "!" in my string but it was rejected:
Had to leave out the !
ps: Is there any way to get a line wrap so that I can have two or more lines displayed in the xpm?
cheers!
I tried putting a "!" in my string but it was rejected:
Code: Select all
# ./text2xpm "Very clever Techno !" >/tmp/tmp.xpm
bash: !": event not found
#
ps: Is there any way to get a line wrap so that I can have two or more lines displayed in the xpm?
cheers!
- Attachments
-
- Screenshot.png
- (12 KiB) Downloaded 241 times
- technosaurus
- Posts: 4853
- Joined: Mon 19 May 2008, 01:24
- Location: Blue Springs, MO
- Contact:
I'll have to check the quotes in all the subfunctions... I just reworked the glyphs for vertically oriented text ... still not implemented, but here are the strings for them ... our forum still hasn't figured out {overflow:scroll} so it won't be readable until cut/pasted.
As for extra lines, I'll probably convert it to functions, so that each arg is a separate line, then a wrapper can split the arguments by something like:
(oh yeah, this forum also adds spaces to each line, so delete the space that it adds to IFS)
Copy/paste to editor to read
As for extra lines, I'll probably convert it to functions, so that each arg is a separate line, then a wrapper can split the arguments by something like:
(oh yeah, this forum also adds spaces to each line, so delete the space that it adds to IFS)
Code: Select all
IFS="
"
wrapper $Text
Copy/paste to editor to read
Code: Select all
" # "
" ###### # ### # ## #### # # ##### #### ## ## ### ####### ######## # ## ## ## ###### # # # ## ##### ########## # # # # ## # ########## ########## ######## #### ######## # #### ## ## ### # ######### #### ######### ## ## ### ## # ###### ##### # # ########## ### # # # # ###### # ## ######## # # ###### ###### ##### ##### ######### ## # # # ####### ### ###### ## ## ######## # # ## ####### # # # ## ### ## ## # ## # # # # # # # # # # # ## ## # # # # ## "
" # # # # ## # # # # # ########## # # # # # # # ## # # # # # # # # # # # # # # # # # # # # # # # # # # ######### # # # ## ## # # # # # ### # # # # # # # # ### # ## ## ## # # # # # # # # # # # # # # # # # ### # # # # # # # # # # # # # # # # # # # # # # # # ## # # # # # ## # # # # # # ########## # # # # # # # ### ## # # ##### # # # # # # # # # # ## # # # # #### # # # # ############## ## "
" # # ########## # # # # ## # # # # # # # # # # ## # # # # # # # # # # # # # # # # # # # # # # # # ########## # # # # # ## # # # # # # # # # ## # # # ########## # ### ### ## ##### # ## # # # # # # # # # # # # # # # # # # # # ## ####### # # # ########## ##### # # # # # # # # # # # # # # ## #### # # # # # # # ####### ## # # # # # # ########### #### # # # # # # # ## ## ## ## # ####### # # # # # # # ### ### ### # ### ## ## ### #### ### ### ##### ##### ##### ##### # ## # ## #############"
" # # # # # # # # # # ## # # # # # # # # ## # # # # # # # # # # # # # # # # # # # # # # # # # # # # # ## # # # # # # # # # # # # # # # ### # ## ## # # # # # # # # # # # # # # # ######### # # # # # # # # ## # # # # # # # # # # # # # # ######### # ## # # # # # ## # # # #### # ########## # # # # # #### # # ## # ##### # # # # # # # # # # # # # # ## # ## # # # # #### # # ############### # ### "
" # # # # # ## # # ## # # # # # # # # ## # # # # # # # # # # # # # # # # # # # # # # # # # # # # # ## ## # # # # # # # # # # # # # # ### ######### ## ## ### # ## # # # # # # # # # # # # # # # ## # # # ## # # ####### # # # # # # # # # # # # # ### ###### # # # # # ## # # # # # # # # # # # # ### # # # # # # # # # # # # ## # # # # # ## "
" ###### ## # # ## ## ##### ## ####### # ## ### #### ## ######## ########## ######## ########## ########## ########## ######## ########## ## ########## ########## ########## ########## ######## ########## ######## ########## ### ## # ######### #### ## ## # ## # ## ########## ##### ##### ##### # ### ## ########## ########## ####### ##### ######### ##### ####### # # # ###### ## ## ##### # # # ## ###### ## ## ## ## # ### # # # ## ## ## "
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].
- mister_electronico
- Posts: 969
- Joined: Sun 20 Jan 2008, 20:20
- Location: Asturias_ España
- Contact:
very good post.
I had no knowledge of this post, The script that converts the text string on points with so few lines of code is so clever. and conversion to xpm image not just to understand it at all is great.
Technosaurus can you let me copy you code, to I try to improve my make_dots script?
Very good post..... thanks.
Technosaurus can you let me copy you code, to I try to improve my make_dots script?
Very good post..... thanks.
I tried grafting them in (hoping for a miracle despite the fact you said it's not implemented yet ) and notice that the dots are missing (replaced by spaces instead?). Is that as expected?technosaurus wrote: I just reworked the glyphs for vertically oriented text ... still not implemented, but here are the strings for them
Ash tells me:
Code: Select all
# ./text2xpm "your text here" >/tmp/tmp.xpm
ash: bad number
#
- Attachments
-
- txt2xpm_vert.jpg
- (113.88 KiB) Downloaded 198 times
- technosaurus
- Posts: 4853
- Joined: Mon 19 May 2008, 01:24
- Location: Blue Springs, MO
- Contact:
It was supposed to be dots, I just converted it to 1s and 0s and screwed up when I switched it back... though the spaces are more readable.greengeek wrote:I tried grafting them in (hoping for a miracle despite the fact you said it's not implemented yet ) and notice that the dots are missing (replaced by spaces instead?). Is that as expected?technosaurus wrote: I just reworked the glyphs for vertically oriented text ... still not implemented, but here are the strings for them
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].
So..
If you would have an extra set of 10 characters that would mimic graph states, like for instance a zero readout would only be dots, and a 1 value would be a row of 6 fills on row 11 (or K) only, and a 2 value would be a row of 6 fills on row 11 plus a row of 6 fills on row 10 (J), and so on and so on, would you then also have a tool for displaying graphs, be it very elementary?!
If you would have an extra set of 10 characters that would mimic graph states, like for instance a zero readout would only be dots, and a 1 value would be a row of 6 fills on row 11 (or K) only, and a 2 value would be a row of 6 fills on row 11 plus a row of 6 fills on row 10 (J), and so on and so on, would you then also have a tool for displaying graphs, be it very elementary?!
- technosaurus
- Posts: 4853
- Joined: Mon 19 May 2008, 01:24
- Location: Blue Springs, MO
- Contact:
At one point I combined this with my xpm percentbar generator... I can only seem to find the standalone percent bar function though (in bashbox), so I will just post it here for now.
I also reworked partview to use it here.
I also reworked partview to use it here.
Code: Select all
percentbar() { #usage: "$0" XX% name=filename fgcolor=XXX bgcolor=XXX height=XXX width=XXX [vertical]
FILENAME=barimage
FGCOLOR=\#000
BGCOLOR=None
PERCENT=50
WIDTH=100
HEIGHT=24
BARSTRING=""
q=0 #should have used for loops
y=0 #not while loops - oops
#get values from input
for x in $@; do
case $x in
width*)WIDTH=`echo $x |cut -d = -f 2`;;
height*)HEIGHT=`echo $x |cut -d = -f 2`;;
fg*)FGCOLOR=`echo $x |cut -d = -f 2`
[ "$FGCOLOR" != "None" ] && FGCOLOR=\#$FGCOLOR;;
bg*)BGCOLOR=`echo $x |cut -d = -f 2`
[ "$BGCOLOR" != "None" ] && BGCOLOR=\#$BGCOLOR;;
name*)FILENAME=`echo $x |cut -d = -f 2`;;
*%)PERCENT=`echo $x |cut -d % -f 1`;;
vert*)VERTICAL="true";;
*) echo "usage "$0" XX% name=filename fgcolor=XXX bgcolor=XXX height=XXX width=XXX [vertical]
colors can be 3 or 6 digit hexadecimal or None ... default is horizontal bars" && exit
;;
esac
done
#write header to file
echo '/* XPM */' >${FILENAME}.xpm
echo 'static char *'$FILENAME'_xpm[] = {' >>${FILENAME}.xpm
echo '"'$WIDTH $HEIGHT '2 1",' >>${FILENAME}.xpm
echo '"0 c '$BGCOLOR'",' >>${FILENAME}.xpm
echo '"1 c '$FGCOLOR'",' >>${FILENAME}.xpm
if [ "$VERTICAL" == "true" ];then #vertical bars
BARTOP=$(($HEIGHT*$PERCENT/100))
#generate each line of the image
while [ "$q" -lt $HEIGHT ]; do
q=$(($q + 1))
if [ "$q" -lt $BARTOP ];then
while [ "$z" -lt $WIDTH ]; do
BARSTRING=${BARSTRING}0
z=$(($z + 1))
done
else
while [ "$z" -lt $WIDTH ]; do
BARSTRING=${BARSTRING}1
z=$(($z + 1))
done
fi
echo '"'$BARSTRING'"' >>${FILENAME}.xpm
BARSTRING=""
z=0
done
else #horizontal bars
#generate one line of the image
BARMAX=$(($WIDTH*$PERCENT/100))
while [ "$q" -lt $BARMAX ]; do
q=$(($q + 1))
BARSTRING=${BARSTRING}1
done
while [ "$q" -le $WIDTH ]; do
BARSTRING=${BARSTRING}0
q=$(($q + 1))
done
#write a line for each pixel of height
while [ "$y" -le $HEIGHT ]; do
echo '"'$BARSTRING'"' >>${FILENAME}.xpm
y=$(($y + 1))
done
fi
echo '};' >>${FILENAME}.xpm
}
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].
- technosaurus
- Posts: 4853
- Joined: Mon 19 May 2008, 01:24
- Location: Blue Springs, MO
- Contact:
Re: very good post.
All of my code is under the Technosaurus Public License which basically says you can do whatever you want with it, but don't expect me to contribute back to it if you put it under a viral license like those of the FSF (GPL, LGPL, AGPL,...)mister_electronico wrote:Technosaurus can you let me copy you code, to I try to improve my make_dots script?
Very good post..... thanks.
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].
Just for fun I converted text2xpm to C. No other reason. It's basically useless, just an exercise.
Also attached is statically compiled version that should run on most x86 and x86_64 linux OS.
EDIT: updated source, removed crap from a previous attempt
Also attached is statically compiled version that should run on most x86 and x86_64 linux OS.
EDIT: updated source, removed crap from a previous attempt
- Attachments
-
- texttoxpm.gz
- binary -renamed so it doesn't conflict
- (11.13 KiB) Downloaded 147 times
-
- text2xpm.c.gz
- source
- (1.71 KiB) Downloaded 153 times
Puppy Linux Blog - contact me for access
- technosaurus
- Posts: 4853
- Joined: Mon 19 May 2008, 01:24
- Location: Blue Springs, MO
- Contact:
that's pretty ironic... I initially wrote it in c and ported it to shell as an exercise.01micko wrote:Just for fun I converted text2xpm to C. No other reason. It's basically useless, just an exercise.
Also attached is statically compiled version that should run on most x86 and x86_64 linux OS.
EDIT: updated source, removed crap from a previous attempt
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].
- mister_electronico
- Posts: 969
- Joined: Sun 20 Jan 2008, 20:20
- Location: Asturias_ España
- Contact:
Use the same License.
Technosaurus wrote
I use the same license, never earn a penny with my code and never will win, it's just for fun.
Thanks Technosaurus.
Code: Select all
All of my code is under the Technosaurus Public License which basically says
you can do whatever you want with it, but don't expect me to contribute back
to it if you put it under a viral license like those of the FSF (GPL, LGPL, AGPL,...)
Thanks Technosaurus.
Hi mick, excuse my ignorance - I tried to run the .c file you uploaded first and got variety of errors. Then I realised it was "source" so I must be using it wrong. I previously thought I should be able to run a C file much the same as a bash file - but that's obviously incorrect (even though I'm sure I have sometimes clicked on a C file and it has run perfectly...).01micko wrote:EDIT: updated source, removed crap from a previous attempt
What should I have done with the .c source file please?
cheers!
(ps I did use the texttoxpm.gz file successfully)
greengeek wrote:Hi mick, excuse my ignorance - I tried to run the .c file you uploaded first and got variety of errors. Then I realised it was "source" so I must be using it wrong. I previously thought I should be able to run a C file much the same as a bash file - but that's obviously incorrect (even though I'm sure I have sometimes clicked on a C file and it has run perfectly...).
No, you can't 'run' a C source file. It contains code that needs to be 'compiled'. Our stock C compiler is gcc (in the devx). Maybe you were thinking of python or perl (.py or .pl)? Some of those might work by clicking them.
To compile it (and this is the most simple form - do some homework if you want to get the exec with the name of your choice) simply run this:greengeek wrote:What should I have done with the .c source file please?
cheers!
(ps I did use the texttoxpm.gz file successfully)
Code: Select all
gcc text2xpm.c
--
Sorry for OT techno.. should have gone to my 'Fun with C' thread.
Puppy Linux Blog - contact me for access