Skip to content

Commit

Permalink
🐛 fix: #312 and #300 - Updates on start
Browse files Browse the repository at this point in the history
  • Loading branch information
matiasanaya committed Dec 29, 2024
1 parent 89bedc1 commit d333cff
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions app/modules/battery.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,18 +139,19 @@ const initialize_battery = async () => {
exec_async( `${ path_fix } sudo -n /usr/local/bin/smc -k CH0C -r` ).catch( () => false ),
exec_async( `${ path_fix } sudo -n /usr/local/bin/smc -k CH0I -r` ).catch( () => false ),
exec_async( `${ path_fix } sudo -n /usr/local/bin/smc -k ACLC -r` ).catch( () => false ),
exec_async( `${ path_fix } sudo -n /usr/local/bin/smc -k ACLC -w 02` ).catch( () => false )
exec_async( `${ path_fix } sudo -n /usr/local/bin/smc -k ACLC -w 02` ).then( () => true ).catch( () => false )
] )

const visudo_complete = charging_in_visudo && discharging_in_visudo && magsafe_led_in_visudo && additional_magsafe_led_in_visudo
const is_installed = battery_installed && smc_installed
log( 'Is installed? ', is_installed )
log( 'visudo complete? ', visudo_complete )

// Kill running instances of battery
const processes = await exec_async( `ps aux | grep "/usr/local/bin/battery " | wc -l | grep -Eo "\\d*"` )
log( `Found ${ `${ processes }`.replace( /\n/, '' ) } battery related processed to kill` )
if( is_installed ) await exec_async( `${ battery } maintain stop` )
await exec_async( `pkill -f "/usr/local/bin/battery.*"` ).catch( e => log( `Error killing existing battery progesses, usually means no running processes` ) )
await exec_async( `pkill -f "/usr/local/bin/battery.*"` ).catch( e => log( `Error killing existing battery processes, usually means no running processes` ) )

// If installed, update
if( is_installed && visudo_complete ) {
Expand Down
2 changes: 1 addition & 1 deletion app/modules/interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,4 +260,4 @@ async function restart_limiter() {

module.exports = {
set_initial_interface
}
}

0 comments on commit d333cff

Please sign in to comment.