Skip to content

Commit

Permalink
chore: improve error message if batt is already uninstalled
Browse files Browse the repository at this point in the history
Signed-off-by: Charlie Chiang <[email protected]>
  • Loading branch information
charlie0129 committed Sep 27, 2023
1 parent 5134fa3 commit ac86188
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ func NewStatusCommand() *cobra.Command {
cmd.Printf(" State: %s\n", bold(state))
cmd.Printf(" Full capacity: %s\n", bold("%.1f Wh", bat.Design/1e3))
cmd.Printf(" Charge rate: %s\n", bold("%.1f W", bat.ChargeRate/1e3))
cmd.Printf(" voltage: %s\n", bold("%.2f V", bat.DesignVoltage))
cmd.Printf(" Voltage: %s\n", bold("%.2f V", bat.DesignVoltage))

cmd.Println()

Expand Down
6 changes: 2 additions & 4 deletions install.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@ func installDaemon() error {
}

func uninstallDaemon() error {
// TODO: revert any changes, enable battery charging and enable adapter before uninstalling

logrus.Infof("stopping batt")

// run launchctl unload /Library/LaunchDaemons/cc.chlc.batt.plist
Expand All @@ -89,14 +87,14 @@ func uninstallDaemon() error {
"/Library/LaunchDaemons/cc.chlc.batt.plist",
).Run()
if err != nil {
return fmt.Errorf("failed to unload /Library/LaunchDaemons/cc.chlc.batt.plist: %w", err)
return fmt.Errorf("failed to unload /Library/LaunchDaemons/cc.chlc.batt.plist: %w. Are you root?", err)
}

logrus.Infof("removing launch daemon")

err = os.Remove("/Library/LaunchDaemons/cc.chlc.batt.plist")
if err != nil {
return fmt.Errorf("failed to remove /Library/LaunchDaemons/cc.chlc.batt.plist: %w", err)
return fmt.Errorf("failed to remove /Library/LaunchDaemons/cc.chlc.batt.plist: %w. Do you have enough permissions? Is batt already uninstalled?", err)
}

return nil
Expand Down

0 comments on commit ac86188

Please sign in to comment.