From 81377d36573fe3cf13329377eed2f3dfce0c4057 Mon Sep 17 00:00:00 2001 From: smartfrigde <37928912+smartfrigde@users.noreply.github.com> Date: Fri, 10 Jun 2022 20:24:13 +0200 Subject: [PATCH 1/3] Add performance mode --- src/content/setup.html | 3 +++ src/main.ts | 5 +++-- src/settings/settings.html | 11 +++++++++- src/utils.ts | 41 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 57 insertions(+), 3 deletions(-) diff --git a/src/content/setup.html b/src/content/setup.html index 6ed4c94..4b9d4bd 100644 --- a/src/content/setup.html +++ b/src/content/setup.html @@ -101,6 +101,7 @@ automaticPatches: false, mods: "cumcord", inviteWebsocket: true, + performanceMode: "none", blurType: "acrylic" }); setTimeout(() => window.armcordinternal.restart(), 5000); @@ -130,6 +131,7 @@ autoLaunch: true, minimizeToTray: true, automaticPatches: false, + performanceMode: "none", mods: options.mod, inviteWebsocket: true, blurType: "acrylic" @@ -145,6 +147,7 @@ automaticPatches: false, autoLaunch: true, mods: "none", + performanceMode: "none", inviteWebsocket: true, blurType: "acrylic" }); diff --git a/src/main.ts b/src/main.ts index ec61b77..8d1abb9 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,7 +1,7 @@ // Modules to control application life and create native browser window import {app, BrowserWindow, session, dialog} from "electron"; import "v8-compile-cache"; -import {getConfig, setup, checkIfConfigExists} from "./utils"; +import {getConfig, setup, checkIfConfigExists, injectElectronFlags} from "./utils"; import "./extensions/mods"; import "./extensions/plugin"; import "./tray"; @@ -12,6 +12,7 @@ export var settings: any; export var customTitlebar: boolean; export var tabs: boolean; + if (process.platform == "linux") { if (process.env.$XDG_SESSION_TYPE == "wayland") { console.log("Wayland specific patches applied."); @@ -24,7 +25,7 @@ if (process.platform == "linux") { } } checkIfConfigExists(); - +injectElectronFlags(); app.whenReady().then(async () => { switch (await getConfig("windowStyle")) { case "default": diff --git a/src/settings/settings.html b/src/settings/settings.html index 7d723c5..c57151c 100644 --- a/src/settings/settings.html +++ b/src/settings/settings.html @@ -58,7 +58,14 @@

Client mod:

- +
+ +

Performance mode:

+
@@ -71,6 +78,7 @@ document.getElementById("mod").value = await settings.get("mods"); document.getElementById("channel").value = await settings.get("channel"); document.getElementById("theme").value = await settings.get("windowStyle"); + document.getElementById("performanceMode").value = await settings.get("performanceMode"); } loadSettings(); document.getElementById("save").addEventListener("click", function () { @@ -84,6 +92,7 @@ mods: document.getElementById("mod").value, blurType: "acrylic", inviteWebsocket: document.getElementById("websocket").checked, + performanceMode: document.getElementById("prfmMode").value, doneSetup: true }); }); diff --git a/src/utils.ts b/src/utils.ts index e331a96..2a42ff8 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,6 +1,7 @@ import * as fs from "fs"; import {app, dialog} from "electron"; import path from "path"; +import { defaultMaxListeners } from "events"; export var firstRun: boolean; export var isSetup: boolean; export var contentPath: string; @@ -42,6 +43,7 @@ export function setup() { automaticPatches: false, mods: "cumcord", blurType: "acrylic", + performanceMode: "none", inviteWebsocket: true, doneSetup: false }; @@ -63,7 +65,45 @@ export async function injectJS(inject: string) { document.body.appendChild(el); } +export async function injectElectronFlags() { + // MIT License + // Copyright (c) 2022 GooseNest + + // Permission is hereby granted, free of charge, to any person obtaining a copy + // of this software and associated documentation files (the "Software"), to deal + // in the Software without restriction, including without limitation the rights + // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + // copies of the Software, and to permit persons to whom the Software is + // furnished to do so, subject to the following conditions: + + // The above copyright notice and this permission notice shall be included in all + // copies or substantial portions of the Software. + + // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + // SOFTWARE. + const presets = { + 'performance': `--enable-gpu-rasterization --enable-zero-copy --ignore-gpu-blocklist --enable-hardware-overlays=single-fullscreen,single-on-top,underlay --enable-features=EnableDrDc,CanvasOopRasterization,BackForwardCache:TimeToLiveInBackForwardCacheInSeconds/300/should_ignore_blocklists/true/enable_same_site/true,ThrottleDisplayNoneAndVisibilityHiddenCrossOriginIframes,UseSkiaRenderer,WebAssemblyLazyCompilation --disable-features=Vulkan --force_high_performance_gpu`, // Performance + 'battery': '--enable-features=TurnOffStreamingMediaCachingOnBattery --force_low_power_gpu' // Known to have better battery life for Chromium? + }; + switch (await getConfig("performanceMode")) { + case "performance": + console.log("Performance mode enabled"); + app.commandLine.appendSwitch(presets.performance); + break; + case "battery": + console.log("Battery mode enabled"); + app.commandLine.appendSwitch(presets.battery); + break; + default: + console.log("No performance modes set"); + } +} //ArmCord Settings/Storage manager export interface Settings { @@ -73,6 +113,7 @@ export interface Settings { minimizeToTray: boolean; automaticPatches: boolean; mods: string; + performanceMode: string, blurType: string; inviteWebsocket: boolean; doneSetup: boolean; From 98f88f4609ade9757a72262d3cd126848caa79da Mon Sep 17 00:00:00 2001 From: smartfrigde <37928912+smartfrigde@users.noreply.github.com> Date: Fri, 10 Jun 2022 20:46:30 +0200 Subject: [PATCH 2/3] Fix icon loading --- package.json | 2 +- src/window.ts | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 17c7f28..6686ce4 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "@types/node": "^17.0.33", "@types/ws": "^8.5.3", "copyfiles": "^2.4.1", - "electron": "^18.2.4", + "electron": "^19.0.4", "electron-builder": "^23.0.3", "husky": "^8.0.1", "prettier": "^2.5.1", diff --git a/src/window.ts b/src/window.ts index 7445fe7..9b6acf2 100644 --- a/src/window.ts +++ b/src/window.ts @@ -119,7 +119,7 @@ export function createCustomWindow() { height: 350, title: "ArmCord", darkTheme: true, - icon: path.join(__dirname, "/assets/icon_transparent.png"), + icon: path.join(__dirname, "../", "/assets/ac_icon_transparent.png"), frame: false, autoHideMenuBar: true, webPreferences: { @@ -135,7 +135,7 @@ export function createNativeWindow() { height: 350, title: "ArmCord", darkTheme: true, - icon: path.join(__dirname, "/assets/icon_transparent.png"), + icon: path.join(__dirname, "../", "/assets/ac_icon_transparent.png"), frame: true, autoHideMenuBar: true, webPreferences: { @@ -157,7 +157,7 @@ export function createTabsHost() { height: 350, title: "ArmCord", darkTheme: true, - icon: path.join(__dirname, "/assets/icon_transparent.png"), + icon: path.join(__dirname, "../", "/assets/ac_icon_transparent.png"), frame: true, autoHideMenuBar: true, webPreferences: { @@ -186,7 +186,7 @@ export function createTabsGuest(number: number) { height: 600, title: "ArmCord Guest Window " + number, darkTheme: true, - icon: path.join(__dirname, "/assets/icon_transparent.png"), + icon: path.join(__dirname, "../", "/assets/ac_icon_transparent.png"), frame: true, autoHideMenuBar: true, webPreferences: { @@ -223,7 +223,7 @@ export function createInviteWindow() { height: 600, title: "ArmCord Invite Manager", darkTheme: true, - icon: path.join(__dirname, "/assets/icon_transparent.png"), + icon: path.join(__dirname, "../", "/assets/ac_icon_transparent.png"), frame: true, autoHideMenuBar: true, webPreferences: { From 090606de6567746959baf875bf7cf16c3db3227d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 10 Jun 2022 18:48:19 +0000 Subject: [PATCH 3/3] Update ws requirement from ^8.6.0 to ^8.8.0 Updates the requirements on [ws](https://github.com/websockets/ws) to permit the latest version. - [Release notes](https://github.com/websockets/ws/releases) - [Commits](https://github.com/websockets/ws/compare/8.6.0...8.8.0) --- updated-dependencies: - dependency-name: ws dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6686ce4..6150824 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "dependencies": { "electron-context-menu": "github:ArmCord/electron-context-menu", "v8-compile-cache": "^2.3.0", - "ws": "^8.6.0" + "ws": "^8.8.0" }, "build": { "appId": "com.smartfridge.armcord",