Skip to content

Commit 97e379f

Browse files
committed
feat: RDP monitoring toggle & config improvements
This commit addresses the performance issues caused by RDP monitoring on some systems by adding a toggle to disable it, and setting the default to false. The config class has also been improved by giving it the ability to fill and write missing keys (useful when updating the config with new keys)
1 parent 4627a84 commit 97e379f

File tree

4 files changed

+56
-3
lines changed

4 files changed

+56
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "winboat",
3-
"version": "0.6.6",
3+
"version": "0.6.7",
44
"description": "Windows for Penguins",
55
"main": "main/main.js",
66
"scripts": {

src/renderer/lib/config.ts

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ import { WINBOAT_DIR } from "./constants";
55
export type WinboatConfigObj = {
66
scale: number;
77
smartcardEnabled: boolean
8+
rdpMonitoringEnabled: boolean
89
};
910

1011
const defaultConfig: WinboatConfigObj = {
1112
scale: 100,
12-
smartcardEnabled: false
13+
smartcardEnabled: false,
14+
rdpMonitoringEnabled: false,
1315
};
1416

1517
let instance: WinboatConfig | null = null;
@@ -57,8 +59,28 @@ export class WinboatConfig {
5759

5860
try {
5961
const rawConfig = fs.readFileSync(this.#configPath, "utf-8");
62+
const configObj = JSON.parse(rawConfig) as WinboatConfigObj;
6063
console.log("Successfully read the config file");
61-
return { ...JSON.parse(rawConfig) as WinboatConfigObj };
64+
65+
// Some fields might be missing after an update, so we merge them with the default config
66+
for (const key in defaultConfig) {
67+
let hasMissing = false;
68+
if (!(key in configObj)) {
69+
// @ts-expect-error This is valid
70+
configObj[key] = defaultConfig[key];
71+
hasMissing = true;
72+
console.log(`Added missing config key: ${key} with default value: ${defaultConfig[key as keyof WinboatConfigObj]}`);
73+
}
74+
75+
// If we have any missing keys, we should just write the config back to disk so those new keys are saved
76+
// We cannot use this.writeConfig() here since #configData is not populated yet
77+
if (hasMissing) {
78+
fs.writeFileSync(this.#configPath, JSON.stringify(configObj, null, 4), "utf-8");
79+
console.log("Wrote updated config with missing keys to disk");
80+
}
81+
}
82+
83+
return { ...configObj };
6284
} catch (e) {
6385
console.error("Config’s borked, outputting the default:", e);
6486
return { ...defaultConfig };

src/renderer/lib/winboat.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,18 @@ export class Winboat {
215215
clearInterval(this.#rdpConnectionStatusInterval);
216216
this.#rdpConnectionStatusInterval = null;
217217
}
218+
218219
this.#rdpConnectionStatusInterval = setInterval(async () => {
220+
// If the guest is offline, don't even bother checking RDP status
219221
if (!this.isOnline.value) return;
222+
223+
// If RDP monitoring is disabled, don't check status, just set it to false
224+
if (!this.#wbConfig?.config.rdpMonitoringEnabled) {
225+
this.rdpConnected.value = false;
226+
return;
227+
}
228+
229+
// Check RDP status
220230
const _rdpConnected = await this.getRDPConnectedStatus();
221231
if (_rdpConnected !== this.rdpConnected.value) {
222232
this.rdpConnected.value = _rdpConnected;

src/renderer/views/Config.vue

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,27 @@
123123
></x-switch>
124124
</div>
125125
</x-card>
126+
<x-card
127+
class="flex items-center p-2 flex-row justify-between w-full py-3 my-0 bg-neutral-800/20 backdrop-brightness-150 backdrop-blur-xl">
128+
<div>
129+
<div class="flex flex-row items-center gap-2 mb-2">
130+
<Icon class="text-violet-400 inline-flex size-8" icon="fluent:remote-16-filled"></Icon>
131+
<h1 class="text-lg my-0 font-semibold">
132+
RDP Monitoring
133+
</h1>
134+
</div>
135+
<p class="text-neutral-400 text-[0.9rem] !pt-0 !mt-0">
136+
If enabled, a banner will appear when the RDP session is connected (may cause high CPU usage, disable if you notice performance issues)
137+
</p>
138+
</div>
139+
<div class="flex flex-row justify-center items-center gap-2">
140+
<x-switch
141+
:toggled="wbConfig.config.rdpMonitoringEnabled"
142+
@toggle="(_: any) => wbConfig.config.rdpMonitoringEnabled = !wbConfig.config.rdpMonitoringEnabled"
143+
size="large"
144+
></x-switch>
145+
</div>
146+
</x-card>
126147
</div>
127148
</div>
128149
<div>

0 commit comments

Comments
 (0)