diff --git a/xbar/brew-services.10m.rb b/xbar/brew-services.10m.rb
index d8c1230..3d4b819 100755
--- a/xbar/brew-services.10m.rb
+++ b/xbar/brew-services.10m.rb
@@ -2,7 +2,7 @@
# frozen_string_literal: true
# Brew Services
-# v3.0.1
+# v3.0.2
# Jim Myhrberg
# jimeh
# List and manage Homebrew Services
@@ -11,7 +11,7 @@
# https://github.com/jimeh/dotfiles/tree/main/xbar
#
# boolean(VAR_GROUPS=true): List services in started/stopped groups?
-# string(VAR_BREW_PATH="/usr/local/bin/brew"): Path to "brew" executable.
+# string(VAR_BREW_PATH=""): Path to "brew" executable.
# string(VAR_HIDDEN_SERVICES=""): Comma-separated list of services to hide.
# rubocop:disable Lint/ShadowingOuterLocalVariable
@@ -172,7 +172,31 @@ module Brew
end
def brew_path
- @brew_path ||= ENV.fetch('VAR_BREW_PATH', '/usr/local/bin/brew')
+ @brew_path ||= brew_path_from_env ||
+ brew_path_from_which ||
+ brew_path_from_fs_check ||
+ raise('Unable to find "brew" executable')
+ end
+
+ def brew_path_from_env
+ return if ENV['VAR_BREW_PATH'].to_s == ''
+
+ ENV['VAR_BREW_PATH']
+ end
+
+ def brew_path_from_which
+ detect = cmd('which', 'brew').strip
+ return if detect == ''
+
+ detect
+ end
+
+ def brew_path_from_fs_check
+ ['/usr/local/bin/brew', '/opt/homebrew/bin/brew'].each do |path|
+ return path if File.exist?(path)
+ end
+
+ nil
end
def brew_check(printer = nil)
diff --git a/xbar/brew-updates.1h.rb b/xbar/brew-updates.1h.rb
index ab3cbe5..8c33adc 100755
--- a/xbar/brew-updates.1h.rb
+++ b/xbar/brew-updates.1h.rb
@@ -2,7 +2,7 @@
# frozen_string_literal: true
# Brew Updates
-# v2.3.2
+# v2.3.3
# Jim Myhrberg
# jimeh
# List and manage outdated Homebrew formulas and casks
@@ -10,7 +10,7 @@
# ruby
# https://github.com/jimeh/dotfiles/tree/main/xbar
#
-# string(VAR_BREW_PATH="/usr/local/bin/brew"): Path to "brew" executable.
+# string(VAR_BREW_PATH=""): Path to "brew" executable.
# rubocop:disable Lint/ShadowingOuterLocalVariable
# rubocop:disable Metrics/AbcSize
@@ -170,7 +170,31 @@ module Brew
end
def brew_path
- @brew_path ||= ENV.fetch('VAR_BREW_PATH', '/usr/local/bin/brew')
+ @brew_path ||= brew_path_from_env ||
+ brew_path_from_which ||
+ brew_path_from_fs_check ||
+ raise('Unable to find "brew" executable')
+ end
+
+ def brew_path_from_env
+ return if ENV['VAR_BREW_PATH'].to_s == ''
+
+ ENV['VAR_BREW_PATH']
+ end
+
+ def brew_path_from_which
+ detect = cmd('which', 'brew').strip
+ return if detect == ''
+
+ detect
+ end
+
+ def brew_path_from_fs_check
+ ['/usr/local/bin/brew', '/opt/homebrew/bin/brew'].each do |path|
+ return path if File.exist?(path)
+ end
+
+ nil
end
def brew_check(printer = nil)