feat: skip two-way copy for cuda devices when decoding video wallpapers + cache wallpapers as blobs in new database
C++ / fmt (pull_request) Failing after 11s
C++ / build (pull_request) Failing after 14s
C++ / clang-tidy (pull_request) Failing after 9s
JS/TS / fmt (pull_request) Successful in 10s
JS/TS / lint (pull_request) Successful in 8s
Python / static (pull_request) Failing after 28s
Rust / build (pull_request) Successful in 47s
Python / verify (pull_request) Failing after 1m20s
Rust / fmt (pull_request) Successful in 28s
Rust / clippy (pull_request) Successful in 59s
C++ / fmt (pull_request) Failing after 11s
C++ / build (pull_request) Failing after 14s
C++ / clang-tidy (pull_request) Failing after 9s
JS/TS / fmt (pull_request) Successful in 10s
JS/TS / lint (pull_request) Successful in 8s
Python / static (pull_request) Failing after 28s
Rust / build (pull_request) Successful in 47s
Python / verify (pull_request) Failing after 1m20s
Rust / fmt (pull_request) Successful in 28s
Rust / clippy (pull_request) Successful in 59s
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
import contextlib
|
||||
import io
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import sqlite3
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
@@ -50,6 +52,30 @@ VIDEO_EXTENSIONS = {
|
||||
}
|
||||
|
||||
|
||||
def scheme_thumb_from_db(db_path: str, wallpaper_path: str) -> bytes | None:
|
||||
if not os.path.exists(db_path):
|
||||
return None
|
||||
|
||||
try:
|
||||
conn = sqlite3.connect(f"file:{db_path}?mode=ro", uri=True)
|
||||
except sqlite3.Error:
|
||||
return None
|
||||
|
||||
try:
|
||||
row = conn.execute(
|
||||
"SELECT scheme_thumb FROM wallpapers WHERE path = ?",
|
||||
(wallpaper_path,),
|
||||
).fetchone()
|
||||
except sqlite3.Error:
|
||||
return None
|
||||
finally:
|
||||
conn.close()
|
||||
|
||||
if row and row[0]:
|
||||
return bytes(row[0])
|
||||
return None
|
||||
|
||||
|
||||
def _complete_scheme_name(incomplete):
|
||||
schemes = [
|
||||
"fruit-salad",
|
||||
@@ -181,6 +207,7 @@ def generate(
|
||||
OUTPUT = Path(HOME + "/.local/state/zshell/scheme.json")
|
||||
SEQ_STATE = Path(HOME + "/.local/state/zshell/sequences.txt")
|
||||
THUMB_DIR = Path(HOME + "/.cache/zshell/imagecache/thumbnails")
|
||||
DB_PATH = Path(HOME + "/.local/state/zshell/wallpapers.sqlite")
|
||||
WALL_DIR_PATH = Path(HOME + "/.local/state/zshell/wallpaper_path.json")
|
||||
|
||||
TEMPLATE_DIR = Path(HOME + "/.config/zshell/templates")
|
||||
@@ -808,13 +835,20 @@ def generate(
|
||||
seed = hex_to_hct(colors.get("primary", "#000000").lstrip("#"))
|
||||
else:
|
||||
image_path = image_path or Path(WALL_PATH)
|
||||
thumb_path = generate_thumbnail(image_path, THUMB_DIR)
|
||||
seed = seed_from_image(thumb_path)
|
||||
|
||||
blob = scheme_thumb_from_db(str(DB_PATH), str(image_path))
|
||||
if blob is not None:
|
||||
open_thumb = lambda: io.BytesIO(blob)
|
||||
else:
|
||||
thumb_path = generate_thumbnail(image_path, THUMB_DIR)
|
||||
open_thumb = lambda: thumb_path
|
||||
|
||||
seed = seed_from_image(open_thumb())
|
||||
name = "dynamic"
|
||||
flavor = "default"
|
||||
|
||||
if smart:
|
||||
effective_mode = smart_mode(thumb_path)
|
||||
effective_mode = smart_mode(open_thumb())
|
||||
elif mode is not None:
|
||||
effective_mode = mode
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user