Improved accessibility access conditional style

This commit is contained in:
Alex 2016-09-21 08:33:10 -07:00 committed by GitHub
parent 169a079903
commit d282565bd0

View File

@ -225,12 +225,7 @@ class Hbc::Installer
def enable_accessibility_access def enable_accessibility_access
return unless @cask.accessibility_access return unless @cask.accessibility_access
ohai "Enabling accessibility access" ohai "Enabling accessibility access"
if MacOS.version >= :sierra if MacOS.version <= :mountain_lion
opoo <<-EOS.undent
Accessibility access cannot be enabled automatically on this version of macOS.
See System Preferences to enable it manually.
EOS
elsif MacOS.version <= :mountain_lion
@command.run!("/usr/bin/touch", @command.run!("/usr/bin/touch",
args: [Hbc.pre_mavericks_accessibility_dotfile], args: [Hbc.pre_mavericks_accessibility_dotfile],
sudo: true) sudo: true)
@ -241,24 +236,29 @@ class Hbc::Installer
"INSERT OR REPLACE INTO access VALUES('kTCCServiceAccessibility','#{bundle_identifier}',0,1,1,NULL);", "INSERT OR REPLACE INTO access VALUES('kTCCServiceAccessibility','#{bundle_identifier}',0,1,1,NULL);",
], ],
sudo: true) sudo: true)
else elsif MacOS.version <= :el_capitan
@command.run!("/usr/bin/sqlite3", @command.run!("/usr/bin/sqlite3",
args: [ args: [
Hbc.tcc_db, Hbc.tcc_db,
"INSERT OR REPLACE INTO access VALUES('kTCCServiceAccessibility','#{bundle_identifier}',0,1,1,NULL,NULL);", "INSERT OR REPLACE INTO access VALUES('kTCCServiceAccessibility','#{bundle_identifier}',0,1,1,NULL,NULL);",
], ],
sudo: true) sudo: true)
else
opoo <<-EOS.undent
Accessibility access cannot be enabled automatically on this version of macOS.
See System Preferences to enable it manually.
EOS
end end
end end
def disable_accessibility_access def disable_accessibility_access
return unless @cask.accessibility_access return unless @cask.accessibility_access
if MacOS.version >= :sierra if MacOS.version <= :mountain_lion
opoo <<-EOS.undent opoo <<-EOS.undent
Accessibility access cannot be disabled automatically on this version of macOS. Accessibility access was enabled for #{@cask}, but it is not safe to disable
See System Preferences to disable it manually. automatically on this version of macOS. See System Preferences.
EOS EOS
elsif MacOS.version >= :mavericks elsif MacOS.version <= :el_capitan
ohai "Disabling accessibility access" ohai "Disabling accessibility access"
@command.run!("/usr/bin/sqlite3", @command.run!("/usr/bin/sqlite3",
args: [ args: [
@ -268,8 +268,8 @@ class Hbc::Installer
sudo: true) sudo: true)
else else
opoo <<-EOS.undent opoo <<-EOS.undent
Accessibility access was enabled for #{@cask}, but it is not safe to disable Accessibility access cannot be disabled automatically on this version of macOS.
automatically on this version of macOS. See System Preferences. See System Preferences to disable it manually.
EOS EOS
end end
end end