LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-17-2010, 10:17 AM   #1
GJQ
Member
 
Registered: Jun 2009
Location: Malaysia
Distribution: Ubuntu 11.04
Posts: 99

Rep: Reputation: 17
Auto reload webpage in Conky


Dear LQ members,
I have just install conky to my Linux Mint 9 system.I like to know if I can set up conky to auto reload a webpage.FYI, the webpage do not have rss feed therefore I cannot set conky to use rss.Any other method are appreciated to get conky to do as per my wish

Thanks
 
Old 11-17-2010, 04:34 PM   #2
Snark1994
Senior Member
 
Registered: Sep 2010
Location: Wales, UK
Distribution: Arch
Posts: 1,632
Blog Entries: 3

Rep: Reputation: 346Reputation: 346Reputation: 346Reputation: 346
Quote:
Originally Posted by GJQ View Post
Dear LQ members,
I like to know if I can set up conky to auto reload a webpage.
I'm not sure if I'm misunderstanding you, but when I used conky it just displayed a list of my computer's statistics (ie. CPU usage; processes using it; current time, day and date; / disk usage; swap usage; etc.)

What are you trying to do with yours? Do you have it set up to display part of a webpage? All the statistics I had on my old conky setup updated automatically, so either I'm misunderstanding what you're trying to do, what you're trying to do works differently to what I was doing, or you've messed up your ~/.conkyrc file :P
 
Old 11-18-2010, 02:03 AM   #3
GJQ
Member
 
Registered: Jun 2009
Location: Malaysia
Distribution: Ubuntu 11.04
Posts: 99

Original Poster
Rep: Reputation: 17
Hi Snark1994,
I have set up my conky to display things like system name,kernel,cpu and ram usage and local ip.But I have seen others displaying things like songs details and web pages using conky.Therefore I would like to know the steps needed to display information from a webpage which automatically refresh at 5 mins interval.I will search again and paste the picture,this may help in understanding what I wanted

By the way,my conky does not start automatically each time I start my pc.I do not know why,I have follow instructions from some other forum members but still not working.I will need to use terminal to call it out and each time the below error will appear in terminal

oem@oem-desktop ~ $ conky
Conky: forked to background, pid is 17876
oem@oem-desktop ~ $
Conky: desktop window (18000aa) is subwindow of root window (103)
Conky: window type - normal
Conky: drawing to created window (0x4000001)
Conky: drawing to double buffer



Appreciate all the help
Thanks

Last edited by GJQ; 11-18-2010 at 02:09 AM. Reason: additional information added
 
Old 11-19-2010, 03:06 PM   #4
Snark1994
Senior Member
 
Registered: Sep 2010
Location: Wales, UK
Distribution: Arch
Posts: 1,632
Blog Entries: 3

Rep: Reputation: 346Reputation: 346Reputation: 346Reputation: 346
Quote:
But I have seen others displaying things like songs details and web pages using conky.
Ah right, I've done song details - I did that using the 'exec' command. The associated part of my .conkyrc is
Code:
${if_running rhythmbox}
  Track:$alignr${exec rhythmbox-client --print-playing-format %tt --no-start}
  Artist:$alignr${exec rhythmbox-client --print-playing-format %ta --no-start}
  Album:$alignr${exec rhythmbox-client --print-playing-format %at --no-start}
  Time:$alignr${exec rhythmbox-client --print-playing-format "%te / %td" -- no-start}
  ${execbar ~/coding/bash/trackElapsed}
$endif
Not sure if that helps, but that's the basic idea for adding more functionality to Conky.

Quote:
Therefore I would like to know the steps needed to display information from a webpage which automatically refresh at 5 mins interval. I will search again and paste the picture,this may help in understanding what I wanted.
Ahhh... Are you just looking for a bit of the text, then? I thought you meant showing the webpage as you would see it in your browser. Displaying part of the text from a site could be done with a batch script - use "wget" to download the website's HTML, then you can do more processing on it with the rest of the script to get what you actually want. Then finally you can use the "exec" command in your .conkyrc to display the information in your conky.

Quote:
By the way,my conky does not start automatically each time I start my pc.
Have you added it to your list of startup applications? I haven't been on Mint in a while but as far as I remember the menu layout is the same as in Ubuntu. System -> Preferences -> Startup Applications, then click 'Add' and type 'conky' as the command. That should just run the command 'conky' exactly as if you ran it in the terminal, every time you log on. It works for me!

Quote:
Each time the below error will appear in terminal

oem@oem-desktop ~ $ conky
Conky: forked to background, pid is 17876
oem@oem-desktop ~ $
Conky: desktop window (18000aa) is subwindow of root window (103)
Conky: window type - normal
Conky: drawing to created window (0x4000001)
Conky: drawing to double buffer
These aren't errors they're just messages telling you what it's doing. 'conky -q' will stop them printing, but it's possible it may also suppress error messages. But long story short, you don't need to worry about them, those messages occur on my machine and indicate Conky is working normally.
 
Old 11-20-2010, 01:02 AM   #5
GJQ
Member
 
Registered: Jun 2009
Location: Malaysia
Distribution: Ubuntu 11.04
Posts: 99

Original Poster
Rep: Reputation: 17
Hi Snark1994,
Thank you for replying.

I try pasting the below code into my conky and it is working well.A few problems that I have is that I cannot close rhythmbox even when I am not using due to conky.When I take away the code from conky,then I can close rhythmbox completely.Another problem is when rhythmbox is playing,terminal show errors as per attach file.

${if_running rhythmbox}
Track:$alignr${exec rhythmbox-client --print-playing-format %tt --no-start}
Artist:$alignr${exec rhythmbox-client --print-playing-format %ta --no-start}
Album:$alignr${exec rhythmbox-client --print-playing-format %at --no-start}
Time:$alignr${exec rhythmbox-client --print-playing-format "%te / %td" -- no-start}
${execbar ~/coding/bash/trackElapsed}
$endif

Ahhh... Are you just looking for a bit of the text, then? I thought you meant showing the webpage as you would see it in your browser. Displaying part of the text from a site could be done with a batch script - use "wget" to download the website's HTML, then you can do more processing on it with the rest of the script to get what you actually want. Then finally you can use the "exec" command in your .conkyrc to display the information in your conky.

Yes,information I need is display as webpage but not all of them I need.There are only part of the information I want that hopefully can be display on conky with auto update interval of 5 mins.I do not know how to extrach the information as no knowledge of programming.Maybe if u can assist in the config and give me a step by step.Attach is link of the site http://www.onemotoring.com.sg/publis...ffic_news.html with screenshot of information I want.

As for the start up after reboot,I have added the information in Start Up.Please refer attachment.

Thank you

Last edited by GJQ; 11-28-2010 at 01:22 PM.
 
Old 11-21-2010, 10:06 AM   #6
Snark1994
Senior Member
 
Registered: Sep 2010
Location: Wales, UK
Distribution: Arch
Posts: 1,632
Blog Entries: 3

Rep: Reputation: 346Reputation: 346Reputation: 346Reputation: 346
Quote:
Originally Posted by GJQ View Post
I cannot close rhythmbox even when I am not using due to conky.
Sorry, I've no idea why that would be... Especially the thing about it now working even if you aren't running conky :/ does it give you an error message? Perhaps you could try running rhythmbox from a terminal, then you could see what it complains about...

Quote:
Another problem is when rhythmbox is playing,terminal show errors as per attach file.
Ah, that's 'cos I only attached the code as an example. As the error says, it can't find "~/coding/bash/trackElapsed", which is a custom bash script that I wrote to find how much of the track has played, so I can have a progress-bar-type effect.

Here it is, if you want it (I'm no bash expert, I dislike it as a language - in particular, this script has problems if the track is longer than 10 mins...):
Code:
#!/bin/bash
# ~/coding/bash/trackElapsed
timeE=$(rhythmbox-client --print-playing-format %te --no-start)
Eseconds=`expr substr $timeE 3 2`
Eseconds=${Eseconds#"0"}
Emins=`expr substr $timeE 1 1`
let "Enum=$Emins*60+$Eseconds"
timeD=$(rhythmbox-client --print-playing-format %td --no-start)
Dseconds=`expr substr $timeD 3 2`
Dseconds=${Dseconds#"0"}
Dmins=`expr substr $timeD 1 1`
let "Dnum=$Dmins*60+$Dseconds"
let "perc=100*$Enum/$Dnum"
echo $perc

Quote:
As for the start up after reboot,I have added the information in Start Up.
No idea again, sorry... I assume that if you run '/usr/bin/conky' then it does actually launch conky, but other than that I can't begin to guess what's going on. Maybe looking through the files in /var/log might help...

Quote:
I do not know how to extrach the information as no knowledge of programming.Maybe if u can assist in the config and give me a step by step.
Hm. Normally, I don't like to just write stuff for people, but if you have absolutely no knowledge of programming then it might be a bit of a tall order to ask you to learn just to do this but it's a very useful skill to have, so I would consider it if I were you.


Okay, I've written something. However, I've discovered that you can't easily use conky to do what you want it to - it cuts off the output at a certain limit. So you can view the first couple of items, but not the entire list. Perhaps you need to find another programme which is designed for more heavy scripting? Anyway, I'll post what I wrote anyway, for you to see how it's done. It's written in Python v3, which you may have to install if you haven't done so already. It's not written in a brilliant way (or an ideal language for what it's doing), but was trying to make it as simple as possible so you could 'get' what it's doing.

Here goes:

Code:
#!/usr/bin/python3

from urllib.request import urlopen

webText = "" 
#Open up the website into a file we can read from
filehandle = urlopen('http://www.onemotoring.com.sg/publish/onemotoring/en/on_the_roads/traffic_news.html')
#Read through each line in this file
for line in filehandle.readlines():
#Add each line to the end of our "string", webText
	webText += str(line)
#Close the file
filehandle.close()

#Remove everything before it says "S/No."
webText = webText[webText.index("S/No."):]
#Remove everything up to and including the first "<img" tag
webText = webText[webText.index("<img")+4:]
#Change it into a list of text phrases, with the text "<img" telling the 
#computer to start a new phrase
webTextList = webText.split("<img")
#For each phrase in the list
for eventText in webTextList:
	try:
		#Remove everything up to and including the first "</td>"
		eventText = eventText[eventText.index("</td>")+5:]
		#We're only interested in the text between <td> and </td>
		eventText = eventText[eventText.index("<td>")+4:eventText.index("</td>")]
		#Replace the "&nbsp;" with a space.
		eventText = eventText.replace("&nbsp;"," ")
		#Output the text
		print(eventText)
	except:
		#In the case that an error occurs, it probably means 
#that we've reached the end of the bit we're interested in, so we should
#quit the programme.
		break
It should work fine in the terminal, but if you try to put it into your .conkyrc with the line "${execi 300 /path/to/file.py}", then it will only display the first few items (at least, it does on my computer).

Welp, we tried
 
Old 11-21-2010, 11:00 AM   #7
GJQ
Member
 
Registered: Jun 2009
Location: Malaysia
Distribution: Ubuntu 11.04
Posts: 99

Original Poster
Rep: Reputation: 17
Dear Snark1994,
I would wish to pick up that knowledge but just do not know where to start after extensive of searching in google.

Code:
#!/usr/bin/python3

from urllib.request import urlopen

webText = "" 
#Open up the website into a file we can read from
filehandle = urlopen('http://www.onemotoring.com.sg/publish/onemotoring/en/on_the_roads/traffic_news.html')
#Read through each line in this file
for line in filehandle.readlines():
#Add each line to the end of our "string", webText
	webText += str(line)
#Close the file
filehandle.close()

#Remove everything before it says "S/No."
webText = webText[webText.index("S/No."):]
#Remove everything up to and including the first "<img" tag
webText = webText[webText.index("<img")+4:]
#Change it into a list of text phrases, with the text "<img" telling the 
#computer to start a new phrase
webTextList = webText.split("<img")
#For each phrase in the list
for eventText in webTextList:
	try:
		#Remove everything up to and including the first "</td>"
		eventText = eventText[eventText.index("</td>")+5:]
		#We're only interested in the text between <td> and </td>
		eventText = eventText[eventText.index("<td>")+4:eventText.index("</td>")]
		#Replace the "&nbsp;" with a space.
		eventText = eventText.replace("&nbsp;"," ")
		#Output the text
		print(eventText)
	except:
		#In the case that an error occurs, it probably means 
#that we've reached the end of the bit we're interested in, so we should
#quit the programme.
		break
It should work fine in the terminal, but if you try to put it into your .conkyrc with the line "${execi 300 /path/to/file.py}", then it will only display the first few items (at least, it does on my computer).

Welp, we tried [/QUOTE]




I have saved the script in my /oem/home/file.py but do I need to allow it to run as program in the permission?

A big thanks to your help.

Last edited by GJQ; 11-21-2010 at 11:02 AM. Reason: Realight message for easy reading
 
Old 11-21-2010, 11:10 AM   #8
Snark1994
Senior Member
 
Registered: Sep 2010
Location: Wales, UK
Distribution: Arch
Posts: 1,632
Blog Entries: 3

Rep: Reputation: 346Reputation: 346Reputation: 346Reputation: 346
First, check if you have python by running '/usr/bin/python3'
If you get a shell prompt, then it's good, if it gives an error then you need to install python (just use 'sudo apt-get install python3'). Then you can either run 'python3 /path/to/file.py' (doesn't need executable permissions) or just '/path/to/file.py' (does need executable permissions).
 
Old 11-21-2010, 11:31 AM   #9
GJQ
Member
 
Registered: Jun 2009
Location: Malaysia
Distribution: Ubuntu 11.04
Posts: 99

Original Poster
Rep: Reputation: 17
Dear Snark1994,
It is working. Thank you so much.Attach is a screenshot of the message.Which line do I have to change if I would like to display more than 3 lines of updates.Currently only 3 lines of updates appear, I like to have around 5-10 lines of updates.As u can see from the screenshots,conky appear big when displaying the message.Is there any way to make the message display within a standard size frame?

Thanks

Last edited by GJQ; 11-28-2010 at 01:22 PM.
 
Old 11-22-2010, 12:13 PM   #10
Snark1994
Senior Member
 
Registered: Sep 2010
Location: Wales, UK
Distribution: Arch
Posts: 1,632
Blog Entries: 3

Rep: Reputation: 346Reputation: 346Reputation: 346Reputation: 346
Quote:
Originally Posted by Snark1994 View Post
It should work fine in the terminal, but if you try to put it into your .conkyrc with the line "${execi 300 /path/to/file.py}", then it will only display the first few items (at least, it does on my computer). Welp, we tried
Like I said a few posts back, I'm very sorry, but I don't think you'll be able to get it to work with conky. Conky appears to cut text short after you've printed out a certain number of characters; this seems to be an in-built limitation. It's possible (even probable) that you could download and edit the source code of conky, then re-compile your own version of it that would allow you to use longer bits of text, but I suspect you would find it difficult to do this if you're not confident with programming.

However, with regards to the second problem, that's just because you're sending very long lines of text to Conky, so it stretches the window to include the text. You can cut a line short using python by typing:
Code:
lineOfText = lineOfText[:10]
This will cut it down to the first 10 characters. Obviously, you should change this value so that it prints enough for you to get the gist of what the line says, but not so much that it covers up your screen.

Sorry I couldn't be of more help
 
Old 11-23-2010, 01:19 AM   #11
GJQ
Member
 
Registered: Jun 2009
Location: Malaysia
Distribution: Ubuntu 11.04
Posts: 99

Original Poster
Rep: Reputation: 17
Dear Snark1994,
Thanks for the reply and sorry that I have requested more from you. Anyway u have helped a lot.

Thank you
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Conky Colors Makes Your Conky Beautiful In Seconds (Version 3.20 Released) LXer Syndicated Linux News 0 08-01-2010 12:21 PM
Any idea where to find PHP code for a sharing Notepad webpage with auto-save? frenchn00b Programming 1 11-30-2009 09:09 PM
Mozilla firfox 3.0.b5- how to auto reload for a particular page. raju.mopidevi SUSE / openSUSE 1 01-31-2009 12:37 PM
Auto reload and scroll dowm in FireFox? x_terminat_or_3 Linux - Software 5 04-29-2007 09:38 AM
Tomcat reload servlet is very slow, but reload jsp is fast and good? gsbarry Programming 2 04-28-2006 10:34 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:00 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration