| Author |
Message |
Lobster
Official Crustacean

Joined: 04 May 2005 Posts: 15109 Location: Paradox Realm
|
Posted: Wed 01 Feb 2012, 08:25 Post subject:
ticker tape PNN - Puppy News Network |
|
this is my latest almost masterpiece of bash
It does not quite work
The idea is to call any text in advert (as the example)
and display on screen, one character after another - a bit like a ticker tape
- As I am such a useless programmer I will have to resign from Puppy hacker school
http://puppylinux.org/wikka/PuppySchoolProgramming
There must be a simpler more efficient way to use yaf-splash to achieve this?
Grateful for any help.
Do I need an array (whatever that is)?
code and text file enclosed as a tar file
| Code: | #!/bin/bash
# Lobster Jan 2012 yellow autocue using yaf-splash
# will read the text file "advert"
# and display one character after another
INPUT=advert
clear
#plainchar=" "
while IFS= read -r -n 100 char
do
# display one character at a time
sleep 0.05
yaf-splash -bg yellow -fontsize x-large -timeout 1 -text $char
# yaf-splash -bg yellow -fontsize x-large -timeout 1 -text $plainchar
done < "$INPUT" |
| Description |
|

Download |
| Filename |
scroller.tar.gz |
| Filesize |
421 Bytes |
| Downloaded |
113 Time(s) |
_________________ Puppy WIKI
Last edited by Lobster on Fri 03 Feb 2012, 18:20; edited 1 time in total
|
|
Back to top
|
|
 |
SFR

Joined: 26 Oct 2011 Posts: 572
|
Posted: Wed 01 Feb 2012, 09:03 Post subject:
|
|
I wasn't able to run your script (and I don't fully understand some commands in it, 'coz I'm relatively new to Bash ), therefore I'm not sure, if this is what you want to achieve..?
| Code: | #!/bin/bash
# Scroll using yaf-splash example
INPUT=" Hello World..." # or INPUT=`cat sometextfile` for external text
WIDTH=5 # width of scroll
LEN=${#INPUT}
for i in `seq 0 $LEN`; do
TEXT="${INPUT:$i:$WIDTH}"
yaf-splash -bg yellow -fontsize x-large -timeout 1 -text "$TEXT"
done |
It works, but the annoying thing is that this yellow box dissapears for a second after every refresh...
BTW, thanks for introducing this "yaf-splash" thing for me, good to know for future use
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
|
|
 |
Lobster
Official Crustacean

Joined: 04 May 2005 Posts: 15109 Location: Paradox Realm
|
Posted: Wed 01 Feb 2012, 10:49 Post subject:
|
|
Hi - many thanks
Ah new code and it works and easy to understand . . .
From your code I guess you are more used to BASIC?
Now how do we get rid of that flashing . . . ?
We have worlds to subjugate . . .
Here are some changes - I now see this as leading to a daily or occasional messaging for those who opt in . . .
| Code: | #!/bin/bash
# Scroll using yaf-splash example
INPUT=" Welcome to Puppy. We are the Dorg. Resistance is Futile. Prepare to be Puppied" # or INPUT=`cat sometextfile` for external text
WIDTH=20 # width of scroll
LEN=${#INPUT}
for i in `seq 0 $LEN`; do
TEXT="${INPUT:$i:$WIDTH}"
yaf-splash -bg yellow -fg red -fontsize x-large -timeout 1 -placement bottom -text "$TEXT"
done
|
_________________ Puppy WIKI
|
|
Back to top
|
|
 |
SFR

Joined: 26 Oct 2011 Posts: 572
|
Posted: Wed 01 Feb 2012, 16:14 Post subject:
|
|
| Lobster wrote: | | From your code I guess you are more used to BASIC? |
I bet you've deduced it from "LEN" and "for i in `seq 0 $LEN`", right?
Yup, I fiddled with BASIC first, and later mainly Assembler on c64.
And now I have started "the new beginning" with Bash/Gtkdialog.
I can't find any way to get rid of this flashing. And the second thing is that yaf-splash can refresh for 1 sec minimum. A bit too slow...
But I think we could also try Gtkdialog-Desklet to display borderless and transparent window with scroller.
But on the other hand it's not implemented in every Puppy...
Any other ideas?
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
|
|
 |
SFR

Joined: 26 Oct 2011 Posts: 572
|
Posted: Thu 02 Feb 2012, 17:12 Post subject:
|
|
Ok, another approach...
This time I used text2svg routine from this post.
Font changed to Monospace and no spaces allowed, to preserve smoothness of scrolling.
Most of parameters are now scattered all over the code and hard to tweak, sorry.
The important parameter is X window position in here:
gtkdialog -G 0x0+450+0 -p MAIN
450 is good for my 1366x768 screen resolution.
Yeah, I know - if I lived in a country ruled by programmers, I'd be sentenced to death for this code...
| Code: | #!/bin/bash
# =================================
# Scroller - The Next Generation ;)
# =================================
echo -n "0" > /tmp/scroll_var
# a bit tweaked text2svg() function
text2svg()
{
#generate an image
WIDTH=$(($(echo "$1"|wc -c)*19))
T=35
BG="$2"
echo '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<rect width="'$WIDTH'"
height="50"
x="10"
y="0"
style="font-size:'${T}';fill:'$BG';fill-opacity:0.35;fill-rule:evenodd;stroke-width:3pt;"
id="rect1" />
<text
x="0"
y="35"
style="font-size:'${T}';font-weight:normal;fill-opacity:0.75;stroke-width:3pt;font-family:monospace;"
id="text1">
<tspan
id="tspan1">'"${1}"'</tspan>
</text>
</svg>' > /tmp/${3}.svg
}
export -f text2svg
scroll (){
INPUT="Welcome_to_Puppy._We_are_the_Dorg._Resistance_is_Futile._Prepare_to_be_Puppied"
INPUT="____________________"$INPUT"____________________"
LEN=${#INPUT}
WIDTH="40"
I=`cat /tmp/scroll_var`
TEXT="[""${INPUT:$I:20}""]"
text2svg "${TEXT}" "#ADD8E6" scroller
I=$(($I+1))
if [ "$I" == "$(($LEN-20))" ]; then I=0;fi
echo -n $I > /tmp/scroll_var
}
export -f scroll
export MAIN='
<window decorated="false">
<vbox>
<pixmap>
<variable>PIX</variable>
<input file>/tmp/scroller.svg</input>
</pixmap>
<hbox>
<progressbar visible="true">
<input>echo 100</input>
</progressbar>
<button width-request="150"><label>Assimilate!</label></button>
<progressbar visible="true">
<input>while [ A = A ]; do sleep 0.2; echo 99; echo 100; done</input>
<action>scroll</action>
<action>refresh:PIX</action>
</progressbar>
</hbox>
</vbox>
</window>
'
scroll
gtkdialog -G 0x0+450+0 -p MAIN
rm -f /tmp/*.svg
rm -f /tmp/scroll_var
TEST=`ps | grep while | grep sleep | grep done | cut -d"r" -f 1`
kill $TEST
# END |
EDIT: changed echo 0 --> echo 99 - less flashing progressbar...and removed unnecessary touch /tmp/scroll_var line...
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
|
|
 |
Lobster
Official Crustacean

Joined: 04 May 2005 Posts: 15109 Location: Paradox Realm
|
Posted: Thu 02 Feb 2012, 21:46 Post subject:
|
|
Gtkdialog-Desklet I like for the transparency
The code which could result in death
I liked the font the excellent non flashing and font
but not the window decoration or the code
I appreciate your ideas . . .
May have to look at Bacon or C
Once the messaging is in place the idea is to call
info when online - maybe a weekly news or updates
_________________ Puppy WIKI
|
|
Back to top
|
|
 |
seaside
Joined: 11 Apr 2007 Posts: 837
|
Posted: Fri 03 Feb 2012, 12:54 Post subject:
|
|
sfr,
Nicely done gtkdialog scroller and I'll bet you hated placing underlines between the words
For pure simplicity, it's a shame we don't have this html tag solution. | Code: | <marquee>Here's the scrolling text</marquee>
|
Wait, maybe we do.... can you call some html code with a minimal browser straight to an undecorated window...
Cheers,
s
|
|
Back to top
|
|
 |
SFR

Joined: 26 Oct 2011 Posts: 572
|
Posted: Fri 03 Feb 2012, 16:42 Post subject:
|
|
| Lobster wrote: | | May have to look at Bacon or C |
Right, probably BaCon/C could provide the most efficient way to achieve a good looking, smooth scroller...
I must begin to learn it at last (but I have brain torsion when I see C code ).
or...
| seaside wrote: | Nicely done gtkdialog scroller and I'll bet you hated placing underlines between the words
For pure simplicity, it's a shame we don't have this html tag solution.
| Code: | | <marquee>Here's the scrolling text</marquee> |
Wait, maybe we do.... can you call some html code with a minimal browser straight to an undecorated window... |
You are reading my mind!
Since yesterday I'm searching the way to launch HTML code in self sized/placed and undecorated window.
<marquee> would be a very clean & aesthetic solution.
But I'm stuck for now.
Eg. Semonkey/Firefox do not have any X/Y/width/height/ command line parameters.
Unless I'll try to dig out something useful from the hundreds of lines of "about:config"
Is there any other way to do it..?
| Lobster wrote: | Once the messaging is in place the idea is to call
info when online - maybe a weekly news or updates |
I support this idea, would be great to receive:
"PNN* - Breaking News: the new version of your favourite Puppy is available now!"
* PNN = Puppy News Network
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
|
|
 |
Lobster
Official Crustacean

Joined: 04 May 2005 Posts: 15109 Location: Paradox Realm
|
Posted: Fri 03 Feb 2012, 18:10 Post subject:
|
|
| Quote: | | Wait, maybe we do.... can you call some html code with a minimal browser straight to an undecorated window... |
well the code is easy from a bit of hacked javascript
http://tmxxine.com/news/.
_________________ Puppy WIKI
|
|
Back to top
|
|
 |
SFR

Joined: 26 Oct 2011 Posts: 572
|
Posted: Fri 03 Feb 2012, 19:08 Post subject:
|
|
| Lobster wrote: | | Quote: | | Wait, maybe we do.... can you call some html code with a minimal browser straight to an undecorated window... |
well the code is easy from a bit of hacked javascript
http://tmxxine.com/news/. |
Cool!
Works out-of-box with:
- Seamonkey 2.7
- Opera 11.57
Dillo doesn't support <marquee>, as I managed to figure out before, but I couldn't make it working with Chromium 17, Firefox 7.0 & Iron 15
Are these browsers have 'status bar' at all? Couldn't find one or I'm blind...
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
|
|
 |
Lobster
Official Crustacean

Joined: 04 May 2005 Posts: 15109 Location: Paradox Realm
|
Posted: Fri 03 Feb 2012, 19:17 Post subject:
|
|
Dillo may not support Javascript. Chromium and Iron probably have it off by default . . .
I just tried it on Seamonkey 2.7 in Saluki 009, which worked . . .
OK better go find some C code
_________________ Puppy WIKI
|
|
Back to top
|
|
 |
seaside
Joined: 11 Apr 2007 Posts: 837
|
Posted: Fri 03 Feb 2012, 19:52 Post subject:
|
|
How about Puppy-browser to the rescue...
| Code: | echo '<html>
<font size=+46 face="DejaVu Sans" color=red> <marquee>
- And Now For Something Different ...... -
</marquee> </font>
</html>' >/tmp/banner.html
/usr/local/PuppyBrowser/puppy-browser /tmp/banner.html -w=500 -h=500 -x=150 -y=50
|
It takes geometry, plays marquee and now if someone can figure out how to ditch the window decoration in /usr/local/PuppyBrowser/ - maybe theme.rc?
Cheers,
s
EDIT: Found this parameter -profile=fullscreen (seems slower) and hardcoded geometry
|
|
Back to top
|
|
 |
SFR

Joined: 26 Oct 2011 Posts: 572
|
Posted: Sat 04 Feb 2012, 08:33 Post subject:
|
|
Hmm, for an unknown reason <marquee> doesn't work for me in puppybrowser-1.1-lucid.pet
On the other hand it works in, eg. this version: http://dotpups.de/files/puppybrowser-tests/PuppyBrowser02-seamonkey-1.1.8-no_mailnews_412.sfs
...but this one has only width/height parameters, no X/Y and -profile.
BTW, I'm using Lupu-528.004
Anyway, my /root/.PuppyBrowser/profiles/fullscreen/settings.rc looks like this now:
| Code: | always_show_tabs=0
show_bookmarks=0
show_status=0
show_urlbar=0
use_tabs=0
show_no_bars=1
start_fullscreen=0 |
...and this code displays resized, widgetless (but still decorated) PuppyBrowser-1.1's window in the bottom-right corner of the screen, independently of current screen resolution:
| Code: | #!/bin/sh
WIDTH=500
HEIGHT=80
MESSAGE=" We're almost there... "
# Determine current screen resolution
RES=$(xrandr | grep "current" | cut -d 'c' -f1,3 | tr -cd 'x [:digit:]' | cut -d 'x' -f1,2)
MAXX=$(echo $RES | cut -d 'x' -f1,1)
MAXY=$(echo $RES | cut -d 'x' -f2,3)
X=$(($MAXX-$WIDTH))
Y=$(($MAXY-$HEIGHT))
# seaside's tweaked routine
echo '
<html>
<font size="+4" face="DejaVu Sans" color=red>
<marquee scrollamount="4" scrolldelay="50">'"$MESSAGE"'</marquee>
</font>
</html>' >/tmp/banner.html
/usr/local/PuppyBrowser/puppy-browser /tmp/banner.html -title="PNN" -profile=fullscreen -x=$X -y=$Y -w=$WIDTH -h=$HEIGHT
|
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
|
|
 |
seaside
Joined: 11 Apr 2007 Posts: 837
|
Posted: Sat 04 Feb 2012, 11:11 Post subject:
|
|
| SFR wrote: |
...and this code displays resized, widgetless (but still decorated) PuppyBrowser-1.1's window in the bottom-right corner of the screen, independently of current screen resolution:
| Code: | #!/bin/sh
WIDTH=500
HEIGHT=80
MESSAGE=" We're almost there... "
# Determine current screen resolution
RES=$(xrandr | grep "current" | cut -d 'c' -f1,3 | tr -cd 'x [:digit:]' | cut -d 'x' -f1,2)
MAXX=$(echo $RES | cut -d 'x' -f1,1)
MAXY=$(echo $RES | cut -d 'x' -f2,3)
X=$(($MAXX-$WIDTH))
Y=$(($MAXY-$HEIGHT))
# seaside's tweaked routine
echo '
<html>
<font size="+4" face="DejaVu Sans" color=red>
<marquee scrollamount="4" scrolldelay="50">'"$MESSAGE"'</marquee>
</font>
</html>' >/tmp/banner.html
/usr/local/PuppyBrowser/puppy-browser /tmp/banner.html -title="PNN" -profile=fullscreen -x=$X -y=$Y -w=$WIDTH -h=$HEIGHT
|
Greetings! |
SFR,
Your code on puppy 431 shows up in the upper left hand corner (and ignores xy coordinates). It is fullscreen (without decorations) at the WH size.
The version for pup 431 is "puppybrowser-0.5.1-1-pup4".
It seems there are a few variations around
Regards,
s
EDIT: I noticed that your /fullscreen/settings.rc has "start_fullscreen=0". Perhaps "start_fullscreen=1" might work.
|
|
Back to top
|
|
 |
SFR

Joined: 26 Oct 2011 Posts: 572
|
Posted: Sat 04 Feb 2012, 14:31 Post subject:
|
|
What a mess with those PuppyBrowsers, indeed.
It was so close...
"start-fullscreen=1" was by default and I've change it to "...=0" to disable fullscreen, but in your version might be inversely.
| Lobster wrote: | OK better go find some C code |
I found this snippet in C (?). It's about GTK#, but might be useful for someone.
Personally I've no idea what to do with that code...
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
|
|
 |
|