Add setting a specific file as desktop wallpaper.
This commit is contained in:
parent
d45d9a0b90
commit
11301f7203
|
@ -15,6 +15,7 @@ async function main(): Promise<void> {
|
|||
"--save-current <file: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", {
|
||||
default: 1920,
|
||||
depends: ["unsplash"],
|
||||
|
@ -25,6 +26,10 @@ async function main(): Promise<void> {
|
|||
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<void> {
|
|||
}).status();
|
||||
}
|
||||
|
||||
async function setWallpaper(): Promise<void> {
|
||||
async function setWallpaper(file: string = imagePath): Promise<void> {
|
||||
const monitors = ["monitorHDMI-0", "monitorHDMI-1"];
|
||||
for (const monitor of monitors) {
|
||||
await Deno.run({
|
||||
|
@ -52,7 +57,7 @@ async function setWallpaper(): Promise<void> {
|
|||
"-p",
|
||||
`/backdrop/screen0/${monitor}/workspace0/last-image`,
|
||||
"-s",
|
||||
imagePath,
|
||||
file,
|
||||
],
|
||||
}).status();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue