From b9b96dcc07f1986fc226eff5a5849ef36e270fa4 Mon Sep 17 00:00:00 2001 From: Santiago Lo Coco Date: Tue, 9 Apr 2024 22:34:19 +0200 Subject: [PATCH] Fix bug --- Makefile | 2 +- cbattery | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index aed0fd4..55ba42c 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,7 @@ $(INSTALL_PATH): cbattery uninstall: @echo "Removing cbattery from $(DESTDIR)" - @su $(USER) -c '$(DESTDIR)/cbattery revert' || (echo "Reverting cbattery configurations failed"; exit 1) + @$(DESTDIR)/cbattery revert || (echo "Reverting cbattery configurations failed"; exit 1) @rm -f $(INSTALL_PATH) help: diff --git a/cbattery b/cbattery index e5dffd6..4b97833 100755 --- a/cbattery +++ b/cbattery @@ -39,14 +39,12 @@ enable_charging() { sudo smc -k CH0B -w 00 sudo smc -k CH0C -w 00 disable_discharging - write_cache "enabled" } disable_charging() { echo "Disabling battery charging" sudo smc -k CH0B -w 02 sudo smc -k CH0C -w 02 - write_cache "disabled" } get_smc_charging_hex() { @@ -106,8 +104,8 @@ runScript() { "charging") echo "Setting $action to $setting" case "$setting" in - "on") enable_charging ;; - "off") disable_charging ;; + "on") enable_charging && write_cache "enabled" ;; + "off") disable_charging && write_cache "disabled" ;; *) echo "Invalid option: $setting" ;; esac ;;