1
Fork 0

Add setting a specific file as desktop wallpaper.

This commit is contained in:
Bauke 2023-01-29 13:28:02 +01:00
parent d45d9a0b90
commit 11301f7203
Signed by: Bauke
GPG Key ID: C1C0F29952BCF558
1 changed files with 7 additions and 2 deletions

View File

@ -15,6 +15,7 @@ async function main(): Promise<void> {
"--save-current <file:file>", "--save-current <file:file>",
"Save the current wallpaper to a different file", "Save the current wallpaper to a different file",
) )
.option("--set <file:file>", "Set a file as the wallpaper")
.option("--width <width:number>", "The width of the image", { .option("--width <width:number>", "The width of the image", {
default: 1920, default: 1920,
depends: ["unsplash"], depends: ["unsplash"],
@ -25,6 +26,10 @@ async function main(): Promise<void> {
await Deno.copyFile(imagePath, options.saveCurrent); await Deno.copyFile(imagePath, options.saveCurrent);
} }
if (options.set) {
await setWallpaper(options.set);
}
if (options.unsplash) { if (options.unsplash) {
await downloadImage( await downloadImage(
`https://source.unsplash.com/random/${options.width}x${options.height}`, `https://source.unsplash.com/random/${options.width}x${options.height}`,
@ -41,7 +46,7 @@ async function downloadImage(url: string): Promise<void> {
}).status(); }).status();
} }
async function setWallpaper(): Promise<void> { async function setWallpaper(file: string = imagePath): Promise<void> {
const monitors = ["monitorHDMI-0", "monitorHDMI-1"]; const monitors = ["monitorHDMI-0", "monitorHDMI-1"];
for (const monitor of monitors) { for (const monitor of monitors) {
await Deno.run({ await Deno.run({
@ -52,7 +57,7 @@ async function setWallpaper(): Promise<void> {
"-p", "-p",
`/backdrop/screen0/${monitor}/workspace0/last-image`, `/backdrop/screen0/${monitor}/workspace0/last-image`,
"-s", "-s",
imagePath, file,
], ],
}).status(); }).status();
} }