text2conky

Window managers, icon programs, widgets, etc.
Post Reply
Message
Author
stemsee

text2conky

#1 Post by stemsee »

This script opens a yad entry box into which you can type what you want. After hitting enter the text will be displayed on the right of your screen. If there are spaces between words they will be replaced by line breaks (carraige return) for vertical top down display. Otherwise use underscore to force single line.

Change font size to suit.

Need help to achieve transparency.

Good for messaging someone sat behind you!!

Code: Select all

#!/bin/sh
killall conky
while true
do
STUFF=`yad --geometry=200x40 --entry`
ret=$?
[[ $ret > 0 ]] && exit 0
kill $conkpid
conky -x 10 -y 20 -t "`printf %s\\\n $STUFF | tr ' ' '\n'`" -f sans:size=80 &
conkpid=$!
done
Attachments
text2conky.png
(51.8 KiB) Downloaded 407 times

User avatar
drunkjedi
Posts: 882
Joined: Mon 25 May 2015, 02:50

#2 Post by drunkjedi »

Do you have feh installed?
It's needed for transparency to work.
Also need ""own_window_type override" in conkyrc.

Please go through following Conky with Lua Thread

You can find my desktop screenshot on it's last page.

Feh is wallpaper setter, conky uses it to show wallpaper to give illusion of transparency.[/url]

stemsee

#3 Post by stemsee »

thanks drunkjedi!

Yes feh is installed. I got it working by changing in conky.conf

Code: Select all

own_window yes
to

Code: Select all

own_window no
I have updated the code so that there are three functions.

Function one is text2conky which posts what ever you type and return. Full stop is a line break. in this way multiple multi-word lines (8) can fill the screen with text. Starts on the left.

Function two is text2conky auto, which posts word by word what you typed and returned top left of screen. Good for countdowns or infos. Loops until new or function one is initiated.

Function three is text2conky file, which always loads /root/text2conky copying it to tmp first. This is read line by line and posted on the right.

Code: Select all

#!/bin/sh
#text2conky by stemsee (c) 2016
killall conky
#text2conky

if [[ "$1" = auto ]]; then
STUFF=`yad --geometry=200x40+600+600 --entry`
ret=$?
[[ $ret > 0 ]] && exit 0

while true
do
for i in $STUFF
do	
	kill $conkpid
	killall conky
	conky -x 10 -y 40 -t "`printf %s\\\n $i | tr ' ' '\n'`" -f sans:size=200 -a top_right &
	conkpid=$!
	sleep 3
done
done
elif [[ "$1" = file ]]; then
geany ~/text2conky
[[ -f ~/text2conky ]] && cp -f ~/text2conky /tmp/
while true
do
while read line
do
killall conky
	conky -x 10 -y 40 -t "$line" -f sans:size=120 &
	conkpid=$!
	sleep 3
kill $conkpid
done < /tmp/text2conky
done
else
while true
do
STUFF=`yad --geometry=200x40 --entry`
ret=$?
[[ $ret > 0 ]] && exit 0
kill $conkpid
killall conky
conky -x 10 -y 10 -t "`printf %s\\\n $STUFF | tr '\n' ' ' | tr '.' '\n'`" -f sans:size=90 &
conkpid=$!
done
fi
control script. /usr/sbin/ktext2conky

Code: Select all

#!/bin/sh
killall text2conky
killall conky
text2conky
I spent thee day trying to get the shade contour and defaut colors to rotate or randomise! Didn't quite get that working with nested loops! Ended up with a seized-up-ram bloated brick!
Attachments
text2conky.png
(220.36 KiB) Downloaded 353 times

User avatar
smokey01
Posts: 2813
Joined: Sat 30 Dec 2006, 23:15
Location: South Australia :-(
Contact:

#4 Post by smokey01 »

stemsee, the "killall conky" will kill all current instances of running conky's.

Did you know you can run multiple instances of conky with different config files?

stemsee

#5 Post by stemsee »

Hi Smokey01

I became aware of the option to use other configs today as I was 'improving' the script. And I have wbar running and it isn't affected by killall conky and there is also another widget which doesn't suffer, but yeah, the conky resources panel is compromised. I am new to this arena and as usual like a bull in a china shop. Some finesse will come as I am made aware of consequences!

Although there has been a lot of work completed by others in developing widgets etc with conky, I myself can only glean a few tidbits as they are offered.

cheers

stemsee

stemsee

#6 Post by stemsee »

I have refined this a bit by adding auto line wrap according to screen res and font size and also the count of thin characters i,l,j. Also changed line break character to ']' instead of '.' Which means '.' can now be used normally.

Code: Select all

#!/bin/sh
#killall text2conky
killall conky
#text2conky

if [[ "$1" = auto ]]; then
STUFF=`yad --geometry=200x40+600+600 --entry`
ret=$?
[[ $ret > 0 ]] && exit 0

while true
do
for i in $STUFF
do	
	kill $conkpid
	killall conky
	conky -x 10 -y 40 -t "`printf %s\\\n $i | tr ' ' '\n'`" -f sans:size=200 -a top_right &
	conkpid=$!
	sleep 2
done
done
elif [[ "$1" = file ]]; then
geany ~/text2conky
[[ -f ~/text2conky ]] && cp -f ~/text2conky /tmp/
while true
do
while read line
do
killall conky
	conky -x 10 -y 40 -t "$line" -f sans:size=120 &
	conkpid=$!
	sleep 2
kill $conkpid
done < /tmp/text2conky
done
else
while true
do
STUFF=`yad --geometry=200x40 --entry`
ret=$?
[[ $ret > 0 ]] && exit 0
kill $conkpid
killall conky
f=88
w=`xrandr | head -1 | cut -f2 -d',' | cut -f3 -d' '`
cn=$((((w / f) * 24) / 18))
num=`echo "$STUFF" |  awk 'BEGIN{FS="i"} {print NF?NF-1:0}'`
num2=`echo "$STUFF" | awk 'BEGIN{FS="l"} {print NF?NF-1:0}'`
num3=`echo "$STUFF" | awk 'BEGIN{FS="j"} {print NF?NF-1:0}'`
num4=`echo "$STUFF" |  awk 'BEGIN{FS="I"} {print NF?NF-1:0}'`
num=$((num2 + num + num4))
if [[ $num > 3 ]]; then
num=$((num / 2))
fi
cn=$((cn + num))
conky -x 00 -y 00 -t "`printf %s\\\n $STUFF | tr '\n' ' ' | fold -w$cn | tr ']' '\n'`" -f sans:size=$f -a top_left &
conkpid=$!
done
fi

stemsee

#7 Post by stemsee »

Added a more useful yad gui. Entry boxes for text wether for 'live' or 'auto': live posts what you type with auto line wrapping. Auto posts what you have typed word by word, a space is the fs. File opense geany to edit a text file with lines of text, displayed er line by line.

Position of text can be top left/middle/right, middle /left/middle/right, bottom left/middle/right.
Size can be selected or specified.

Time to display each item can be selected or specified.

updated code

Code: Select all

#!/bin/sh

#text2conky by stemsee (c) 2016
#
function input () {
STUFF=$(yad --columns=1 --title "text2conky: configurator" --form --item-separator="," --field="Live Input" "" --field="Auto Cycle"  "" --field="Size":CBE "88,11,22,33,44,55,66,77,88,99,111,121,131,141,151,161,171,181,191,222,333,444,555,666,777,888" --field=File:CHK "" --field=top:CHK "TRUE" --field=right:CHK "" --field=middle:CHK "" --field=frequency:CBE "0.8,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1,1.5,2,2.5,3,4" --button="gtk-ok:0" --button="gtk-close:1")
ret=$?
[[ $ret > 0 ]] && exit 0
f=`echo "$STUFF" | cut -f3 -d'|'`
lf=`echo "$f" | cut -c1`
if [ "$lf" = l ]; then
	f=`echo "$f" | cut -c2,3,4,5,6,7,8,9,10`
elif [ "$lf" = r ]; then
	f=`echo "$f" | cut -c2,3,4,5,6,7,8,9,10`
fi
STUFF1=`echo "$STUFF" | cut -f1 -d'|'`
STUFF2=`echo "$STUFF" | cut -f2 -d'|'`
STUFF3=`echo "$STUFF" | cut -f4 -d'|'`
STUFF4=`echo "$STUFF" | cut -f5 -d'|'`
STUFF5=`echo "$STUFF" | cut -f6 -d'|'`
STUFF6=`echo "$STUFF" | cut -f7 -d'|'`
STUFF7=`echo "$STUFF" | cut -f8 -d'|'`

if [[ "$STUFF4" = TRUE && "$STUFF5" = FALSE && "$STUFF6" = FALSE ]]; then
	pre=top
	suf=left
elif [[ "$STUFF4" = TRUE && "$STUFF5" = TRUE && "$STUFF6" = FALSE ]]; then
	pre=top
	suf=right
elif [[ "$STUFF4" = FALSE && "$STUFF5" = FALSE && "$STUFF6" = TRUE ]]; then
	pre=middle
	suf=middle
elif [[ "$STUFF4" = TRUE && "$STUFF5" = FALSE && "$STUFF6" = TRUE ]]; then
	pre=top
	suf=middle
elif [[ "$STUFF4" = FALSE && "$STUFF5" = TRUE && "$STUFF6" = TRUE ]]; then
	pre=bottom
	suf=middle
elif [[ "$STUFF4" = FALSE && "$STUFF5" = FALSE && "$STUFF6" = FALSE ]]; then
	pre=bottom
	suf=left
elif [[ "$STUFF6" = TRUE && "$lf" = r ]]; then
	pre=middle
	suf=right
elif [[ "$STUFF6" = TRUE && "$lf" = l ]]; then
	pre=middle
	suf=left
elif [[ "$STUFF4" = FALSE && "$STUFF5" = TRUE && "$STUFF6" = FALSE ]]; then
	suf=right
	pre=bottom
fi

pos="$pre"_"$suf"

}
export -f input
input

if [[ ! -z "$STUFF2" ]]; then
function auto () {
while true
do
for i in $STUFF2
do	
	killall conky
	conky -x 10 -y 40 -t "`printf %s\\\n $i | tr ' ' '\n'`" -f sans:size=$f -a $pos &
	conkpid=$!
	sleep $STUFF7
	kill $conkpid
done
done

}
export -f auto
auto
fi

if [[ "$STUFF3" = TRUE ]]; then
function file () {
geany ~/text2conky
[[ -f ~/text2conky ]] && cp -f ~/text2conky /tmp/
while true
do
while read line
do
killall conky
	conky -x 10 -y 40 -t "$line" -f sans:size=$f -a $pos &
	conkpid=$!
	sleep $STUFF7
kill $conkpid
done < /tmp/text2conky
done
}
export -f file
file
fi

if [[ ! -z "$STUFF1" ]]; then
function live () {
while true
do
kill $conkpid
killall conky
w=`xrandr | head -1 | cut -f2 -d',' | cut -f3 -d' '`
cn=$((((w / f) * 24) / 18))
num=`echo "$STUFF1" |  awk 'BEGIN{FS="i"} {print NF?NF-1:0}'`
num2=`echo "$STUFF1" | awk 'BEGIN{FS="l"} {print NF?NF-1:0}'`
num3=`echo "$STUFF1" | awk 'BEGIN{FS="j"} {print NF?NF-1:0}'`
num4=`echo "$STUFF1" |  awk 'BEGIN{FS="I"} {print NF?NF-1:0}'`
num=$((num2 + num + num4))
if [[ $num > 3 ]]; then
	num=$((num / 2))
fi
cn=$((cn + num))
conky -x 00 -y 00 -t "`printf %s\\\n $STUFF1 | tr '\n' ' ' | fold -w$cn | tr ']' '\n'`" -f sans:size=$f -a $pos &
conkpid=$!
input
done

}
export -f live
live
fi
Attachments
t2c.png
(49.71 KiB) Downloaded 290 times
screeny.png
(161.65 KiB) Downloaded 291 times

Post Reply