From 11301f7203a8a5c5b33f3b3d38d10f40d30c32e4 Mon Sep 17 00:00:00 2001 From: Bauke Date: Sun, 29 Jan 2023 13:28:02 +0100 Subject: [PATCH] Add setting a specific file as desktop wallpaper. --- .bauke/scripts/desktop-wallpaper.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.bauke/scripts/desktop-wallpaper.ts b/.bauke/scripts/desktop-wallpaper.ts index 89b2e6b..8befc11 100644 --- a/.bauke/scripts/desktop-wallpaper.ts +++ b/.bauke/scripts/desktop-wallpaper.ts @@ -15,6 +15,7 @@ async function main(): Promise { "--save-current ", "Save the current wallpaper to a different file", ) + .option("--set ", "Set a file as the wallpaper") .option("--width ", "The width of the image", { default: 1920, depends: ["unsplash"], @@ -25,6 +26,10 @@ async function main(): Promise { await Deno.copyFile(imagePath, options.saveCurrent); } + if (options.set) { + await setWallpaper(options.set); + } + if (options.unsplash) { await downloadImage( `https://source.unsplash.com/random/${options.width}x${options.height}`, @@ -41,7 +46,7 @@ async function downloadImage(url: string): Promise { }).status(); } -async function setWallpaper(): Promise { +async function setWallpaper(file: string = imagePath): Promise { const monitors = ["monitorHDMI-0", "monitorHDMI-1"]; for (const monitor of monitors) { await Deno.run({ @@ -52,7 +57,7 @@ async function setWallpaper(): Promise { "-p", `/backdrop/screen0/${monitor}/workspace0/last-image`, "-s", - imagePath, + file, ], }).status(); }