From a2cdc4f2f151111992a52c56a7df0ae6d387a351 Mon Sep 17 00:00:00 2001 From: Wizzard <25581244+Wizzard@users.noreply.toomuchslop.com> Date: Tue, 17 Oct 2023 12:50:37 -0400 Subject: [PATCH] Make theming the bar a configurable option --- config.example.json | 3 ++- main.js | 31 ++++++++++++++++--------------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/config.example.json b/config.example.json index a986e4b..c56e4eb 100644 --- a/config.example.json +++ b/config.example.json @@ -1,4 +1,5 @@ { "apiKey": "YOUR_LASTFM_API_KEY", - "username": "YOUR_LASTFM_USERNAME" + "username": "YOUR_LASTFM_USERNAME", + "themeBar": true } diff --git a/main.js b/main.js index d80075b..fc7b887 100644 --- a/main.js +++ b/main.js @@ -70,23 +70,24 @@ async function setAsWallpaper(buffer, dominantColor) { try { await fs.promises.writeFile('/tmp/current_album_cover.png', buffer, 'binary'); - const colorString = `#${dominantColor.r.toString(16).padStart(2, '0')}${dominantColor.g.toString(16).padStart(2, '0')}${dominantColor.b.toString(16).padStart(2, '0')}`; - - console.log(`Sending color string to Python script: ${colorString}`); - - const command = `python3 ./tap_in.py '${colorString}'`; - console.log("Running command:", command); - - exec(command, (error, stdout, stderr) => { - if (error) { - console.error(`Error running the command: ${error}`); - } - console.log(`Python stdout: ${stdout}`); - console.log(`Python stderr: ${stderr}`); - }); - exec('feh --bg-center /tmp/current_album_cover.png'); + if (config.themeBar) { + const colorString = `#${dominantColor.r.toString(16).padStart(2, '0')}${dominantColor.g.toString(16).padStart(2, '0')}${dominantColor.b.toString(16).padStart(2, '0')}`; + console.log(`Sending color string to Python script: ${colorString}`); + + const command = `python3 ./tap_in.py '${colorString}'`; + console.log("Running command:", command); + + exec(command, (error, stdout, stderr) => { + if (error) { + console.error(`Error running the command: ${error}`); + } + console.log(`Python stdout: ${stdout}`); + console.log(`Python stderr: ${stderr}`); + }); + } + console.log('Wallpaper and Qtile colors successfully updated.'); } catch (error) { console.error("Failed to set wallpaper and update Qtile colors:", error);