mirror of
https://github.com/cupcakearmy/volta.git
synced 2024-12-22 07:56:27 +00:00
- Fix accuracy battery level (right way now)
- Fix bug multiple desktops
This commit is contained in:
parent
dd3fba2052
commit
24ec6dfd1a
@ -23,10 +23,10 @@ body,
|
|||||||
#app {
|
#app {
|
||||||
color: #3B252C;
|
color: #3B252C;
|
||||||
font-family: 'Source Sans Pro', sans-serif;
|
font-family: 'Source Sans Pro', sans-serif;
|
||||||
height: 100%;
|
|
||||||
width: 100%;
|
width: 100%;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
|
border-radius: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#app.dark {
|
#app.dark {
|
||||||
@ -54,9 +54,7 @@ hr {
|
|||||||
|
|
||||||
#app .link {
|
#app .link {
|
||||||
color: #3F8EFC;
|
color: #3F8EFC;
|
||||||
/* color: inherit; */
|
|
||||||
font-size: 1em;
|
font-size: 1em;
|
||||||
/* font-weight: normal; */
|
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,5 +66,5 @@ ipcRenderer.on('launch', (event, checked) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
ipcRenderer.on('battery', (event, value) => {
|
ipcRenderer.on('battery', (event, value) => {
|
||||||
document.getElementById('currentBattery').innerText = `${value}`
|
document.getElementById('currentBattery').innerText = `${value}%`
|
||||||
})
|
})
|
||||||
|
16
src/main.js
16
src/main.js
@ -11,7 +11,6 @@ const {
|
|||||||
const settings = require('electron-settings')
|
const settings = require('electron-settings')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
const AutoLaunch = require('auto-launch')
|
const AutoLaunch = require('auto-launch')
|
||||||
const batteryLevel = require('battery-level')
|
|
||||||
const exec = require('child_process').exec
|
const exec = require('child_process').exec
|
||||||
|
|
||||||
const al = new AutoLaunch({
|
const al = new AutoLaunch({
|
||||||
@ -95,6 +94,7 @@ const createWindow = () => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
window.loadURL(`file://${path.join(__dirname, 'index.html')}`)
|
window.loadURL(`file://${path.join(__dirname, 'index.html')}`)
|
||||||
|
window.setVisibleOnAllWorkspaces(true)
|
||||||
|
|
||||||
window.on('blur', () => {
|
window.on('blur', () => {
|
||||||
if (!window.webContents.isDevToolsOpened()) window.hide()
|
if (!window.webContents.isDevToolsOpened()) window.hide()
|
||||||
@ -149,7 +149,7 @@ function sendMax() {
|
|||||||
}).show()
|
}).show()
|
||||||
}
|
}
|
||||||
|
|
||||||
let level = 'checking...';
|
let level = '--';
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
exec('pmset -g batt | egrep "([0-9]+\%)" -o', function(err, stdout, stderr) {
|
exec('pmset -g batt | egrep "([0-9]+\%)" -o', function(err, stdout, stderr) {
|
||||||
if (err) {
|
if (err) {
|
||||||
@ -157,7 +157,17 @@ setInterval(() => {
|
|||||||
console.log('Error code: ' + error.code)
|
console.log('Error code: ' + error.code)
|
||||||
console.log('Signal received: ' + error.signal)
|
console.log('Signal received: ' + error.signal)
|
||||||
}
|
}
|
||||||
level = String(stdout)
|
level = parseInt(stdout)
|
||||||
})
|
})
|
||||||
|
if (level > lastBattery) charging = true
|
||||||
|
else charging = false
|
||||||
|
lastBattery = level
|
||||||
|
|
||||||
|
const limits = settings.get('values', defaultValues)
|
||||||
|
|
||||||
|
if (level <= limits.min) sendMin()
|
||||||
|
else if (level >= limits.max) sendMax()
|
||||||
|
else numMax = numMin = 0
|
||||||
|
|
||||||
window.webContents.send('battery', level)
|
window.webContents.send('battery', level)
|
||||||
}, 3000)
|
}, 3000)
|
||||||
|
Loading…
Reference in New Issue
Block a user