diff options
Diffstat (limited to 'src/services')
| -rw-r--r-- | src/services/wallpapers.ts | 18 |
1 files changed, 3 insertions, 15 deletions
diff --git a/src/services/wallpapers.ts b/src/services/wallpapers.ts index 4c7c49b..f0a68af 100644 --- a/src/services/wallpapers.ts +++ b/src/services/wallpapers.ts @@ -1,6 +1,6 @@ -import { basename } from "@/utils/strings"; import { monitorDirectory } from "@/utils/system"; -import { execAsync, GLib, GObject, property, register } from "astal"; +import Thumbnailer from "@/utils/thumbnailer"; +import { execAsync, GObject, property, register } from "astal"; import { wallpapers as config } from "config"; export interface IWallpaper { @@ -22,8 +22,6 @@ export default class Wallpapers extends GObject.Object { return this.instance; } - #thumbnailDir = `${CACHE}/thumbnails`; - #list: IWallpaper[] = []; #categories: ICategory[] = []; @@ -37,14 +35,6 @@ export default class Wallpapers extends GObject.Object { return this.#categories; } - async #thumbnail(path: string) { - const dir = path.slice(1, path.lastIndexOf("/")).replaceAll("/", "-"); - const thumbPath = `${this.#thumbnailDir}/${dir}-${basename(path)}.jpg`; - if (!GLib.file_test(thumbPath, GLib.FileTest.EXISTS)) - await execAsync(`magick -define jpeg:size=1000x500 ${path} -thumbnail 500x250 -unsharp 0x.5 ${thumbPath}`); - return thumbPath; - } - #listDir(path: { path: string; recursive: boolean }, type: "f" | "d") { const absPath = path.path.replace("~", HOME); const maxDepth = path.recursive ? "" : "-maxdepth 1"; @@ -68,7 +58,7 @@ export default class Wallpapers extends GObject.Object { const files = successes.map(r => r.files.replaceAll("\n", " ")).join(" "); const list = (await execAsync(["fish", "-c", `identify -ping -format '%i\n' ${files} ; true`])).split("\n"); - this.#list = await Promise.all(list.map(async p => ({ path: p, thumbnail: await this.#thumbnail(p) }))); + this.#list = await Promise.all(list.map(async p => ({ path: p, thumbnail: await Thumbnailer.thumbnail(p) }))); this.notify("list"); const categories = await Promise.all(successes.map(r => this.#listDir(r.path, "d"))); @@ -82,8 +72,6 @@ export default class Wallpapers extends GObject.Object { constructor() { super(); - GLib.mkdir_with_parents(this.#thumbnailDir, 0o755); - this.update().catch(console.error); let monitors = config.paths |