ticker tape PNN - Puppy News Network

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Message
Author
User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

#31 Post by vovchik »

Dear guys,

I am enjoying the ideas here. If you don't really want to do any work, you could try this: http://www.murga-linux.com/puppy/viewto ... 401#602401.

It's good for standard RSS feeds, but I really like the idea of a tiny ticker along the lines of what we are sseing in this thread.

With kind regards,
vovchik

PS. The transparent rxvt version is fabulous. Thanks, technosaurus!

User avatar
SFR
Posts: 1800
Joined: Wed 26 Oct 2011, 21:52

#32 Post by SFR »

I'm back...
Another draft, this time with auto update and ON/OFF mechanism.
Now it's enought to click the script to turn it on, and click again to turn off.
Works in Openbox and JWM (Lupu-528).

But what about colors, size, placement, etc.?
I'm not good with decoration stuff...

Code: Select all

#!/bin/sh

PRECODELENGHT=25	 # This parameter is the number of lines from the very beginning to the "START" comment
                    # It MUST be very accurate to make the script working!!!

# checking if there's temporary scroll state file, create one if not           
if [ ! -f /tmp/scroller_state ]; then
  echo -n "OFF" > /tmp/scroller_state
fi

# checking if the script is working now: if yes - kill, if not - launch
ONOFFTEST=$(cat /tmp/scroller_state)
if [ "$ONOFFTEST" == "ON" ]; then
  kill $(cat /tmp/scroller_pid)			# kills scroller process
  echo -n "OFF" > /tmp/scroller_state
  rm -f /tmp/scroller_pid
  exit
else
  echo -n "ON" > /tmp/scroller_state
fi

tail -n +$PRECODELENGHT $0  > /tmp/scroller_temp.txt 
exec rxvt -foreground 7 -transparent -borderLess +sb -g 40x1+0+0 -fn 'xft:DejaVu Sans Mono-18:dpi=76' -e sh /tmp/scroller_temp.txt 

# START

# Here the main scroller's code starts

echo -ne "\033[?25l" # to disable cursor

# Get the message and add spaces in front of it
function getmessage () {
echo -n "UPDATING..."

MESSAGE=$(wget -q -O - "http://tmxxine.com/test2/t.txt")

for i in `seq 0 40`; do 
  MESSAGE=" "$MESSAGE
done

LEN=${#MESSAGE} 
POS=0
}

getmessage

echo -n $$ > /tmp/scroller_pid	# export PID into temp file

# Main loop

while true; do

  TEXT=${MESSAGE:$POS:40}
  POS=$(($POS+1)) 
  if [ "$POS" == "$LEN" ]; then POS=0; fi 
  echo 
  echo -n "$TEXT"
  
  # update check (every full hour)
  TEMP1=`date +%M`		# get current minute
  TEMP2=`date +%S`		# get current second
  if [ "$TEMP1" -eq 0 ] && [ "$TEMP2" -eq 0 ]; then
    getmessage
  fi
  
  sleep 0.2
  
done 

# The End
Greetings!
[color=red][size=75][O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource[/size][/color]
[b][color=green]Omnia mea mecum porto.[/color][/b]

User avatar
SFR
Posts: 1800
Joined: Wed 26 Oct 2011, 21:52

#33 Post by SFR »

Sorry, I didn't notice that before... I was in trance, perhaps I'm a "code-junkie"..? :shock:
I donwloaded the tool; very nice find, but can't achieve transparency (Openbox).
Anyway, I like it!

Ok, so the problem seems to be solved now..?
Thanks for the challenge - it was fun!

Take care & Greetings!
[color=red][size=75][O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource[/size][/color]
[b][color=green]Omnia mea mecum porto.[/color][/b]

seaside
Posts: 934
Joined: Thu 12 Apr 2007, 00:19

#34 Post by seaside »

SFR,

That is very impressive. Nice and compact. I still had hoped to get PuppyBrowser to work with newer pups since it works perfectly in pup431, so that the full use of the marquee tag could be exploited with all it's extra functions. Alas, it seems it is loathe to work on the newer ones.

Perhaps the rxvt command should be changed to urxvt, because sometimes it's a link to urxvt and sometimes not. (many extra functions in urxvt not in rxvt) :)

Regards,
s

User avatar
SFR
Posts: 1800
Joined: Wed 26 Oct 2011, 21:52

#35 Post by SFR »

seaside wrote:I still had hoped to get PuppyBrowser to work with newer pups since it works perfectly in pup431, so that the full use of the marquee tag could be exploited with all it's extra functions. Alas, it seems it is loathe to work on the newer ones.
...because it's a good idea, too!
I even was looking for a tiny browser with javascript (it's needed by <marquee>, am I right?) that could be compatibile with as many Puppies as possible.
I found Links2 - very, very nice one, but doesn't support <marquee> :(
seaside wrote:Perhaps the rxvt command should be changed to urxvt, because sometimes it's a link to urxvt and sometimes not. (many extra functions in urxvt not in rxvt)
Why not, it's just a single-letter modification :)
AFAIK urxvt = Unicode rxvt
Thanks to it shoud be possible to get diacritic characters...maybe multilanguage news..?

Greetings!
[color=red][size=75][O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource[/size][/color]
[b][color=green]Omnia mea mecum porto.[/color][/b]

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#36 Post by technosaurus »

SFR wrote:
seaside wrote:Perhaps the rxvt command should be changed to urxvt, because sometimes it's a link to urxvt and sometimes not. (many extra functions in urxvt not in rxvt)
Why not, it's just a single-letter modification :)
AFAIK urxvt = Unicode rxvt
Thanks to it shoud be possible to get diacritic characters...maybe multilanguage news..?

Greetings!
because you can't simply make a symlink for urxvt using a rxvt binary

if it is programmed/tested to work on rxvt, then it will more than likely work in urxvt with only a symlink, but not vice versa

its kinda like putting #!/bin/sh in a script that uses bashisms, when you add bashisms you should change it to #!/bin/bash ... likewise, when you add unicode, -hold, etc... that urxvt does not support then you _should _change rxvt to urxvt
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].

User avatar
SFR
Posts: 1800
Joined: Wed 26 Oct 2011, 21:52

#37 Post by SFR »

Thanks, I didn't know that.
So, I checked and in Lupu-528 rxvt IS a symlink for urxvt, and sh IS a symlink for bash.
...and I was wondering why everything works no matter it's #!/bin/sh or #!/bin/bash...

Code corrected:

Code: Select all

#!/bin/bash

PRECODELENGHT=25	# This parameter is the number of lines from the very beginning to the "START" comment
                    # It MUST be very accurate to make the script working!!!

# checking if there's temporary scroll state file, create one if not           
if [ ! -f /tmp/scroller_state ]; then
  echo -n "OFF" > /tmp/scroller_state
fi

# checking if the script is working now: if yes - kill, if not - launch
ONOFFTEST=$(cat /tmp/scroller_state)
if [ "$ONOFFTEST" == "ON" ]; then
  kill $(cat /tmp/scroller_pid)			# kills scroller process
  echo -n "OFF" > /tmp/scroller_state
  rm -f /tmp/scroller_pid
  exit
else
  echo -n "ON" > /tmp/scroller_state
fi

tail -n +$PRECODELENGHT $0  > /tmp/scroller_temp.txt 
exec urxvt -foreground 7 -transparent -borderLess +sb -g 40x1+0+0 -fn 'xft:DejaVu Sans Mono-18:dpi=76' -e sh /tmp/scroller_temp.txt 

# START

# Here the main scroller's code starts

echo -ne "\033[?25l" # to disable cursor

# Get the message and add spaces in front of it
function getmessage () {
echo -n "UPDATING..."

MESSAGE=$(wget -q -O - "http://tmxxine.com/test2/t.txt")

for i in `seq 0 40`; do 
  MESSAGE=" "$MESSAGE
done

LEN=${#MESSAGE} 
POS=0
}

getmessage

echo -n $$ > /tmp/scroller_pid	# export PID into temp file

# Main loop

while true; do

  TEXT=${MESSAGE:$POS:40}
  POS=$(($POS+1)) 
  if [ "$POS" == "$LEN" ]; then POS=0; fi 
  echo 
  echo -n "$TEXT"
  
  # update check (every full hour)
  TEMP1=`date +%M`		# get current minute
  TEMP2=`date +%S`		# get current second
  if [ "$TEMP1" -eq 0 ] && [ "$TEMP2" -eq 0 ]; then
    getmessage
  fi
  
  sleep 0.2
  
done 

# The End
Greetings!
[color=red][size=75][O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource[/size][/color]
[b][color=green]Omnia mea mecum porto.[/color][/b]

seaside
Posts: 934
Joined: Thu 12 Apr 2007, 00:19

#38 Post by seaside »

SFR wrote:
seaside wrote: I even was looking for a tiny browser with javascript (it's needed by <marquee>, am I right?) that could be compatibile with as many Puppies as possible.
I found Links2 - very, very nice one, but doesn't support <marquee> :(
seaside wrote:Perhaps the rxvt command should be changed to urxvt, because sometimes it's a link to urxvt and sometimes not. (many extra functions in urxvt not in rxvt)
Why not, it's just a single-letter modification :)
AFAIK urxvt = Unicode rxvt
Thanks to it shoud be possible to get diacritic characters...maybe multilanguage news..?

Greetings!
SFR,

<marquee> tag is html and doesn't require javascript. There are some implementations using javascript see-
http://www.htmlmarquee.com/

I mentioned the change to rxvt because in pup431 there is a rxvt binary and a separate urxvt binary. Whereas, in the newer puppies it seems that rxvt usually is only a symlink to urxvt as you discovered.

So when rxvt is used in pup431, it results thus...
rxvt -foreground 7 -transparent -borderLess
rxvt: bad option "-transparent"
rxvt: bad option "-borderLess"

And no problem using urxvt - so urxvt should always work.

Regards,
s
(Also, #!/bin/sh refers to the file "/bin/sh" which is a link to "/bin/bash" , while #!/bin/bash refers directly to bash- so everything works :) )

User avatar
Lobster
Official Crustacean
Posts: 15522
Joined: Wed 04 May 2005, 06:06
Location: Paradox Realm
Contact:

#39 Post by Lobster »

PS. The transparent rxvt version is fabulous. Thanks, technosaurus!
Did not work for me, bits of it did . . .
I could not incorporate this:

Code: Select all

rxvt -g 40x1+0+0 +sb -name xmessage -fn 'xft:DejaVu Sans Mono-28:dpi=76'
into something like this which requires a populated text file called autocue

Code: Select all

#!/bin/bash
# run from command line with ./Script
# will read the text file "autocue"
# and display one character after another 

INPUT=autocue

clear
while IFS= read -r -n1 char
do
   sleep 0.05
   echo -n "$char"
done < "$INPUT"
I used this a couple of years back in this video
but had to use the Sakura terminal to get large text
http://youtu.be/E4BqXF_ZXiY

I am using Saluki Beta 010 (based on Racy 5.2.2)

So how to get large text directly?
Puppy Raspup 8.2Final 8)
Puppy Links Page http://www.smokey01.com/bruceb/puppy.html :D

User avatar
Lobster
Official Crustacean
Posts: 15522
Joined: Wed 04 May 2005, 06:06
Location: Paradox Realm
Contact:

#40 Post by Lobster »

SFR the transparency is great - your code is working :)
BUT the off/on switch is not. :cry:

I will look at the code later but I thought I might add today's news first :)
Puppy Raspup 8.2Final 8)
Puppy Links Page http://www.smokey01.com/bruceb/puppy.html :D

User avatar
SFR
Posts: 1800
Joined: Wed 26 Oct 2011, 21:52

#41 Post by SFR »

Thanks seaside!
Achieving compability between different Puppies is more complex than I thought...
It's some kind of Sisyphean labor. :roll:
So if javascript has nothing to do with <marquee> there's still a chance to find working one.
More scroller versions = More fun :)

@Lobster:
It's odd...
I downloaded the latest Saluki (whoa, great progress since 006, by the way), and ON/OFF works, but has no transparency.
(might be because I launched it in VBox..?)
I tried Slacko either, everything's ok...

Greetings!
[color=red][size=75][O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource[/size][/color]
[b][color=green]Omnia mea mecum porto.[/color][/b]

User avatar
SFR
Posts: 1800
Joined: Wed 26 Oct 2011, 21:52

#42 Post by SFR »

Lobster, I encountered the failure of On/Off feature, at last.
It was because I tried to turn off the scroller too soon, before the message was loaded.
The line which exports PID was placed AFTER that. Now it's fixed.
Hope it was the same in your case, not something worse...

BTW, sometimes it takes two times to run the scroller, especially when it's turned off via ctrl+c instead of mouse-click.

Assuming everyone has it's own settings of panel(s) (top/bottom/vertical/horizontal) and different background colors,
I've added few easy-editable parameters in front of the script, to make it more friendly/customizable.

Code: Select all

#!/bin/bash 

# Scroller for "News Network"
# Requirements: Bash + urxvt + wget

TRANS="-"			  # Transparency On (-) or Off (+)
FORECOL=Blue		  # Foreground color (also: 0-15)
BACKCOL=White		 # Background color (also: 0-15)
LENGHT=20			  # Scroller lenght (in characters)
POSITIONX=0			# Scroller X position (in pixels)
POSITIONY=0			# Scroller Y position (in pixels)
#==============================================================================
PRECODELENGHT=37	 # This parameter is the number of lines from the very beginning to the "START" comment 
                    # It MUST be very accurate to make the script working!!! 

# Checking if there's temporary scroll state file - create one if not
       
if [ ! -f /tmp/scroller_state ]; then 
  echo -n "OFF" > /tmp/scroller_state 
fi 

# checking if the script is working now: if yes - kill, if not - launch

ONOFFTEST=$(cat /tmp/scroller_state)
if [ "$ONOFFTEST" == "ON" ]; then
  kill $(cat /tmp/scroller_pid)         # kills scroller process 
  echo -n "OFF" > /tmp/scroller_state 
  rm -f /tmp/scroller_pid 
  exit 
else 
  echo -n "ON" > /tmp/scroller_state 
fi 

tail -n +$PRECODELENGHT $0  > /tmp/scroller_temp.txt 
exec urxvt -fg "$FORECOL" -bg "$BACKCOL" "$TRANS"tr -bl +sb -g "$LENGHT"x1+"$POSITIONX"+"$POSITIONY" -fn 'xft:DejaVu Sans Mono-18:dpi=76' -e bash /tmp/scroller_temp.txt 

# START 

# Here the main scroller's code starts 

echo -n $$ > /tmp/scroller_pid	# Export PID into temp file
WINLEN=$(tput cols)				# Get current number of columns
echo -ne "\033[?25l" 			# Disable cursor 

# Get the message and add spaces in front of it

function getmessage () { 
echo -n "UPDATING..." 

MESSAGE=$(wget -q -O - "http://tmxxine.com/test2/t.txt") 

for i in `seq 0 $WINLEN`; do 
  MESSAGE=" "$MESSAGE 
done 

LEN=${#MESSAGE} 
POS=0 
} 

getmessage 
 
# Main loop 

while true; do 

  TEXT=${MESSAGE:$POS:$WINLEN} 
  POS=$(($POS+1)) 
  if [ "$POS" == "$LEN" ]; then POS=0; fi 
  echo 
  echo -n "$TEXT" 
  
  # update check (every full hour)
  TEMP1=`date +%M`      # get current minute 
  TEMP2=`date +%S`      # get current second 
  if [ "$TEMP1" -eq 0 ] && [ "$TEMP2" -eq 0 ]; then 
    getmessage 
  fi 
  
  sleep 0.2 
  
done 

# The End
EDIT: I overlooked one more reference to sh in this line:

Code: Select all

exec urxvt -fg "$FORECOL" -bg "$BACKCOL" "$TRANS"tr -bl +sb -g "$LENGHT"x1+"$POSITIONX"+"$POSITIONY" -fn 'xft:DejaVu Sans Mono-18:dpi=76' -e sh /tmp/scroller_temp.txt
Code corrected now.

Greetings!
[color=red][size=75][O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource[/size][/color]
[b][color=green]Omnia mea mecum porto.[/color][/b]

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#43 Post by technosaurus »

Would anyone be interested in having this in their tray, or is there too much text to fit?
If so, I did a generic tray icon program that will work:
http://murga-linux.com/puppy/viewtopic.php?t=76431
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].

Post Reply