From c7ccfc5613fa55cddbed8aac8994a1e15a82aa41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=AD=E3=83=A3=E3=83=83=E3=83=84=E3=82=A6=E3=82=A3?= =?UTF-8?q?=E3=82=BA=E3=83=A9=E3=82=A4=E3=82=B9?= <103961848+Vaneeyo@users.noreply.github.com> Date: Mon, 23 Oct 2023 12:39:53 +0200 Subject: [PATCH] autostart fixed --- main.js | 21 ++++++--- .../widgets/videoPlayer/upcomingMovies.css | 33 ++++++++++++++ src/js/videoPlayer/upcomingMovies.js | 40 +++++++++++++++++ src/res/ic_oui_movie.svg | 1 + src/widgets/videoPlayer/upcomingMovies.html | 43 +++++++++++++++++++ 5 files changed, 131 insertions(+), 7 deletions(-) create mode 100644 src/css/widgets/videoPlayer/upcomingMovies.css create mode 100644 src/js/videoPlayer/upcomingMovies.js create mode 100644 src/res/ic_oui_movie.svg create mode 100644 src/widgets/videoPlayer/upcomingMovies.html diff --git a/main.js b/main.js index 86a4cc4..4b6ab30 100644 --- a/main.js +++ b/main.js @@ -7,13 +7,17 @@ const fs = require('fs') const path = require('path'); const icon = __dirname + '/favicon.ico' const { spawn } = require('child_process'); -const exeName = path.basename(process.execPath) -// starts the app at login -app.setLoginItemSettings({ - openAtLogin: true, - path: exeName -}); +// checks if the appExe is named electron so it doesn't autostart electron.exe while autostarting +if (!app.getPath('exe').includes('electron')) { + // starts the app at login + app.setLoginItemSettings({ + openAtLogin: true, + path: app.getPath('exe') + }); +} + + // starts the background Serivce which provides information for the music and device care widget const backgroundServicePath = './backgroundService/backgroundService.exe'; @@ -38,6 +42,7 @@ let quickNotesWidget = null; let untisWidget = null; let digitalClockWidget = null; let forecastWidget = null; +let upcomingMovies = null; const folderPath = path.join(os.homedir(), 'AppData', 'Local', 'Samsung-Widgets'); @@ -61,6 +66,7 @@ const positionData = { untisWidget: { y: "900", x: "75" }, digitalClockWidget: { y: "75", x: "875" }, forecastWidget: { y: "200", x: "875" }, + forecastWidget: { y: "375", x: "875" }, }; const stateData = { @@ -77,6 +83,7 @@ const stateData = { untisWidget: { show: "false" }, digitalClockWidget: { show: "true" }, forecastWidget: { show: "false" }, + upcomingMovies: { show: "false" }, }; const weatherData = { @@ -135,7 +142,7 @@ const widgetsData = { { name: "quickNotesWidget", width: 390, height: 175, html: "./src/widgets/notes/quickNotes.html", "clickthrough": false }, { name: "untisWidget", width: 390, height: 125, html: "./src/widgets/untis.html", "clickthrough": true }, { name: "digitalClockWidget", width: 390, height: 100, html: "./src/widgets/clock/digitalClock.html", "clickthrough": true }, - { name: "forecastWidget", width: 390, height: 150, html: "./src/widgets/weather/forecast.html", "clickthrough": true }, + { name: "forecastWidget", width: 390, height: 175, html: "./src/widgets/videoPlayer/upcomingMovies.html", "clickthrough": true }, ], }; diff --git a/src/css/widgets/videoPlayer/upcomingMovies.css b/src/css/widgets/videoPlayer/upcomingMovies.css new file mode 100644 index 0000000..19e151e --- /dev/null +++ b/src/css/widgets/videoPlayer/upcomingMovies.css @@ -0,0 +1,33 @@ +body { + top: 0; + margin: 0; + height: 100vh; +} + +#container-main { + height: 100%; + width: 100%; + display: flex; + border-radius: 33px; + padding: 5px 15px 5px 15px; + box-sizing: border-box; + align-items: center; + justify-content: center; + flex-direction: column; +} + +header { + display: flex; + width: 95%; + height: 30px; + justify-content: space-between; + align-items: center; + box-sizing: border-box; + padding: 0 2px 0 2px; +} + +#container-movies { + display: flex; + justify-content: center; + align-items: center; +} \ No newline at end of file diff --git a/src/js/videoPlayer/upcomingMovies.js b/src/js/videoPlayer/upcomingMovies.js new file mode 100644 index 0000000..a5be5a9 --- /dev/null +++ b/src/js/videoPlayer/upcomingMovies.js @@ -0,0 +1,40 @@ +const os = require('os') +const fs = require('fs') +const path = require('path'); +const contrast = require('wcag-contrast') + +const folderPath = path.join(os.homedir(), 'AppData', 'Local', 'Samsung-Widgets'); + +window.addEventListener("DOMContentLoaded", () => { + const containerMain = document.getElementById("container-main"); + + const secondaryColors = [ + [179, 179, 179], + [142, 142, 142] + ]; + + const textColors = [ + [0, 0, 0], + [250, 250, 250] + ]; + + // change color based on Setting + const colorData = JSON.parse(fs.readFileSync(path.join(folderPath, 'color.json'), 'utf8')); + + function findBetterContrast(rgb1, rgb2) { + const contrast1 = contrast.rgb(rgb1, [colorData.red, colorData.green, colorData.blue]) + const contrast2 = contrast.rgb(rgb2, [colorData.red, colorData.green, colorData.blue]) + if (contrast1 > contrast2) { + return `rgb(${rgb1[0]}, ${rgb1[1]}, ${rgb1[2]})`; + } else { + return `rgb(${rgb2[0]}, ${rgb2[1]}, ${rgb2[2]})`; + } + } + + const textColor = findBetterContrast(textColors[0], textColors[1]) + const secondaryColor = findBetterContrast(secondaryColors[0], secondaryColors[1]) + + containerMain.style.color = textColor; + + containerMain.style.background = `linear-gradient(135deg, rgb(${colorData.red}, ${colorData.green}, ${colorData.blue}) 0%, rgb(${colorData.red - 35}, ${colorData.green - 35}, ${colorData.blue - 35}) 100%)`; +}) \ No newline at end of file diff --git a/src/res/ic_oui_movie.svg b/src/res/ic_oui_movie.svg new file mode 100644 index 0000000..e0d006a --- /dev/null +++ b/src/res/ic_oui_movie.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/widgets/videoPlayer/upcomingMovies.html b/src/widgets/videoPlayer/upcomingMovies.html new file mode 100644 index 0000000..d6fae84 --- /dev/null +++ b/src/widgets/videoPlayer/upcomingMovies.html @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + +
+ Upcoming Movies + +
+ + + + Avengers: Endgame + + + + Avengers: Endgame + + + + + Avengers: Endgame + + + + + Avengers: Endgame + + + +
+ + + \ No newline at end of file