mirror of
https://github.com/everoddandeven/monerod-gui.git
synced 2024-12-22 11:39:25 +00:00
Linux fixes
This commit is contained in:
parent
72c7442306
commit
8c9519f604
4 changed files with 44 additions and 2 deletions
32
app/main.ts
32
app/main.ts
|
@ -15,6 +15,21 @@ const pidusage = require('pidusage');
|
|||
const batteryLevel = require('battery-level');
|
||||
const network = require('network');
|
||||
|
||||
function isOnBatteryPower(): Promise<boolean> {
|
||||
return new Promise<boolean>((resolve) => {
|
||||
exec("upower -i $(upower -e | grep 'battery') | grep 'state'", (error, stdout) => {
|
||||
if (error) {
|
||||
console.error(`isOnBatteryPower(): ${error.message}`);
|
||||
resolve(false); // Ritorna false se non riesce a rilevare lo stato della batteria
|
||||
return;
|
||||
}
|
||||
|
||||
const isOnBattery = stdout.includes("discharging");
|
||||
resolve(isOnBattery);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
interface Stats {
|
||||
/**
|
||||
* percentage (from 0 to 100*vcore)
|
||||
|
@ -787,7 +802,22 @@ try {
|
|||
// #endregion
|
||||
|
||||
ipcMain.handle('is-on-battery-power', (event: IpcMainInvokeEvent) => {
|
||||
win?.webContents.send('on-is-on-battery-power', powerMonitor.isOnBatteryPower());
|
||||
const onBattery = powerMonitor.isOnBatteryPower();
|
||||
|
||||
if (!onBattery && os.platform() == 'linux') {
|
||||
isOnBatteryPower().then((value) => {
|
||||
win?.webContents.send('on-is-on-battery-power', value);
|
||||
}).catch((error: any) => {
|
||||
console.error(`${error}`);
|
||||
win?.webContents.send('on-is-on-battery-power', false);
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
else {
|
||||
win?.webContents.send('on-is-on-battery-power', onBattery);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
powerMonitor.on('on-ac', () => win?.webContents.send('on-ac'));
|
||||
|
|
|
@ -10,5 +10,10 @@
|
|||
],
|
||||
"lintianOverrides": [
|
||||
"changelog-file-missing-in-native-package"
|
||||
],
|
||||
"depends": [
|
||||
"net-tools",
|
||||
"upower",
|
||||
"dbus"
|
||||
]
|
||||
}
|
|
@ -10,5 +10,10 @@
|
|||
],
|
||||
"lintianOverrides": [
|
||||
"changelog-file-missing-in-native-package"
|
||||
],
|
||||
"depends": [
|
||||
"net-tools",
|
||||
"upower",
|
||||
"dbus"
|
||||
]
|
||||
}
|
|
@ -71,7 +71,9 @@ export class SettingsComponent {
|
|||
public isAppImage: boolean = true;
|
||||
|
||||
public refreshSyncMode(): void {
|
||||
this.currentSettings.dbSyncMode = this.dbSyncMode;
|
||||
setTimeout(() => {
|
||||
this.currentSettings.dbSyncMode = this.dbSyncMode;
|
||||
}, 100);
|
||||
}
|
||||
|
||||
private initSyncMode(): void {
|
||||
|
|
Loading…
Reference in a new issue