Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ADD: Idle timer #2102

Merged
merged 6 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
146 changes: 146 additions & 0 deletions launcher/public/output.css
Original file line number Diff line number Diff line change
Expand Up @@ -887,6 +887,10 @@ video {
left: 40%;
}

.left-\[50\%\]{
left: 50%;
}

.left-\[920px\]{
left: 920px;
}
Expand Down Expand Up @@ -983,6 +987,10 @@ video {
top: 1px;
}

.top-\[25\%\]{
top: 25%;
}

.top-\[33\%\]{
top: 33%;
}
Expand All @@ -991,6 +999,10 @@ video {
top: 42%;
}

.top-\[50\%\]{
top: 50%;
}

.top-\[56px\]{
top: 56px;
}
Expand Down Expand Up @@ -1035,6 +1047,10 @@ video {
grid-column: span 10 / span 10;
}

.col-span-12{
grid-column: span 12 / span 12;
}

.col-span-2{
grid-column: span 2 / span 2;
}
Expand Down Expand Up @@ -1616,6 +1632,14 @@ video {
height: 33.333333%;
}

.h-1\/4{
height: 25%;
}

.h-1\/5{
height: 20%;
}

.h-1\/6{
height: 16.666667%;
}
Expand Down Expand Up @@ -1844,6 +1868,10 @@ video {
height: 80px;
}

.h-\[90\%\]{
height: 90%;
}

.h-\[90px\]{
height: 90px;
}
Expand Down Expand Up @@ -2086,6 +2114,10 @@ video {
width: 25%;
}

.w-1\/5{
width: 20%;
}

.w-1\/6{
width: 16.666667%;
}
Expand All @@ -2098,6 +2130,10 @@ video {
width: 83.333333%;
}

.w-11{
width: 2.75rem;
}

.w-11\/12{
width: 91.666667%;
}
Expand Down Expand Up @@ -2126,6 +2162,14 @@ video {
width: 50%;
}

.w-2\/5{
width: 40%;
}

.w-2\/6{
width: 33.333333%;
}

.w-20{
width: 5rem;
}
Expand Down Expand Up @@ -2218,6 +2262,10 @@ video {
width: 2rem;
}

.w-8\/12{
width: 66.666667%;
}

.w-9{
width: 2.25rem;
}
Expand All @@ -2226,6 +2274,10 @@ video {
width: 75%;
}

.w-\[10\%\]{
width: 10%;
}

.w-\[100px\]{
width: 100px;
}
Expand Down Expand Up @@ -2278,6 +2330,10 @@ video {
width: 200px;
}

.w-\[24\%\]{
width: 24%;
}

.w-\[27px\]{
width: 27px;
}
Expand Down Expand Up @@ -2346,6 +2402,10 @@ video {
width: 8rem;
}

.w-\[90\%\]{
width: 90%;
}

.w-fit{
width: -webkit-fit-content;
width: -moz-fit-content;
Expand Down Expand Up @@ -2473,6 +2533,18 @@ video {
transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
}

.rotate-90{
--tw-rotate: 90deg;
-webkit-transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
}

.rotate-\[270deg\]{
--tw-rotate: 270deg;
-webkit-transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
}

.scale-100{
--tw-scale-x: 1;
--tw-scale-y: 1;
Expand Down Expand Up @@ -2866,6 +2938,12 @@ video {
margin-left: calc(0.5rem * calc(1 - var(--tw-space-x-reverse)));
}

.space-x-3 > :not([hidden]) ~ :not([hidden]){
--tw-space-x-reverse: 0;
margin-right: calc(0.75rem * var(--tw-space-x-reverse));
margin-left: calc(0.75rem * calc(1 - var(--tw-space-x-reverse)));
}

.space-x-4 > :not([hidden]) ~ :not([hidden]){
--tw-space-x-reverse: 0;
margin-right: calc(1rem * var(--tw-space-x-reverse));
Expand Down Expand Up @@ -4244,6 +4322,14 @@ video {
padding: 2rem;
}

.p-\[\.10rem\]{
padding: .10rem;
}

.p-\[0\.10rem\]{
padding: 0.10rem;
}

.p-\[1px\]{
padding: 1px;
}
Expand Down Expand Up @@ -4422,6 +4508,10 @@ video {
padding-top: 2rem;
}

.pr-3{
padding-right: 0.75rem;
}

.text-left{
text-align: left;
}
Expand Down Expand Up @@ -4460,6 +4550,10 @@ video {
line-height: 2.25rem;
}

.text-\[100\%\]{
font-size: 100%;
}

.text-\[10px\]{
font-size: 10px;
}
Expand Down Expand Up @@ -4492,10 +4586,42 @@ video {
font-size: 26px;
}

.text-\[30\%\]{
font-size: 30%;
}

.text-\[40\%\]{
font-size: 40%;
}

.text-\[45\%\]{
font-size: 45%;
}

.text-\[50\%\]{
font-size: 50%;
}

.text-\[55\%\]{
font-size: 55%;
}

.text-\[60\%\]{
font-size: 60%;
}

.text-\[7px\]{
font-size: 7px;
}

.text-\[8px\]{
font-size: 8px;
}

.text-\[90\%\]{
font-size: 90%;
}

.text-\[9px\]{
font-size: 9px;
}
Expand Down Expand Up @@ -4558,6 +4684,10 @@ video {
font-weight: 600;
}

.font-thin{
font-weight: 100;
}

.uppercase{
text-transform: uppercase;
}
Expand Down Expand Up @@ -4654,6 +4784,11 @@ video {
color: rgb(0 0 0 / var(--tw-text-opacity));
}

.text-blue-300{
--tw-text-opacity: 1;
color: rgb(147 197 253 / var(--tw-text-opacity));
}

.text-blue-400{
--tw-text-opacity: 1;
color: rgb(96 165 250 / var(--tw-text-opacity));
Expand Down Expand Up @@ -4744,6 +4879,11 @@ video {
color: rgb(249 115 22 / var(--tw-text-opacity));
}

.text-orange-600{
--tw-text-opacity: 1;
color: rgb(234 88 12 / var(--tw-text-opacity));
}

.text-red-400{
--tw-text-opacity: 1;
color: rgb(248 113 113 / var(--tw-text-opacity));
Expand Down Expand Up @@ -5092,6 +5232,12 @@ video {
filter: var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow);
}

.sepia{
--tw-sepia: sepia(100%);
-webkit-filter: var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow);
filter: var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow);
}

.filter{
-webkit-filter: var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow);
filter: var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow);
Expand Down
30 changes: 30 additions & 0 deletions launcher/src/backend/Monitoring.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,17 @@ import * as crypto from "crypto";
import * as fs from "fs";
import * as os from "os";
import * as path from "path";
const { powerMonitor } = require("electron");

const globalMonitoringCache = {
intervalHandler: null,
isRefreshing: 0,
refreshIntervalSeconds: 5,
nodestatsInitialized: false,
storagestatus: {},
setTime: 300,
idleTimerRunning: false,
idleTimerStop: false,
};

export class Monitoring {
Expand All @@ -39,6 +43,8 @@ export class Monitoring {
async cleanup() {
this.isLoggedIn = false;
this.triedCurlInstall = false;
this.idleTimerRunning = false;
this.idleTimerStop = false;
this.rpcTunnel = {};
this.wsTunnel = {};
this.beaconTunnel = {};
Expand Down Expand Up @@ -3516,4 +3522,28 @@ rm -rf diskoutput
}
return [];
}

async setIdleTime(setTime) {
this.globalMonitoringCache.setTime = setTime;
}

async idleTimerCheck(timerStop, win) {
if (!this.globalMonitoringCache.idleTimerRunning) {
this.globalMonitoringCache.idleTimerRunning = true;
await this.idleTimerLoop(win);
}
this.globalMonitoringCache.idleTimerStop = timerStop;
}

async idleTimerLoop(win) {
if (powerMonitor.getSystemIdleTime() >= this.globalMonitoringCache.setTime * 60) {
win.send("IdleLogout");
} else if (this.isLoggedIn && !this.globalMonitoringCache.idleTimerStop) {
await new Promise((resolve) => setTimeout(resolve, 60000));
await this.idleTimerLoop(win);
} else {
this.globalMonitoringCache.idleTimerStop = false;
this.globalMonitoringCache.idleTimerRunning = false;
}
}
}
9 changes: 9 additions & 0 deletions launcher/src/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,15 @@ ipcMain.handle("logout", async () => {
return await nodeConnection.logout();
});

ipcMain.handle("idleTimerCheck", async (event, args) => {
const current_window = event.sender;
return await monitoring.idleTimerCheck(args.timerStop, current_window);
});

ipcMain.handle("setIdleTime", async (event, arg) => {
return await monitoring.setIdleTime(arg);
});

// userData storage
ipcMain.handle("readConfig", async () => {
return storageService.readConfig();
Expand Down
Loading