Making productive use of the XScreenSaver to display text instead of Conky

Forum Forums General Tips and Tricks Making productive use of the XScreenSaver to display text instead of Conky

Tagged: ,

This topic contains 48 replies, has 6 voices, and was last updated by BobC Jun 13-5:47 pm.

Viewing 15 posts - 16 through 30 (of 49 total)
  • Author
    Posts
  • #10227
    Member

    BobC

    Here is a video of it running. If anyone tries it that could test it for another language besides English, let me know if it works ok, please. It is setup to work with Utf-8 to work with the wttr.in weather forecast.

    Yes, the video is crude. I’m not used to making them, LOL.

    PS: I did come up with one problem. Nobody complained, yet, but it will probably hit websites too often, so I think I should default it to going to the website initially when the screensaver starts, then just display the file retrieved last time until its over 15 minutes old, then go to the site again and get a fresh copy when its older. Any thoughts on that? I had thought about using cron, but then it would be running all the time.

    PS: the starwars screensaver is in the xscreensaver-gl-extra package. To install it, use synaptic or at a terminal screen, type
    sudo apt-get install xscreensaver-gl-extra

    PSS: I’ve attached the revised code that is doesn’t cause as much network traffic

    • This reply was modified 3 months ago by BobC.
    • This reply was modified 3 months ago by BobC.
    • This reply was modified 3 months ago by BobC.
    #10277
    Member

    BobC

    If its of any interest to anyone I added the URL, name of the feed, and date/time last retrieval was attempted as a couple lines of addition text at the beginning of the feeds from HTML and RSS websites since I’m only going to get them every so often, now.

    I learned at least some things creating it. I’m afraid I’ve only scratched the surface as far as script coding, though, but I did get it to do what I wanted, which is at least something to me.

    Next time I load a machine I’ll try installing it to find out what difficulties I hit. I did it as a zip file because last time I tried a .gz file here, it was rejected, but now I saw one posted, so that’s allowed here, too, and that might have been better. A readme file might have been better than expecting people to read here and figure it out, also. Someday maybe I’ll figure out how to make things easily installable, but I guess that’s for another day.

    Thanks to those who helped with ideas, questions answered and snippets of code I borrowed.

    #10283
    Member
    sleekmason
    sleekmason

    I am having trouble with the RSS feeds. World News works as expected, but when I try other urls, they fail. Here are a couple of examples:

    printf "\n\nArkansasTimes\n" > /tmp/sst_arnews.txt
    /bin/bash getrss2txt https://www.arktimes.com/arkansas/Rss.xml /tmp/sst_ arnews 10 no >> /tmp/sst_arnews.txt
    cat /tmp/sst_arnews.txt
    echo
    printf "\n\nNewYorkTimes\n" > /tmp/sst_nytnews.txt
    /bin/bash getrss2txt http://feeds.nytimes.com/nyt/rss/HomePage /tmp/sst_ nytnews 10 no >> /tmp/sst_nytnews.txt
    cat /tmp/sst_nytnews.txt



    The titles do appear, just not any articles. Both work fine in Newsboat RSS reader.
    Any ideas? (tried both yes and no for description.)

    #10287
    Member

    BobC

    The format of the data on the feed is different than the script expects, so either the script needs to change to allow both or a 2nd script to handle the other format is needed. Did you look for other RSS feed processing scripts? I got that one a few years ago from archlinux bbs.

    #10289
    Member

    BobC

    I don’t pretend to know much about RSS feeds, but they seem to be like web pages to me. You use curl or wget with the URL and whatever it sends back needs to be massaged into the text you want to see. Perhaps there is a program that just does that well? The one I had was built to bring back an old ABC news feed and based on the weather data one, and the basics of it seemed to work for the news feeds I wanted.

    So, in a terminal if you do a curl -s with the New York times URL you will see the main reason that one didn’t work!

    As for the Ar Times, the site was ok, but the format didn’t include the CDATA stuff the script was looking for. I call it stuff because like I said, I don’t actually know its meaning, and if I ever need to, I’ll have to look for it and learn it. Common sense tells me that I want to remove it, but if its not there, the script didn’t find it, and so didn’t think it found something we wanted to print, and therefore nothing came out.

    I could have still been able to do it by first finding and removing the title, then finding an removing the CDATA stuff, then if that was found, also removing the trailing CDATA stuff, and then removing the trailing title stuff, but I’m not a pro at this, and pretty drained from the day, so instead I will try the getrssa2txt script on a url, and if I get a bunch of CDATA stuff, I’ll try getrss2txt and see if that does better..

    So I copied the getrss2txt script I had and created getrssa2txt from it, and removed the CDATA related stuff. I see there are a few glitches still in how it gets displayed. Maybe you can see if you can tweak what I did into something even better.

    PS: I was reading last night that the title block is supposed to be inside an item block, but I didn’t try to implement that.

    Here is the getrssa2txt script.

    #!/bin/bash
    # getrssa2txt - get rss feed (format a without CDATA stuff) and send to std output
    # parms: 1-URL, 2-temp dir and file prefix, 3-base rss filename, 4-maximum lines, 5-show description yes or no, , 6-optional minimum interval in minutes with 30 min default
    # example: /bin/bash getrssfeed https://abcnews.go.com/abcnews/internationalheadlines /tmp/sstnb_ abcworldnews 25 no
    datetime=<code>date '+%Y-%m-%d %H:%M:%S'</code>
    url=$1
    pathprefix=$2
    file=$3
    maxlines=$4
    showdescr=$5
    mininter=$6
    if [ -z $mininter ]; then
    	mininter=30
    fi
    skipfile=Y
    # if the file exists already and is too recent, then skip and use existing file
    if [ -e $pathprefix$file.99.xml ]; then
    	if test <code>find $pathprefix$file.99.xml -mmin +$mininter</code>; then
    		skipfile=N
    	fi
    else
    	skipfile=N
    fi
    if [ "$skipfile" = 'N' ]; then
    	printf " <title>Data retrieved from $url</title>\n" > $pathprefix$file.99.xml
    	printf " <title>  for $file at $datetime</title>\n" >> $pathprefix$file.99.xml
    	curl -s $url >> $pathprefix$file.99.xml
    fi
    if [[ "$showdescr" == "yes" ]]; then
    	# leave the raw xml file there and make a txt file stripped down to what is wanted to display, titles and descriptions
    	cat $pathprefix$file.99.xml | grep -E "<title>|<description>" > $pathprefix$file.10.tmp
    	cat $pathprefix$file.10.tmp | sed "s/^ \+<title>//g;s/<\/title>//;" > $pathprefix$file.20.tmp
    	cat $pathprefix$file.20.tmp | sed "s/^ \+<description>/   /g;s/<\/description>//;" > $pathprefix$file.30.tmp
    else
    	# leave the raw xml file there and make a txt file stripped down to what is wanted to display, titles only
    	cat $pathprefix$file.99.xml | grep -E "<title>" > $pathprefix$file.10.tmp
    	cat $pathprefix$file.10.tmp | sed "s/^ \+<title>//g;s/<\/title>//;" > $pathprefix$file.30.tmp
    fi
    cat $pathprefix$file.30.tmp | grep -v "<title>" | head -n $maxlines > $pathprefix$file.99.tmp
    cat $pathprefix$file.99.tmp
    • This reply was modified 3 months ago by BobC.
    • This reply was modified 3 months ago by BobC.
    #10301
    Member
    sleekmason
    sleekmason

    Oh man! That’s a lot of work you did there. I sure do appreciate it. While you were doing that, I found a program in the repos. “rsstail”. rsstail may be the thing to use, but my bash skills are sorely lacking and I couldn’t figure out how to “re-implement” the command each time, or only read the changes. 7 screen hours later . .

    here is the example I have been using and some stuff I have tried but am not familiar enough to place everything right.
    rsstail -n 10 -u http://feeds.nytimes.com/nyt/rss/HomePage >> /tmp/news
    rsstail works from terminal just fine, but keeps adding instances with every go round. i.e 20 items, 40 items, 60 items and onward. I don’t know how to delete /tmp/news after each instance, or simply check for extras.

    Anyhow, rsstail might be the thing you are looking for for inclusiveness.


    I’m going to check out your edited file now:)

    #10302
    Member

    736b69646f6f

    stuff >> somefile
    appends the destination file

    stuff > somefile
    overwrites the destination file, which seems to be what you want in this case

    #10303
    Member

    BobC

    rsstail is designed to run and run. I have to think on how to use it.

    #10306
    Member

    BobC

    Ok, here is what I found. When I run rsstail from a terminal, it keeps running till I abort it. What its doing is waiting -i seconds to check for any new articles, and then those will display. If I tell it to go to std output with a > sign, then it will just be writing to the file instead.

    Xscreensaver can be configured to run a program or display a file or url, and if all you wanted was one rss feed you could probably find a way to use any of those methods.

    When you ask for 2 it gets trickier…

    My method would be to add the rsstail commands to run in background from a startup script, having them writing to files and then either add the files or links to them in my /etc/xscreensaver.d folder or a small script to parse if additional processing was wanted.

    Keep in mind that if you tell xscreensaver to run a program, it will run it each time the screensaver cycles if my analysis is correct, so if you ran an rsstail in background to load each file each time it cycled you would need to wait and kill it after you got the file, or I think you would end up with many rsstail commands running in background.

    Just thinking aloud… You chose to create your own process, and are looking for nice rss feeds, so the choices are yours.

    I suppose the rsstail program could be modified to have an option to get the feed one time and quit, but maybe its a better design, and should be left alone…

    #10308
    Member

    BobC

    ***NOTE*** I REVISED THE POST AND TOOK OUT THE PREVIOUS CODE, and working code is reposted below

    So I came up with an idea… Not tested yet… I called it getrsst2txt. It works a lot like the others except the interval is in seconds instead of minutes, and like the others could be run from my /etc/xscreensaver.d folder. I’ll try to test tonight, need to go to work… Here is the NY times script and the getrsst2txt

    • This reply was modified 3 months ago by BobC.
    #10309
    Member
    sleekmason
    sleekmason

    When you ask for 2 it gets trickier…

    Sure the hell does! Just now saw your latest post. More to look at:)

    736b69646f6f > Thank you. That was killing me.

    Here is what I have been working on.


    This works, but I don’t know if it is stable.

    #!/bin/bash
    #
    if pidof rsstail | grep [0-9] > /dev/null
     then
      touch /tmp/news
     else
    rsstail -n 10 -u http://feeds.nytimes.com/nyt/rss/HomePage > /tmp/news &
    fi
    echo "New York Times"
    echo
    cat /tmp/news
    exit 1

    Then call from the main,

    #!/bin/bash
    echo
    echo
    sed -n '9p' $HOME/4_Moon/raw
    echo
    cat ~/.weather/weather      
    echo
    echo
    sed -n '11p' $HOME/4_Moon/raw
    sed -n '1p' $HOME/4_Moon/raw
    sed -n '8p' $HOME/4_Moon/raw
    echo
    echo
    ###
    fortune
    echo
    echo
    sh ~/xscreensaver/nyt.sh
    echo
    cat ~/xscreensaver/keybinds
    echo

    I am calling the above from the screensaver program setting. ~/xscreensaver/settings

    Guessing this could be made better.

    I do not know how to add another instance. I’ve tried adding to nyt.sh using separate paths for /tmp, but no go. Also tried different file to call from “settings”

    • This reply was modified 3 months ago by sleekmason.
    #10319
    Member
    sleekmason
    sleekmason

    Also, After running the above for an hour or so I find that rsstail updates every 15 minutes (changeable), and then adds more to the feed, so that after an hour I have 40 items scrolling instead of 10. This isn’t horrible, as it also is adding only new articles, but obviously isn’t the goal.

    I had thought that “touch” might help with this by applying a new time stamp?


    How to add to nyt.sh the removal and recreation of /tmp/news every round, or signal to not add unless deleted first (so only 10 ever).
    No matter what I try concerning this, adding rm /tmp/news makes the whole file run once/twice, then stops.

    • This reply was modified 3 months ago by sleekmason.
    #10329
    Member

    BobC

    Touch will create a file if its missing, and will update the date/timestamp if it exists.

    I will attach a complete zipfile of new code with the rsstail built in. The only downside is that once it goes to screensaver, that starts the RSS feed if it isn’t already started for that URL, but because I don’t know how to tell when the screensaver is no longer running, they will stay running afterwards until you turn them off or reboot. I suppose I could create another process to monitor if the feeds are being used, and if not within X amount of time, shut them down, but that seems like overkill to me.

    In general I think the rsstail method or catching the feed is probably better than going at the URL manually with curl, if for no other reason than that parsing out the title gets done for you, but I had no success getting it to print the description, too, and so I guess I’ll just say no to those to turn them off if they don’t work.

    Its not perfect. I have real problems with root vs user, so be careful of that. The home directory stuff should be owned by the user.

    • This reply was modified 2 months, 4 weeks ago by BobC.
    #10335
    Member
    sleekmason
    sleekmason

    Howdy,

    Since rsstail keeps running, you have to killall xscreensaver and restart to see changes. The -d (description) option works well here.

    The -i (interval) option doesn’t appear to work in shortening the time, but may allow for increasing it, (checking now).

    I figured to put ${execi 3600 rm /tmp/news} in conky, since it exists and will allow for this. Unfortunately, upon execution, xscreensaver won’t renew even after the default 15 minutes are up. This doesn’t make sense to me. but there it is. another solution may be to remove individual lines /tmp on the fly? don’t know.

    I added back in your corrected file for the AR times and it works well minus descriptions. Using it in my setup calling from ~/xscreensaver/settings, I added an “exit 1” to the end of the 0000.arnews file to allow it to repeat.

    I’m using both right now to get around the problem with two feeds independent of each other in rsstail. Works!


    Working on the two feed problem in rsstail. Got an idea or six to try.

    • This reply was modified 2 months, 4 weeks ago by sleekmason.
    #10337
    Member

    BobC

    Multiple feeds work just fine in mine.

    I don’t think it can work as one process. With rsstail I think there needs to be a process for each feed, and a separate process to feed the screensaver text.

Viewing 15 posts - 16 through 30 (of 49 total)

You must be logged in to reply to this topic.