Compare commits
2 Commits
7d9800806a
...
d834eed748
Author | SHA1 | Date |
---|---|---|
Wizzard | d834eed748 | |
Wizzard | 96634a7e9e |
8
main.js
8
main.js
|
@ -18,8 +18,8 @@ async function processAlbumCover(url) {
|
||||||
const imageSharp = sharp(imageBuffer);
|
const imageSharp = sharp(imageBuffer);
|
||||||
const metadata = await imageSharp.metadata();
|
const metadata = await imageSharp.metadata();
|
||||||
|
|
||||||
if (metadata.format !== 'jpeg' && metadata.format !== 'jpg') {
|
if (metadata.format !== 'jpeg' && metadata.format !== 'jpg' && metadata.format !== 'png') {
|
||||||
throw new Error('Not a JPEG image');
|
throw new Error('Not a supported image format');
|
||||||
}
|
}
|
||||||
|
|
||||||
const dominantColor = await getDominantColor(imageBuffer);
|
const dominantColor = await getDominantColor(imageBuffer);
|
||||||
|
@ -67,8 +67,8 @@ async function getDominantColor(imageBuffer) {
|
||||||
|
|
||||||
async function setAsWallpaper(buffer) {
|
async function setAsWallpaper(buffer) {
|
||||||
try {
|
try {
|
||||||
await fs.promises.writeFile('current_album_cover.png', buffer);
|
await fs.promises.writeFile('/tmp/current_album_cover.png', buffer);
|
||||||
exec('feh --bg-center current_album_cover.png');
|
exec('feh --bg-center /tmp/current_album_cover.png');
|
||||||
console.log("Wallpaper set using feh.");
|
console.log("Wallpaper set using feh.");
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error setting wallpaper:", error);
|
console.error("Error setting wallpaper:", error);
|
||||||
|
|
Loading…
Reference in New Issue