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
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
Code: Select all
# ./text2xpm "Very clever Techno !" >/tmp/tmp.xpm
bash: !": event not found
#
Code: Select all
IFS="
"
wrapper $Text
Code: Select all
" # "
" ###### # ### # ## #### # # ##### #### ## ## ### ####### ######## # ## ## ## ###### # # # ## ##### ########## # # # # ## # ########## ########## ######## #### ######## # #### ## ## ### # ######### #### ######### ## ## ### ## # ###### ##### # # ########## ### # # # # ###### # ## ######## # # ###### ###### ##### ##### ######### ## # # # ####### ### ###### ## ## ######## # # ## ####### # # # ## ### ## ## # ## # # # # # # # # # # # ## ## # # # # ## "
" # # # # ## # # # # # ########## # # # # # # # ## # # # # # # # # # # # # # # # # # # # # # # # # # # ######### # # # ## ## # # # # # ### # # # # # # # # ### # ## ## ## # # # # # # # # # # # # # # # # # ### # # # # # # # # # # # # # # # # # # # # # # # # ## # # # # # ## # # # # # # ########## # # # # # # # ### ## # # ##### # # # # # # # # # # ## # # # # #### # # # # ############## ## "
" # # ########## # # # # ## # # # # # # # # # # ## # # # # # # # # # # # # # # # # # # # # # # # # ########## # # # # # ## # # # # # # # # # ## # # # ########## # ### ### ## ##### # ## # # # # # # # # # # # # # # # # # # # # ## ####### # # # ########## ##### # # # # # # # # # # # # # # ## #### # # # # # # # ####### ## # # # # # # ########### #### # # # # # # # ## ## ## ## # ####### # # # # # # # ### ### ### # ### ## ## ### #### ### ### ##### ##### ##### ##### # ## # ## #############"
" # # # # # # # # # # ## # # # # # # # # ## # # # # # # # # # # # # # # # # # # # # # # # # # # # # # ## # # # # # # # # # # # # # # # ### # ## ## # # # # # # # # # # # # # # # ######### # # # # # # # # ## # # # # # # # # # # # # # # ######### # ## # # # # # ## # # # #### # ########## # # # # # #### # # ## # ##### # # # # # # # # # # # # # # ## # ## # # # # #### # # ############### # ### "
" # # # # # ## # # ## # # # # # # # # ## # # # # # # # # # # # # # # # # # # # # # # # # # # # # # ## ## # # # # # # # # # # # # # # ### ######### ## ## ### # ## # # # # # # # # # # # # # # # ## # # # ## # # ####### # # # # # # # # # # # # # ### ###### # # # # # ## # # # # # # # # # # # # ### # # # # # # # # # # # # ## # # # # # ## "
" ###### ## # # ## ## ##### ## ####### # ## ### #### ## ######## ########## ######## ########## ########## ########## ######## ########## ## ########## ########## ########## ########## ######## ########## ######## ########## ### ## # ######### #### ## ## # ## # ## ########## ##### ##### ##### # ### ## ########## ########## ####### ##### ######### ##### ####### # # # ###### ## ## ##### # # # ## ###### ## ## ## ## # ### # # # ## ## ## "
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
Code: Select all
# ./text2xpm "your text here" >/tmp/tmp.xpm
ash: bad number
#
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
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
}
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.
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
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,...)
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
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...).
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