توی فایلی که تصویر رو به روز میکرد اون متن ubuntu رو با ساعت جایگزین کردم.
تم ساعت رو از کجا دانلود کردی؟ چطوری ساعت رو جایگزین کردی؟
اگر از تم زیر استفاده کردی چطوری کوچک کزدی و روی یک عکس دیگه داری استفاده میکنی؟
http://forum.ubuntu.ir/index.php/topic,58072.0.html
من python بلد نیستم پس هرجاش غلطه چیز عجیبی نیست
اینم فایله /usr/share/backgrounds/evolving-circle/update-wallpaper.py منه
#!/usr/bin/python
#Import things for the process check.
from os import path, getpid
from sys import exit
if path.exists("/tmp/evolving-circle.pid"):
f = open("/tmp/evolving-circle.pid", "r")
if path.exists("/proc/" + f.read()):
f.close()
exit(0) #This means there's another copy running.
f.close()
f = open("/tmp/evolving-circle.pid", "w")
f.write(str(getpid()))
f.close()
from math import sin, cos, radians
from random import random, randrange
from time import sleep
from datetime import datetime
from math import floor
Width = 1920
Height = 1200
Scale = 0.7
Centre = [1600, 300]
NumberOfCircles = 22
Hex = ["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"]
f = open("/usr/share/backgrounds/evolving-circle/template.svg", "r")
DefaultBackground = f.read()
f.close()
f = open("/usr/share/backgrounds/evolving-circle/template-custom.svg", "r")
CustomBackground = f.read()
f.close()
Colour = ""
Direction = ""
if path.exists("/var/log/evolving-circle/colour"):
f = open("/var/log/evolving-circle/colour", "r")
Colour, Direction = f.read().strip("\n").split("\n")
f.close()
else:
n = randrange(0,16)
Colour = "#ff" + Hex[max(0,n-8)] + "0" + Hex[max(0,9-n)] + "0"
if randrange(0,2) == 0:
Direction = "forward"
else:
Direction = "back"
f = open("/var/log/evolving-circle/colour", "w")
f.write(Colour + "\n" + Direction)
f.close()
Positions = []
if path.exists("/var/log/evolving-circle/positions"):
f = open("/var/log/evolving-circle/positions", "r")
exec("Positions = " + f.read())
f.close()
else:
for n in range(0,NumberOfCircles):
Positions.append(random()*360)
f = open("/var/log/evolving-circle/positions", "w")
f.write(str(Positions))
f.close()
if not path.exists("/var/log/evolving-circle/bg"):
f = open("/var/log/evolving-circle/bg", "w")
f.write("default")
f.close()
while True:
#Check that the package is still installed. If not, kill the script.
if not path.exists("/usr/share/backgrounds/evolving-circle/template.svg"):
exit(0)
Save = ""
f = open("/var/log/evolving-circle/bg", "r")
Settings = f.read()
f.close()
Data = ""
if Settings[0] == "#":
Data = CustomBackground.replace("#460f28", Settings)
else:
Data = DefaultBackground
Data = Data.replace( "ScaleValue", "scale(" + str(Scale)+")" )
Data = Data.replace( "HeightValue", str(Height) )
Data = Data.replace( "WidthValue", str(Width) )
for num in range(0,randrange(1,4)): #Do 1 to 3 increments.
if Direction == "forward":
if Hex.index(Colour[-3]) > 0:
Colour = Colour[:-3] + Hex[Hex.index(Colour[-3]) -1] + Colour[-2:]
elif Hex.index(Colour[-4]) > 0:
Colour = Colour[:-4] + Hex[Hex.index(Colour[-4]) -1] + "f" + Colour[-2:]
elif Hex.index(Colour[-1]) < 15:
Colour = Colour[:-1] + Hex[Hex.index(Colour[-1]) +1]
elif Hex.index(Colour[-2]) < 9:
Colour = Colour[:-2] + Hex[Hex.index(Colour[-2]) +1] + "0"
else:
Direction = "back"
# print "Going back"
else:
if Hex.index(Colour[-1]) > 0:
Colour = Colour[:-1] + Hex[Hex.index(Colour[-1]) -1]
elif Hex.index(Colour[-2]) > 0:
Colour = Colour[:-2] + Hex[Hex.index(Colour[-2]) -1] + "f"
elif Hex.index(Colour[-3]) < 15:
Colour = Colour[:-3] + Hex[Hex.index(Colour[-3]) +1] + Colour[-2:]
elif Hex.index(Colour[-4]) < 8:
Colour = Colour[:-4] + Hex[Hex.index(Colour[-4]) +1] + "0" + Colour[-2:]
else:
Direction = "forward"
# print "Going forward"
# print Colour
Data = Data.replace("#ffffff", Colour)
for n in range(1,NumberOfCircles+1):
Radius = int( Data.split("C"+str(n)+"_X")[0].rsplit("width=\"",1)[1].split("height=\"")[1].split("\"\n")[0] ) /2
#print Radius
Rand = Positions[n-1] + 12*(random()-0.5)
if Rand > 360:
Rand -= 360
elif Rand < 0:
Rand += 360
Save += str(Rand) + "," #Save the values in case of shutdown.
Positions[n-1] = Rand #Keep track of the values within this session of the script.
Rand = radians(Rand)
x = Centre[0]/Scale - Radius + 240 * cos(Rand)
y = Centre[1]/Scale - Radius + 240 * sin(Rand)
Data = Data.replace("C"+str(n)+"_X", str(x))
Data = Data.replace("C"+str(n)+"_Y", str(y))
Now = datetime.now()
TimeCount = int((Now.hour % 12) * 2 + floor(Now.minute / 30.0))
#print TimeCount
LoopOrder = []
if Now.hour <= 12:
LoopOrder = range(1,TimeCount+1)
else:
LoopOrder = range(TimeCount+1, 25)
for n in LoopOrder:
Temp = Data.find("\"#clockdot" + str(n) + "\"")
FindString = "style=\"fill:#fefefe;fill-opacity:"
Temp = Data[:Temp].rfind(FindString,1) + len(FindString)
#print Data[Temp:].find("\"") #TODO: use to prevent errors from mixed number of figures
Data = Data[:Temp] + "1.0" + Data[Temp+10:]
for n in range(1,25):
x = Centre[0]/Scale + 200.0 * cos( 4.71238898 - (n-1) * 0.261799388 ) - 3.6
y = Centre[1]/Scale + 200.0 * sin( 4.71238898 - (n-1) * 0.261799388 ) - 3.6
Data = Data.replace("inkscape:label=\"#clockdot"+str(n)+"\"","x=\""+str(x)+"\"\n y=\""+str(y)+"\"\n inkscape:label=\"#clockdot"+str(n)+"\"" )
Data = Data.replace("id=\"rect2988\"","id=\"rect2988\"\n x=\""+str(Centre[0]/Scale-240)+"\"\n y=\""+str(Centre[1]/Scale-240)+"\"")
Data = Data.replace("id=\"rect2988-4\"","id=\"rect2988-4\"\n x=\""+str(Centre[0]/Scale-240)+"\"\n y=\""+str(Centre[1]/Scale-240)+"\"")
if (Now.hour < 12 and Now.hour > 0):
Data=Data.replace("-inkscape-font-specification:Ubuntu\">Ubuntu","-inkscape-font-specification:Ubuntu\" x=\""+str(Centre[0]/Scale-81.67499)+"\" y=\""+str(Centre[1]/Scale+18.26398)+"\">"+str(Now.hour)+":"+str(Now.minute)+" AM")
elif (Now.hour == 12):
Data=Data.replace("-inkscape-font-specification:Ubuntu\">Ubuntu","-inkscape-font-specification:Ubuntu\" x=\""+str(Centre[0]/Scale-81.67499)+"\" y=\""+str(Centre[1]/Scale+18.26398)+"\">"+str(Now.hour)+":"+str(Now.minute)+" PM")
elif ( not Now.hour==0):
Data=Data.replace("-inkscape-font-specification:Ubuntu\">Ubuntu","-inkscape-font-specification:Ubuntu\" x=\""+str(Centre[0]/Scale-81.67499)+"\" y=\""+str(Centre[1]/Scale+18.26398)+"\">"+str(Now.hour-12)+":"+str(Now.minute)+" PM")
else:
Data=Data.replace("-inkscape-font-specification:Ubuntu\">Ubuntu","-inkscape-font-specification:Ubuntu\" x=\""+str(Centre[0]/Scale-81.67499)+"\" y=\""+str(Centre[1]/Scale+18.26398)+"\">"+"12"+":"+str(Now.minute)+" AM")
if path.exists("/usr/share/backgrounds/evolving-circle/template11.svg"):
f = open("/usr/share/backgrounds/evolving-circle/template11.svg", "r")
Data=Data.replace("<g","<g\n "+f.read()+"</g><g\n")
f.close()
f = open("/var/log/evolving-circle/positions", "w")
f.write(str(Positions))
f.close()
f = open("/var/log/evolving-circle/colour", "w")
f.write(Colour + "\n" + Direction)
f.close()
f = open("/var/log/evolving-circle/background.svg", "w")
f.write(Data)
f.close()
sleep(30)
اولاش چهار تا متغیر هست:
Width = 1920
Height = 1200
Scale = 0.7
Centre = [1600, 300]
Width و Height رو مطابق عکس که برای پس زمینه بود گذاشتم و Scale هم میزان کوچیک شدن اون ساعتس و Centre هم مکان ساعت رو تغییر میده
متن ساعت رو با این کد جایگزین کردم
if (Now.hour < 12 and Now.hour > 0):
Data=Data.replace("-inkscape-font-specification:Ubuntu\">Ubuntu","-inkscape-font-specification:Ubuntu\" x=\""+str(Centre[0]/Scale-81.67499)+"\" y=\""+str(Centre[1]/Scale+18.26398)+"\">"+str(Now.hour)+":"+str(Now.minute)+" AM")
elif (Now.hour == 12):
Data=Data.replace("-inkscape-font-specification:Ubuntu\">Ubuntu","-inkscape-font-specification:Ubuntu\" x=\""+str(Centre[0]/Scale-81.67499)+"\" y=\""+str(Centre[1]/Scale+18.26398)+"\">"+str(Now.hour)+":"+str(Now.minute)+" PM")
elif ( not Now.hour==0):
Data=Data.replace("-inkscape-font-specification:Ubuntu\">Ubuntu","-inkscape-font-specification:Ubuntu\" x=\""+str(Centre[0]/Scale-81.67499)+"\" y=\""+str(Centre[1]/Scale+18.26398)+"\">"+str(Now.hour-12)+":"+str(Now.minute)+" PM")
else:
Data=Data.replace("-inkscape-font-specification:Ubuntu\">Ubuntu","-inkscape-font-specification:Ubuntu\" x=\""+str(Centre[0]/Scale-81.67499)+"\" y=\""+str(Centre[1]/Scale+18.26398)+"\">"+"12"+":"+str(Now.minute)+" AM")
و برای پس زمینه هم این
if path.exists("/usr/share/backgrounds/evolving-circle/template11.svg"):
f = open("/usr/share/backgrounds/evolving-circle/template11.svg", "r")
Data=Data.replace("<g","<g\n "+f.read()+"</g><g\n")
f.close()
که template11.svg اسم فایل svg که می خوام بکگراند باشه ولی مشکل اینه که باید یه جور چند خط اول فایل رو پاک کرد (که من بلد نبود چجوری با python این کارو بکنم مجبور شدم دستی این کار رو بکنم
به همین خاطر عکس پس زمینم قابل دیدن نیست و فقط این برنامه میتونه ازش استفاده کنه اگر کسی بلده راهنمایی کنه ممنون میشم ) مشکل دوم هم اینه که فایل template.svg هم باید تغییر کنه چون مختصات اون دایره کوچولو های دور ساعت باید عوض شه که من اون فایل رو ضمیمه کردم باید توی
/usr/share/backgrounds/evolving-circle
جایگزینش کنید.
http://ubuntuone.com/4OlOOMd8CbKDtcz8XkIDQlاینم بکگراندم که تغییرش دادم
http://ubuntuone.com/2Dg24lhXhmt0PrY0sswS1G