Skip to content

Commit

Permalink
Revert "Added readme"
Browse files Browse the repository at this point in the history
This reverts commit 62c00ff.
  • Loading branch information
duch3201 committed Feb 3, 2023
1 parent 62c00ff commit 1df0df1
Show file tree
Hide file tree
Showing 8 changed files with 150 additions and 57 deletions.
Binary file added Fonts/.DS_Store
Binary file not shown.
Binary file added Fonts/Raleway-Medium.ttf
Binary file not shown.
50 changes: 0 additions & 50 deletions Readme.md

This file was deleted.

22 changes: 17 additions & 5 deletions Themes/MCwalp.udd/Wallpaper.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,36 @@
{
"name":"MC Wallpaper",
"name":"MC Wallpaper",
"desc":"Just a wallpaper pack from minecraft",
"Day":[
{
"id":1,
"file":"1.png",
"tag":"dawn"
"tag":"dawn",
"title":"Minecraft canyon - In the morning",
"desc":"Photo by krzysztof"
},
{
"id":2,
"file":"2.png",
"tag":"day"
"tag":"day",
"title":"Minecraft canyon - At noon",
"desc":"Photo by krzysztof"
}
],
"Night":[
{
"id":3,
"file":"3.png",
"tag":"sunset"
"tag":"sunset",
"title":"Minecraft canyon - At sun set",
"desc":"Photo by krzysztof"
},
{
"id":4,
"file":"4.png",
"tag":"night"
"tag":"night",
"title":"Minecraft canyon - At night",
"desc":"Photo by krzysztof"
}
]
}
18 changes: 16 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import sys
import time
import utils

import menu
import pytz
from astral.location import LocationInfo
from astral.sun import sun
Expand Down Expand Up @@ -60,6 +60,8 @@ def Darwin():
current_time = now.strftime("%H:%M")
#print(current_time)

Wallpaper_info, Wallpaper_interval, Info_position, City, Country = utils.get_settings("null")



SelectedWalp = utils.GetSelectedWallpaper()
Expand All @@ -73,15 +75,24 @@ def Darwin():
if dawn.time() <= current_time < sunrise.time():
print("dawn")
img = jsonTheme["Day"][0]["file"]
if Wallpaper_info == True:
img = utils.add_text(Info_position, img)
elif sunrise.time() <= current_time < sunset.time():
print("day")
img = jsonTheme["Day"][1]["file"]
if Wallpaper_info == True:
img = utils.add_text(Info_position, img)
elif sunset.time() <= current_time < dusk.time():
img = jsonTheme["Night"][0]["file"]
print("sunset")
if Wallpaper_info == True:
img = utils.add_text(Info_position, img)
else:
img = jsonTheme["Night"][1]["file"]
print("night")
if Wallpaper_info == True:
img = utils.add_text(Info_position, img)


path_to_image = path + "/images/" + str(img)
path = NSURL.fileURLWithPath_(path_to_image)
Expand Down Expand Up @@ -127,6 +138,8 @@ def main():

os_name = platform.system()

Refresh_interval = utils.get_settings("Wallpaper_interval")

if os_name == "Windows":
utils.discovery()
Windowswalp()
Expand All @@ -136,6 +149,7 @@ def main():
utils.discovery()
while True:
Darwin()
time.sleep(5)
print(Refresh_interval)
time.sleep(Refresh_interval)

main()
12 changes: 12 additions & 0 deletions menu.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import os
import json


def menu():
print("hello")
with open("settings.json", 'r') as f:
JsonSettings = json.load(f)

print(JsonSettings)

input()
9 changes: 9 additions & 0 deletions settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"wallpaperRefreshInterval": 10,
"showWallpaperInfo": true,
"infoPosition": "bottom-right",
"autoStart": false,
"city": "Bydgoszcz",
"country": "Poland"
}

96 changes: 96 additions & 0 deletions utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import os
from AppKit import NSScreen, NSWindow, NSWorkspace, NSURL
import datetime
from PIL import Image, ImageDraw, ImageFont

def set_wallpaper(image_path):
workspace = NSWorkspace.sharedWorkspace()
Expand Down Expand Up @@ -29,6 +30,75 @@ def FirstRun():
def init():
pass


def add_text(position, img):

SelectedWalp = GetSelectedWallpaper()
path = os.getcwd() + "/Themes/" + SelectedWalp
with open(path + "/Wallpaper.json") as f:
jsonTheme = json.load(f)

img = Image.open(path + "/images/" + jsonTheme["Night"][0]["file"])
d1 = ImageDraw.Draw(img)
myFont = ImageFont.truetype('./Fonts/Raleway-Medium.ttf', 40)
myFontt = ImageFont.truetype('./Fonts/Raleway-Medium.ttf', 25)

# Get the font size
font_size = 40

# Get the width and height of the image
width, height = img.size

img_title = jsonTheme["Night"][0]["file"].split(".")
img_desc = jsonTheme["Night"][0]["desc"]


if position == 'bottom_left':
x = 50
y = height - font_size - 80

xx = 50
yy = height - font_size - 30

d1.text((x, y), img_title[0], font=myFont, fill=(71, 71, 71))
d1.text((xx, yy), img_desc, font=myFontt, fill=(71, 71, 71))
img.show()
return img
img.save("image_text.png")
elif position == 'bottom_right':
x = width - font_size * len(img_title[0]) - 50
y = height - font_size - 80

xx = width - font_size * len(img_desc) + 645
yy = height - font_size - 30

d1.text((x, y), img_title[0], font=myFont, fill=(71, 71, 71))
d1.text((xx, yy), img_desc, font=myFontt, fill=(71, 71, 71))
img.show()
img.save("image_text.png")
elif position == 'top_left':
x = 50
y = 50

xx = 50
yy = 100

d1.text((x, y), img_title[0], font=myFont, fill=(71, 71, 71))
d1.text((xx, yy), img_desc, font=myFontt, fill=(71, 71, 71))
img.show()
img.save("image_text.png")
elif position == 'top_right':
x = width - font_size * len(img_title[0]) - 50
y = 50

xx = width - font_size * len(img_desc) + 645
d1.text((x, y), img_title[0], font=myFont, fill=(71, 71, 71))
yy = 100
d1.text((xx, yy), img_desc, font=myFontt, fill=(71, 71, 71))
img.show()
img.save("image_text.png")


def get_milestones():
from astral.sun import sun
from astral.location import LocationInfo
Expand All @@ -43,6 +113,32 @@ def get_milestones():

return dawn, sunrise, sunset, dusk

def get_settings(setting):
with open("settings.json", "r") as f:
settings = json.load(f)

Wallpaper_interval = settings["wallpaperRefreshInterval"]
Wallpaper_info = settings["showWallpaperInfo"]
Info_position = settings["showWallpaperInfo"]
City = settings["city"]
Country = settings["country"]

if setting == "null":

return Wallpaper_info, Wallpaper_interval, Info_position, City, Country
elif setting == "Wallpaper_info":
return Wallpaper_info
elif setting == "Wallpaper_interval":
return Wallpaper_interval
elif setting == "Info_position":
return Info_position
elif setting == "City":
return City
elif setting == "Country":
return Country
else:
return "Invalid setting"

def get_current_time():
now = datetime.datetime.now().time()
return now
Expand Down

0 comments on commit 1df0df1

Please sign in to comment.