View previous topic :: View next topic |
Author |
Message |
cata1986 Tux's lil' helper
Joined: 01 Feb 2004 Posts: 111 Location: bologna
|
Posted: Mon Feb 16, 2004 4:06 pm Post subject: superkaramba |
|
|
Scusate, avrei qualche problemino con superkaramba... dopo aver notato che qualsiasi tema che mi visualizasse il tempo... piu cvhe altro mi sono soffermato sul tema: the e qui di seguito vi posto sia il thema sia lo script weather
theme relativo al weather (l'ho impostato per bologna)
Code: |
#weather
<GROUP> X=0 Y=80
TEXT X=0 Y=0 VALUE="Weather" COLOR=255,165,0 FONTSIZE=10 FONT="Impact" SHADOW=1
TEXT X=10 Y=70SENSOR=PROGRAM PROGRAM="scripts/weather.pl" LINE=1 COLOR=0,0,0 FONTSIZE=10 FONT="Impact" INTERVAL=600000
IMAGE X=0 Y=20 SENSOR=PROGRAM PROGRAM="scripts/weather.pl" LINE=2
IMAGE X=60 Y=15 SENSOR=PROGRAM PROGRAM="scripts/weather.pl" LINE=3
IMAGE X=60 Y=33 SENSOR=PROGRAM PROGRAM="scripts/weather.pl" LINE=4
IMAGE X=60 Y=51 SENSOR=PROGRAM PROGRAM="scripts/weather.pl" LINE=5
IMAGE X=60 Y=69 SENSOR=PROGRAM PROGRAM="scripts/weather.pl" LINE=6
</GROUP>
|
script weather
Code: |
use LWP::Simple;
# The country's ID from weather.yahoo.com
# Just visit thje city for which you want information,
# can take the 4 letters of the 1st sub-directory.
# It normally ends with XX.
my $country = "ITXX";
# The city's ID from weather.yahoo.com
# This can be found immediately following the second
# occurance of the Country Code
my $city = "0006";
# The path to the images.
my $path = "pics/weatherpics";
my $URL="http://ca.weather.yahoo.com/$country/$country$city/index_c.html";
my $page=get($URL);
$page2 = $page;
$page =~ s/face=Arial><b>(\d{1,2})/$1/;
print "$1°C\n";
$page =~ s/http:\/\/us.yimg.com\/i\/us\/we\/intl\/(\d{1,2}).gif/$1/;
print "$path/$1.gif\n";
for ($x=1;$x<=4;$x++) {
$page =~ s/http:\/\/us.yimg.com\/i\/us\/we\/intl\/(\d{1,2}).gif/$1/;
print "$path/small/$1.gif\n";
|
come ultima cosa vi volevo chiedere se si potesse impostare questi temi in secondo piano perche cosi come adesso stanno sempre in primo piano e mi sono di intralcio... |
|
Back to top |
|
|
comio Advocate
Joined: 03 Jul 2003 Posts: 2191 Location: Taranto
|
|
Back to top |
|
|
cata1986 Tux's lil' helper
Joined: 01 Feb 2004 Posts: 111 Location: bologna
|
Posted: Mon Feb 16, 2004 5:39 pm Post subject: |
|
|
ma il baco di kde3.2 è riguardante lo script weather o riguarda la capacita di mettere i temi in secondo piano??? |
|
Back to top |
|
|
comio Advocate
Joined: 03 Jul 2003 Posts: 2191 Location: Taranto
|
Posted: Mon Feb 16, 2004 5:42 pm Post subject: |
|
|
è la capità di mettere i temi in secondo piano _________________ RTFM!!!!
e
http://www.comio.it
|
|
Back to top |
|
|
cata1986 Tux's lil' helper
Joined: 01 Feb 2004 Posts: 111 Location: bologna
|
Posted: Mon Feb 16, 2004 5:46 pm Post subject: |
|
|
il problema di mettere in secondo piano il tema l'ho gia risolto... mi serve solo capire dove sbaglio la configurazione per fare andare le previsioni del tempo... |
|
Back to top |
|
|
cata1986 Tux's lil' helper
Joined: 01 Feb 2004 Posts: 111 Location: bologna
|
Posted: Tue Feb 17, 2004 3:31 pm Post subject: |
|
|
x cerri:
se avvio da terminale lo script weather che ho postato nel primo post mi da in uscita:
Code: |
Can't locate LWP/Simple.pm in @INC (@INC contains: /etc/perl /usr/lib/perl5/site_perl/5.8.0/i686-linux /usr/lib/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.0/i686-linux /usr/lib/perl5/vendor_perl/5.8.0 /usr/lib/perl5/vendor_perl /usr/lib/perl5/5.8.0/i686-linux /usr/lib/perl5/5.8.0 /usr/local/lib/site_perl .) at ./weather.pl line 23.
BEGIN failed--compilation aborted at ./weather.pl line 23.
|
mentre lo script di cui ti parlavo ha come .theme
Code: |
KARAMBA X=200 Y=200 W=224 H=394 INTERVAL=1800000 LOCKED=true
IMAGE X=0 Y=0 PATH="bg.png"
<GROUP>
TEXT X=177 Y=19 ALIGN=RIGHT COLOR=220,220,220 FONTSIZE=10 FONT="arial black" SENSOR=PROGRAM PROGRAM="~/.superkaramba/k_weather.py" LINE=1 SHADOW=1 FIXEDPITCH=false INTERVAL=10800000
TEXT X=177 Y=36 ALIGN=RIGHT COLOR=220,220,220 FONTSIZE=8 FONT="arial black" LINE=6 SENSOR=PROGRAM PROGRAM="~/.superkaramba/k_weather.py" SHADOW=1 FIXEDPITCH=false
TEXT X=177 Y=48 ALIGN=RIGHT COLOR=220,220,220 FONTSIZE=9 FONT="arial black" LINE=11 SENSOR=PROGRAM PROGRAM="~/.superkaramba/k_weather.py" SHADOW=1 FIXEDPITCH=false
TEXT X=36 Y=50 COLOR=220,220,220 FONTSIZE=8 FONT="arial" LINE=12 SENSOR=PROGRAM PROGRAM="~/.superkaramba/k_weather.py" SHADOW=1 FIXEDPITCH=false
IMAGE X=-2 Y=-2 SENSOR=PROGRAM LINE=8 PROGRAM="~/.superkaramba/k_weather.py"
</GROUP>
<GROUP> X=16 Y=89
TEXT X=20 Y=0 COLOR=220,220,220 FONTSIZE=10 FONT="arial black" LINE=29 SENSOR=PROGRAM PROGRAM="~/.superkaramba/k_weather.py" SHADOW=1 FIXEDPITCH=false
TEXT X=160 Y=4 ALIGN=RIGHT COLOR=220,220,220 FONTSIZE=8 FONT="arial black" LINE=33 SENSOR=PROGRAM PROGRAM="~/.superkaramba/k_weather.py" SHADOW=1 FIXEDPITCH=false
IMAGE X=-10 Y=-10 SENSOR=PROGRAM LINE=31 PROGRAM="~/.superkaramba/k_weather.py"
TEXT X=160 Y=18 ALIGN=RIGHT COLOR=220,220,220 FONTSIZE=8 FONT="arial" LINE=32 SENSOR=PROGRAM PROGRAM="~/.superkaramba/k_weather.py" SHADOW=1 FIXEDPITCH=false
TEXT X=20 Y=18 COLOR=220,220,220 FONTSIZE=8 FONT="arial" LINE=35 SENSOR=PROGRAM PROGRAM="~/.superkaramba/k_weather.py" SHADOW=1 FIXEDPITCH=false
</GROUP>
<GROUP> X=16 Y=138
TEXT X=20 Y=0 COLOR=220,220,220 FONTSIZE=10 FONT="arial black" LINE=36 SENSOR=PROGRAM PROGRAM="~/.superkaramba/k_weather.py" SHADOW=1 FIXEDPITCH=false
TEXT X=160 Y=4 ALIGN=RIGHT COLOR=220,220,220 FONTSIZE=8 FONT="arial black" LINE=40 SENSOR=PROGRAM PROGRAM="~/.superkaramba/k_weather.py" SHADOW=1 FIXEDPITCH=false
IMAGE X=-10 Y=-10 SENSOR=PROGRAM LINE=38 PROGRAM="~/.superkaramba/k_weather.py"
TEXT X=160 Y=18 ALIGN=RIGHT COLOR=220,220,220 FONTSIZE=8 FONT="arial" LINE=39 SENSOR=PROGRAM PROGRAM="~/.superkaramba/k_weather.py" SHADOW=1 FIXEDPITCH=false
TEXT X=20 Y=18 COLOR=220,220,220 FONTSIZE=8 FONT="arial" LINE=42 SENSOR=PROGRAM PROGRAM="~/.superkaramba/k_weather.py" SHADOW=1 FIXEDPITCH=false
</GROUP>
<GROUP> X=16 Y=188
TEXT X=20 Y=0 COLOR=220,220,220 FONTSIZE=10 FONT="arial black" LINE=43 SENSOR=PROGRAM PROGRAM="~/.superkaramba/k_weather.py" SHADOW=1 FIXEDPITCH=false
TEXT X=160 Y=4 ALIGN=RIGHT COLOR=220,220,220 FONTSIZE=8 FONT="arial black" LINE=47 SENSOR=PROGRAM PROGRAM="~/.superkaramba/k_weather.py" SHADOW=1 FIXEDPITCH=false
IMAGE X=-10 Y=-10 SENSOR=PROGRAM LINE=45 PROGRAM="~/.superkaramba/k_weather.py"
TEXT X=160 Y=18 ALIGN=RIGHT COLOR=220,220,220 FONTSIZE=8 FONT="arial" LINE=46 SENSOR=PROGRAM PROGRAM="~/.superkaramba/k_weather.py" SHADOW=1 FIXEDPITCH=false
TEXT X=20 Y=18 COLOR=220,220,220 FONTSIZE=8 FONT="arial" LINE=49 SENSOR=PROGRAM PROGRAM="~/.superkaramba/k_weather.py" SHADOW=1 FIXEDPITCH=false
</GROUP>
<GROUP> X=16 Y=237
TEXT X=20 Y=0 COLOR=220,220,220 FONTSIZE=10 FONT="arial black" LINE=50 SENSOR=PROGRAM PROGRAM="~/.superkaramba/k_weather.py" SHADOW=1 FIXEDPITCH=false
TEXT X=160 Y=4 ALIGN=RIGHT COLOR=220,220,220 FONTSIZE=8 FONT="arial black" LINE=54 SENSOR=PROGRAM PROGRAM="~/.superkaramba/k_weather.py" SHADOW=1 FIXEDPITCH=false
IMAGE X=-10 Y=-10 SENSOR=PROGRAM LINE=52 PROGRAM="~/.superkaramba/k_weather.py"
TEXT X=160 Y=18 ALIGN=RIGHT COLOR=220,220,220 FONTSIZE=8 FONT="arial" LINE=53 SENSOR=PROGRAM PROGRAM="~/.superkaramba/k_weather.py" SHADOW=1 FIXEDPITCH=false
TEXT X=20 Y=18 COLOR=220,220,220 FONTSIZE=8 FONT="arial" LINE=56 SENSOR=PROGRAM PROGRAM="~/.superkaramba/k_weather.py" SHADOW=1 FIXEDPITCH=false
</GROUP>
<GROUP> X=16 Y=287
TEXT X=20 Y=0 COLOR=220,220,220 FONTSIZE=10 FONT="arial black" LINE=57 SENSOR=PROGRAM PROGRAM="~/.superkaramba/k_weather.py" SHADOW=1 FIXEDPITCH=false
TEXT X=160 Y=4 ALIGN=RIGHT COLOR=220,220,220 FONTSIZE=8 FONT="arial black" LINE=61 SENSOR=PROGRAM PROGRAM="~/.superkaramba/k_weather.py" SHADOW=1 FIXEDPITCH=false
IMAGE X=-10 Y=-10 SENSOR=PROGRAM LINE=59 PROGRAM="~/.superkaramba/k_weather.py"
TEXT X=160 Y=18 ALIGN=RIGHT COLOR=220,220,220 FONTSIZE=8 FONT="arial" LINE=60 SENSOR=PROGRAM PROGRAM="~/.superkaramba/k_weather.py" SHADOW=1 FIXEDPITCH=false
TEXT X=20 Y=18 COLOR=220,220,220 FONTSIZE=8 FONT="arial" LINE=63 SENSOR=PROGRAM PROGRAM="~/.superkaramba/k_weather.py" SHADOW=1 FIXEDPITCH=false
</GROUP>
|
e come k_weather.py
Code: |
#!/usr/bin/env python
# Configuration
#
# Replace this URL
url = 'http://www.w3.weather.com/weather/local/ITXX0006'
#
# Where k_weather.py and the cached copy of the html page
# should be kept:
installed = '~/.superkaramba'
#
# To display temperatures in Celsius and convert units to
# metric, change to '1'
metric = 0
#
# For a 24-hour clock, set to '1'
clock = 0
#
# If 1, then the high temperature will be displayed first.
# Otherwise, the low temperature will be displayed first
order = 0
#
# This changes the separator between the high and low values:
separator = "-"
#
# End Configuration
def getWeather(data, metric, days):
'''Parses a page from weather.com and returns a list
containing the current weather conditions and forecast.
data: An unmodified html page from weather.com
metric: Set to '1' to convert units to metric format
days: Number of forecast days to return (maximum 9)
'''
import re
forecast = []
# Make sure we don't try to get any more than 9 day's forecast
if days > 9: days = 9
# Chop the data into more managable bits
start = data.find('Current Conditions')
stop = data.find('>Last Updated') + 100
#stop = data.find('EDT') + 3
data1 = data[start:stop]
# The regular expressions needed to get the weather forecast
# listed roughly in the order that they occur
p_current = r'''(?isx) # Ignore case, Dot matches all, Verbose
wxicons/52/(?P<icon>\d*?)\.gif # Icon
.*?obsTempTextA>(?P<temp>\d*?)° # Temp
.*?obsTextA>(?P<sky>.*?)</b> # Sky
.*?Feels\sLike<br>(?P<heat>.*?)° # Heat
'''
p_today = r'''(?isx) # Ignore case, Dot matches all, Verbose
[Today|Tonight]</a><br>\s*(?P<date>.*?)</td> # Date
.*?wxicons/31/(?P<icon>\d*)\.gif # Icon
.*?5>(?P<sky>.*?)</td> # Sky
.*?<b>(?P<low>\d*?)° # Temp
.*?CENTER>(?P<precip>\d*?\s%)</div>
# Chance of precipitation
'''
p_uv = r'(?is)UV Index:.*?Info2>(?P<uv>.*?) '
p_dewpoint = r'(?is)Dew Point:.*?Info2>(?P<dew>.*?)°'
p_humidity = r'(?is)Humidity:.*?Info2>(?P<hum>.*?)</td>'
p_visibility = r'(?is)Visibility:.+?Info2>(?P<vis>.*?)</td>'
p_barometer = r'(?is)Pressure:.+?Info2>(?P<baro>.*?)\sinches\sand\s(?P<change>.*?)</td>'
p_wind = r'(?is)Wind:.+?Info2>(?P<wind>.*?)\sat\s(?P<speed>\d*?) '
p_report = r'''(?ix)
reported\sat</a>\s*(?P<city>.+?), # Reporting city
.+?Updated\s(?P<weekday>.+?), # Day of the week
\s(?P<month>.+?) # Month
\s(?P<day>\d+?), # Day
\s(?P<year>\d+?), # Year
\sat\s(?P<hour>.+?)\s #Time
(?P<meridian>[A|P]M) # AM or PM
'''
p_forecast = r''' # No embedded flags, since they will be added later
>(?P<day>.*?)</a> # Weekday
<br>\s(?P<date>.*?)</td> # Day number
.*?wxicons/31/(?P<icon>\d*)\.gif # Icon
.*?5>(?P<sky>.*?)</td> # Sky
.*?<b>(?P<high>\d*?)° # High temperature
/(?P<low>\d*?)° # Low temperature
.*?CENTER>(?P<precip>\d*?\s%)</div>
# Chance of precipitation
'''
patterns = [p_report, p_current, p_wind, p_barometer, \
p_humidity, p_uv, p_visibility, p_dewpoint, p_today]
# Weather.com often has problems, so we supply defaults so that the program doesn't break.
defaultReport = ['N/A', 'N/A', 'N/A', '0', '0', '0:00', 'AM']
defaultCurrent = ['1', '0', 'N/A', '0']
defaultWind = ['Calm', '0'] # This is actually a likely error; the wind regex won't catch calm winds
defaultBarometer = ['0', 'N/A']
defaultHumidity = ['0']
defaultUV = ['0']
defaultVisibility = ['N/A']
defaultDewpoint = ['0']
defaultToday = ['N/A', '1', 'N/A', '0', 'N/A']
defaultForecast = ['N/A', 'N/A', '1', 'N/A', '0', '0', '0']
defaultValues = [defaultReport, defaultCurrent, defaultWind, \
defaultBarometer, defaultHumidity, defaultUV, \
defaultVisibility, defaultDewpoint, defaultToday]
count = 0 # This keeps track of which pattern we're using, so we can replace it if something goes wrong
for pattern in patterns:
try:
match = re.search(pattern, data1)
for group in match.groups():
group = group.replace(' ', '')
forecast += [group]
count += 1
except: # This catches calm winds and occasions when weather.com incorrectly reports the weather
for item in defaultValues[count]:
forecast += [item]
count += 1
day = 1
while day <= days:
daystring = r'(?isx)/detail/.*?=' + str(day)
pattern = daystring + p_forecast
try:
match = re.search(pattern, data1)
for group in match.groups():
group = group.replace(' ', '')
forecast += [group]
except:
for item in defaultForecast:
forecast += [item]
day += 1
# Massage the data a bit...
if metric:
scale = 'C'
speed = 'kph'
forecast[8] = str('%d' % ((5/9.0) * (int(forecast[8]) - 32))) + ' °' + scale
forecast[10] = str('%d' % ((5/9.0) * (int(forecast[10]) - 32))) + ' °' + scale
forecast[12] = str('%d' % (int(forecast[12]) * 1.60934)) + ' ' + speed
forecast[13] = '%.1f' % (float(forecast[13]) / .02953)
lines = [22, 28, 29] # Today's temperatures
for x in range(days - 1):
lines += [35 + (x * 7), 36 + (x * 7)] # All other temps
for i in lines:
forecast[i] = '%d' % ((5/9.0) * (int(forecast[i]) - 32))
else:
scale = 'F'
speed = ' mph'
forecast[8] = forecast[8] + ' °' + scale
forecast[10] = forecast[10] + ' °' + scale
forecast[12] = forecast[12] + speed
return forecast
if __name__ == '__main__':
from urllib import urlopen
from os.path import expanduser
from sys import exit
from sys import argv
warning = 0
days = 5
if installed != '~/.superkaramba': # Toggle a warning if the default directory is changed
warning = 1
if installed[0] == '~':
home = expanduser('~')
installed = home + installed[1:]
if len(argv) == 2:
if argv[1] == '-i': # Install flag
from os import mkdir
from shutil import copy
print 'Creating directory: ', installed
try:
mkdir(installed)
except OSError, e:
if e == 13:
print 'You do not have permission to create the directory ', installed
print 'Try installing as root'
exit()
else:
pass # The directory already exists, ignore the error
print "Copying k_weather.py to ", installed
try:
copy('k_weather.py', installed)
except:
print 'Unable to copy k_weather.py'
print '''
Now run './k_weather.py' to be sure that it works correctly.
Remember, anytime you change k_weather.py, you will need to
re-install it for the changes to take effect in the theme.'''
if warning:
print '''
WARNING: you have changed the default directory from
~/.superkaramba. Be sure to change all references to
k_weather.py in any Karamba themes that make use of it, or
else they may not work properly.'''
exit()
else:
print 'Unknown command'
exit()
try:
data = urlopen(url).read()
if data.find('Refresh') > 0:
import re
find_url = r'URL=(?P<url>.*?)">'
redirect = re.search(find_url, data)
print "Change URL to ", redirect.group('url')
exit()
else:
save = open(installed + '/karamba_weather.html', 'w')
print >> save, data
save.close()
weather = getWeather(data, metric, days)
except: # Maybe we're offline?
try: # Try to load the saved weather data
data = open(installed + '/karamba_weather.html', 'r').read()
weather = getWeather(data, metric, days)
except:
print "Fatal Error; Cannot connect to site or load old data"
exit()
# Add some items to the list
if metric:
scale = 'C'
else:
scale = 'F'
weather.insert(8, weather[8][:-3])
weather.insert(9, scale)
weather.insert(21, weather[1][:3])
weather.insert(26, weather[25] + ' °' + scale)
if clock:
if weather[6] == 'PM':
hour = weather[5][:-3]
weather[5] = str(int(hour) + 12) + weather[5][-3:]
# Add icon paths
weather[7] = 'large_icons/' + weather[7] + '.png'
for i in range(days + 1):
weather[(i * 7) + 23] = 'small_icons/' + weather[(i * 7) + 23] + '.png'
# Format highs and lows
for i in range(days):
high = weather[(i * 7) + 32]
low = weather[(i * 7) + 33]
if order:
temps = high + separator + low
else:
temps = low + separator + high
weather[(i * 7) + 32] = temps
weather[(i * 7) + 33] = temps + ' °' + scale
for item in weather:
print item
|
|
|
Back to top |
|
|
micron Guru
Joined: 23 Jul 2003 Posts: 411 Location: Bergamo, Italy
|
Posted: Tue Feb 17, 2004 3:36 pm Post subject: |
|
|
cata1986 wrote: | il problema di mettere in secondo piano il tema l'ho gia risolto... mi serve solo capire dove sbaglio la configurazione per fare andare le previsioni del tempo... |
E come hai fatto a risolverlo?!
Pendo dalle tue labbra!! _________________ ~ "Progress is merely a realisation of utopias" ~ |
|
Back to top |
|
|
cata1986 Tux's lil' helper
Joined: 01 Feb 2004 Posts: 111 Location: bologna
|
Posted: Tue Feb 17, 2004 4:48 pm Post subject: |
|
|
apri il .theme e alla prima riga dove c'è scritto ONTOP=TRUE lo cancelli.... |
|
Back to top |
|
|
micron Guru
Joined: 23 Jul 2003 Posts: 411 Location: Bergamo, Italy
|
Posted: Tue Feb 17, 2004 5:48 pm Post subject: |
|
|
cata1986 wrote: | apri il .theme e alla prima riga dove c'è scritto ONTOP=TRUE lo cancelli.... |
Putroppo nel .theme del plug-in che intendo usare non c'è questa opzione.
Ho provato ad aggiungere
ma non è cambiato nulla... _________________ ~ "Progress is merely a realisation of utopias" ~ |
|
Back to top |
|
|
cerri Bodhisattva
Joined: 05 Mar 2003 Posts: 2957 Location: # init S
|
Posted: Wed Feb 18, 2004 9:20 pm Post subject: |
|
|
cata1986: ti manca il pacchetto dev-perl/libwww-perl
micron: https://bugs.gentoo.org/show_bug.cgi?id=33243 _________________ Enjoy your freedom.
Sex is like hacking. You get in, you get out, and you hope you didnt leave something behind that can be traced back to you.
<----------------------->
Andrea Cerrito |
|
Back to top |
|
|
micron Guru
Joined: 23 Jul 2003 Posts: 411 Location: Bergamo, Italy
|
Posted: Thu Feb 19, 2004 2:16 pm Post subject: |
|
|
grazie mille, seguendo il tuo link ho trovato la soluzione qui .
Basta fare così:
Code: | ebuild /usr/portage/x11-misc/superkaramba/superkaramba-0.33.ebuild unpack
vim /var/tmp/portage/superkaramba-0.33/work/superkaramba-0.33/src/karamba.cpp |
e sostituire
Code: | //Matthew Kay: set window type to "dock" (plays better with taskbar themes this way)
KWin::setType(winId(), NET::Dock);
|
con
Code: | //Matthew Kay: set window type to "dock" (plays better with taskbar themes this way)
//KWin::setType(winId(), NET::Dock);
|
In seguito fate:
Code: | ebuild /usr/portage/x11-misc/superkaramba/superkaramba-0.33.ebuild merge |
Ora tutto funziona regolarmente, mi stupisco che non sia stato rilasciato un nuovo ebuild _________________ ~ "Progress is merely a realisation of utopias" ~ |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|