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
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