Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 fix: #312 and #300 - Updates on start #323

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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