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

Feature request: use Homebrew Services for persist #30

Open
dingwen07 opened this issue Dec 23, 2023 · 1 comment
Open

Feature request: use Homebrew Services for persist #30

dingwen07 opened this issue Dec 23, 2023 · 1 comment
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@dingwen07
Copy link

Homebrew Services is a way to manage background services (using launchctl) for homebrew formulas. Using it to manage persist feature might be a good choice.

@zackelia zackelia added enhancement New feature or request good first issue Good for newcomers labels Jan 21, 2024
@kevinm6
Copy link

kevinm6 commented Feb 19, 2024

@zackelia it should work something like this:

class Bclm < Formula
   desc "macOS command-line utility to limit max battery charge"
   homepage "https://github.com/zackelia/bclm”
   version "0.1.0"
   url "https://github.com/zackelia/bclm/releases/download/v#{version}/bclm.zip"
   sha256 "3f0148e107846e83c7b85282d98ce8611609084920ff0757ab4a017837d54a97"
   license "https://github.com/zackelia/bclm/blob/main/LICENSE"

   depends_on macos: :mavericks
   
   def install
     bin.install "bclm"
   end
  end
 
  service do
    run macos: [opt_bin/“bclm”, “write”, #{value_passed_from_shell}" ]
    keep_alive true
    log_path var/“log/bclm/stdout.log"
    error_log_path var/“log/bclm/stderr.log"
  end
end

The only thing that it’s a little tricky, is that (especially for Intel Macs), this brew formula is copied on install into
{/opt/homebrew, /usr/local}/Library/Taps/zackelia/homebrew-formulae/Formula, so the write value to be passed is already copied into /Library/LaunchDaemons by brew.
Due to this, have a specific value for the battery percentage could be tricky to handle, since with brew it’s not flexible as populating the plist via Swift.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants