fix for certain things

This commit is contained in:
Zacharias-Brohn
2026-02-21 18:32:03 +01:00
parent 23ccc0e1e8
commit ab02c679ca
22 changed files with 924 additions and 1259 deletions
-22
View File
@@ -1,22 +0,0 @@
from PIL import Image, ImageFilter
import argparse
def gen_blurred_image(input_image, output_path, blur_amount):
img = Image.open(input_image)
size = img.size
img = img.resize((size[0] // 2, size[1] // 2), Image.NEAREST)
img = img.filter(ImageFilter.GaussianBlur(blur_amount))
# img = img.resize(size, Image.LANCZOS)
img.save(output_path, "PNG")
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Generate a blurred lock screen background image.")
parser.add_argument("--input_image", type=str)
parser.add_argument("--output_path", type=str)
parser.add_argument("--blur_amount", type=int)
args = parser.parse_args()
gen_blurred_image(args.input_image, args.output_path, args.blur_amount)
-123
View File
@@ -1,123 +0,0 @@
import json
import argparse
from pathlib import Path
from PIL import Image
from materialyoucolor.quantize import QuantizeCelebi
from materialyoucolor.score.score import Score
from materialyoucolor.dynamiccolor.material_dynamic_colors import MaterialDynamicColors
from materialyoucolor.hct.hct import Hct
parser = argparse.ArgumentParser(
description="Generate color scheme from wallpaper image"
)
parser.add_argument(
"--path",
required=True,
help="Path to the wallpaper image"
)
parser.add_argument(
"--output",
required=True,
help="Path to save the color scheme JSON file"
)
parser.add_argument(
"--thumbnail",
required=True,
help="Path to save the thumbnail image"
)
parser.add_argument(
"--scheme",
required=False,
type=str,
default="vibrant",
)
args = parser.parse_args()
if args.scheme == 'fruit-salad':
from materialyoucolor.scheme.scheme_fruit_salad import SchemeFruitSalad as Scheme
elif args.scheme == 'expressive':
from materialyoucolor.scheme.scheme_expressive import SchemeExpressive as Scheme
elif args.scheme == 'monochrome':
from materialyoucolor.scheme.scheme_monochrome import SchemeMonochrome as Scheme
elif args.scheme == 'rainbow':
from materialyoucolor.scheme.scheme_rainbow import SchemeRainbow as Scheme
elif args.scheme == 'tonal-spot':
from materialyoucolor.scheme.scheme_tonal_spot import SchemeTonalSpot as Scheme
elif args.scheme == 'neutral':
from materialyoucolor.scheme.scheme_neutral import SchemeNeutral as Scheme
elif args.scheme == 'fidelity':
from materialyoucolor.scheme.scheme_fidelity import SchemeFidelity as Scheme
elif args.scheme == 'content':
from materialyoucolor.scheme.scheme_content import SchemeContent as Scheme
elif args.scheme == 'vibrant':
from materialyoucolor.scheme.scheme_vibrant import SchemeVibrant as Scheme
else:
from materialyoucolor.scheme.scheme_tonal_spot import SchemeTonalSpot as Scheme
def generate_thumbnail(image_path, thumbnail_path, size=(128, 128)):
thumbnail_file = Path(thumbnail_path)
image = Image.open(image_path)
image = image.convert("RGB")
image.thumbnail(size, Image.NEAREST)
thumbnail_file.parent.mkdir(parents=True, exist_ok=True)
image.save(thumbnail_path, "JPEG")
def generate_color_scheme(thumbnail_path, output_path):
image = Image.open(thumbnail_path)
pixel_len = image.width * image.height
image_data = image.getdata()
quality = 1
pixel_array = [image_data[_] for _ in range(0, pixel_len, quality)]
result = QuantizeCelebi(pixel_array, 128)
score = Score.score(result)[0]
scheme = Scheme(
Hct.from_int(score),
True,
0.0
)
color_dict = {}
for color in vars(MaterialDynamicColors).keys():
color_name = getattr(MaterialDynamicColors, color)
if hasattr(color_name, "get_hct"):
color_int = color_name.get_hct(scheme).to_int()
color_dict[color] = int_to_hex(color_int)
output_dict = {
"name": "dynamic",
"flavour": "default",
"mode": "dark",
"variant": "tonalspot",
"colors": color_dict
}
output_file = Path(output_path)
output_file.parent.mkdir(parents=True, exist_ok=True)
with open(output_file, "w") as f:
json.dump(output_dict, f, indent=4)
def int_to_hex(argb_int):
return "#{:06X}".format(argb_int & 0xFFFFFF)
try:
generate_thumbnail(args.path, str(args.thumbnail))
generate_color_scheme(str(args.thumbnail), args.output)
except Exception as e:
print(f"Error: {e}")
with open(args.output, "w") as f:
f.write(f"Error: {e}")
-103
View File
@@ -1,103 +0,0 @@
#!/usr/bin/env python3
"""
Calendar cache generator for z-bar-qt
Generates a JSON file containing date numbers for all 52 weeks of 3 years (last, current, next)
Structure: { "2024": { "week_0": [1,2,3,4,5,6,7], ... }, "2025": {...}, ... }
"""
import json
import sys
from datetime import datetime, timedelta
from pathlib import Path
def get_week_start_day():
"""Returns the first day of the week (0=Sunday, 1=Monday, etc.) - hardcoded to Monday"""
return 1 # Monday
def get_weeks_for_year(year, week_start_day=1):
"""
Generate week data for a given year.
Returns a dict with 52 weeks, each containing 7 date numbers.
"""
weeks = {}
# Find the first day of the year
jan_1 = datetime(year, 1, 1)
# Find the first week's start date (adjust based on week_start_day)
first_date = jan_1 - timedelta(days=(jan_1.weekday() - week_start_day) % 7)
# Generate 52 weeks
for week_num in range(52):
week_dates = []
week_start = first_date + timedelta(weeks=week_num)
for day_offset in range(7):
current_date = week_start + timedelta(days=day_offset)
week_dates.append(current_date.day)
weeks[f"week_{week_num}"] = week_dates
return weeks
def generate_calendar_cache(year=None):
"""Generate cache for last year, current year, and next year"""
if year is None:
year = datetime.now().year
cache = {}
for offset_year in [-1, 0, 1]:
target_year = year + offset_year
cache[str(target_year)] = get_weeks_for_year(target_year)
return cache
def write_cache_file(cache_data):
"""Write cache to the same location as Paths.cache in QML"""
import os
# Use XDG_CACHE_HOME or ~/.cache, then add /zshell (matching Paths singleton)
xdg_cache_home = os.environ.get("XDG_CACHE_HOME")
if xdg_cache_home:
cache_dir = Path(xdg_cache_home) / "zshell"
else:
cache_dir = Path.home() / ".cache" / "zshell"
cache_dir.mkdir(parents=True, exist_ok=True)
cache_file = cache_dir / "calendar_cache.json"
with open(cache_file, "w") as f:
json.dump(cache_data, f, indent=2)
print(f"Calendar cache written to: {cache_file}")
return cache_file
def main():
try:
# Generate cache for current year and ±1 year
cache = generate_calendar_cache()
# Write to file
cache_file = write_cache_file(cache)
print("Cache structure:")
print(" - Keys: year (e.g., '2024', '2025', '2026')")
print(" - Values: dict with 52 weeks")
print(" - Each week: array of 7 date numbers")
print(f"\nExample (first week of 2025):")
print(f" {cache['2025']['week_0']}")
return 0
except Exception as e:
print(f"Error generating calendar cache: {e}", file=sys.stderr)
return 1
if __name__ == "__main__":
sys.exit(main())
View File
-22
View File
@@ -1,22 +0,0 @@
#!/usr/bin/env bash
QML_ROOT=/home/zach/GitProjects/z-bar-qt/scripts/..
LOCK=false
main() {
local OPTARG OPTIND opt
while getopts "l" opt; do
case "$opt" in
l) LOCK=true ;;
*) fatal 'bad option' ;;
esac
done
if [[ "$LOCK" = "true" ]]; then
hyprctl dispatch global zshell:lock
else
qs -n -d -p "$QML_ROOT/shell.qml"
fi
}
main "$@"
-22
View File
@@ -1,22 +0,0 @@
#!/usr/bin/env bash
QML_ROOT=/home/zach/GitProjects/z-bar-qt/scripts/..
LOCK=false
main() {
local OPTARG OPTIND opt
while getopts "l" opt; do
case "$opt" in
l) LOCK=true ;;
*) fatal 'bad option' ;;
esac
done
if [[ "$LOCK" = "true" ]]; then
hyprctl dispatch global zshell:lock
else
qs -n -d -p "$QML_ROOT/shell.qml"
fi
}
main "$@"