Compare commits

...

2 Commits

Author SHA1 Message Date
Wizzard d834eed748 Save image to /tmp rather than current directory 2023-10-16 16:40:07 -04:00
Wizzard 96634a7e9e Allow pngs 2023-10-16 16:38:25 -04:00
1 changed files with 4 additions and 4 deletions

View File

@ -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);