Skip to content

Commit

Permalink
autostart fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Vaneeyo committed Oct 23, 2023
1 parent 87533c9 commit c7ccfc5
Show file tree
Hide file tree
Showing 5 changed files with 131 additions and 7 deletions.
21 changes: 14 additions & 7 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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');

Expand All @@ -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 = {
Expand All @@ -77,6 +83,7 @@ const stateData = {
untisWidget: { show: "false" },
digitalClockWidget: { show: "true" },
forecastWidget: { show: "false" },
upcomingMovies: { show: "false" },
};

const weatherData = {
Expand Down Expand Up @@ -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 },
],
};

Expand Down
33 changes: 33 additions & 0 deletions src/css/widgets/videoPlayer/upcomingMovies.css
Original file line number Diff line number Diff line change
@@ -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;
}
40 changes: 40 additions & 0 deletions src/js/videoPlayer/upcomingMovies.js
Original file line number Diff line number Diff line change
@@ -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%)`;
})
1 change: 1 addition & 0 deletions src/res/ic_oui_movie.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 43 additions & 0 deletions src/widgets/videoPlayer/upcomingMovies.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="../../css/fonts.css">
<link rel="stylesheet" href="../../css/colors.css">
<link rel="stylesheet" href="../../css/widgets/videoPlayer/upcomingMovies.css">
<script src="../../js/videoPlayer/upcomingMovies.js"></script>
</head>

<body>
<container id="container-main">
<header>
<strong>Upcoming Movies</strong>
<img src="../../res/ic_oui_movie.svg">
</header>

<container id="container-movies">
<container id="movie-container">
<span>Avengers: Endgame</span>
</container>

<container id="movie-container">
<span>Avengers: Endgame</span>

</container>

<container id="movie-container">
<span>Avengers: Endgame</span>

</container>

<container id="movie-container">
<span>Avengers: Endgame</span>

</container>
</container>
</container>
</body>

</html>

0 comments on commit c7ccfc5

Please sign in to comment.