diff --git a/CHANGELOG.md b/CHANGELOG.md index d34e00bda..091d8ff04 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## 0.4.3 - Increment Binaries: - - PatcherSupportPkg 0.3.2 - release + - PatcherSupportPkg 0.3.3 - release - OpenCorePkg 0.7.8 - release - Lilu 1.6.0 - release - WhateverGreen 1.5.7 - release @@ -12,6 +12,8 @@ - Hardware Cursor - Note cursor images will be static (ie. beachball) - Quicklook dismiss/expand + - Keyboard Backlight + - Drops reliance on LabTick - Add Ethernet Controller detection to build - Resolve i210/i225 NIC support on pre-Ivy Macs diff --git a/resources/constants.py b/resources/constants.py index 9e07e5782..5837fb4e3 100644 --- a/resources/constants.py +++ b/resources/constants.py @@ -15,7 +15,7 @@ class Constants: def __init__(self): # Patcher Versioning self.patcher_version = "0.4.3" # OpenCore-Legacy-Patcher - self.patcher_support_pkg_version = "0.3.2" # PatcherSupportPkg + self.patcher_support_pkg_version = "0.3.3" # PatcherSupportPkg self.url_patcher_support_pkg = "https://github.com/dortania/PatcherSupportPkg/releases/download/" self.nightly_url_patcher_support_pkg = "https://nightly.link/dortania/PatcherSupportPkg/workflows/build/master/" self.discord_link = "https://discord.gg/rqdPgH8xSN" @@ -698,10 +698,6 @@ class Constants: def legacy_wifi_support(self): return self.payload_apple_application_support / Path("Legacy-Wifi") - @property - def legacy_keyboard_backlight_support(self): - return self.payload_apple_application_support / Path("Keyboard-Backlight") - @property def legacy_dropbox_support(self): return self.payload_apple_application_support / Path("Dropbox") diff --git a/resources/device_probe.py b/resources/device_probe.py index b6bd64f48..faac6c790 100644 --- a/resources/device_probe.py +++ b/resources/device_probe.py @@ -471,6 +471,7 @@ class Computer: oclp_version: Optional[str] = None opencore_version: Optional[str] = None bluetooth_chipset: Optional[str] = None + ambient_light_sensor: Optional[bool] = False third_party_sata_ssd: Optional[bool] = False @staticmethod @@ -486,6 +487,7 @@ class Computer: computer.smbios_probe() computer.cpu_probe() computer.bluetooth_probe() + computer.ambient_light_sensor_probe() computer.sata_disk_probe() return computer @@ -542,6 +544,12 @@ class Computer: break ioreg.IOObjectRelease(device) + def ambient_light_sensor_probe(self): + device = next(ioreg.ioiterator_to_list(ioreg.IOServiceGetMatchingServices(ioreg.kIOMasterPortDefault, ioreg.IOServiceNameMatching("ALS0".encode()), None)[1]), None) + if device: + self.ambient_light_sensor = True + ioreg.IOObjectRelease(device) + def usb_controller_probe(self): xhci_controllers = ioreg.ioiterator_to_list( ioreg.IOServiceGetMatchingServices( diff --git a/resources/sys_patch.py b/resources/sys_patch.py index ed149148b..b87291e35 100644 --- a/resources/sys_patch.py +++ b/resources/sys_patch.py @@ -229,9 +229,7 @@ class PatchSysVolume: print("- Failed to revert snapshot via bless, falling back on manual restoration") self.manual_root_patch_revert() else: - if (Path(self.mount_application_support) / Path("SkyLightPlugins")).exists(): - print("- Found SkylightPlugins folder, removing") - utilities.process_status(utilities.elevated(["rm", "-rf", f"{self.mount_application_support}/SkyLightPlugins"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)) + self.clean_skylight_plugins() print("- Unpatching complete") print("\nPlease reboot the machine for patches to take effect") else: @@ -309,6 +307,11 @@ class PatchSysVolume: utilities.process_status(utilities.elevated(["chmod", "-Rf", "755", f"{self.mount_extensions}/{add_current_kext}"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)) utilities.process_status(utilities.elevated(["chown", "-Rf", "root:wheel", f"{self.mount_extensions}/{add_current_kext}"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)) + def clean_skylight_plugins(self): + if (Path(self.mount_application_support) / Path("SkyLightPlugins/")).exists(): + print("- Found SkylightPlugins folder, removing") + utilities.process_status(utilities.elevated(["rm", "-rf", f"{self.mount_application_support}/SkyLightPlugins"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)) + def add_brightness_patch(self): self.delete_old_binaries(sys_patch_data.DeleteBrightness) self.add_new_binaries(sys_patch_data.AddBrightness, self.constants.legacy_brightness) @@ -347,8 +350,10 @@ class PatchSysVolume: ) def add_legacy_keyboard_backlight_patch(self): - print("- Merging Keyboard Backlight SkyLightPlugins") - utilities.elevated(["rsync", "-r", "-i", "-a", f"{self.constants.legacy_keyboard_backlight_support}/", self.mount_application_support], stdout=subprocess.PIPE) + print("- Enabling Keyboard Backlight delay") + utilities.process_status( + utilities.elevated(["defaults", "write", "/Library/Preferences/.GlobalPreferences.plist", "NonMetal_BacklightHack", "-bool", "true"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + ) def add_legacy_dropbox_patch(self): print("- Merging DropboxHack SkyLightPlugins") @@ -404,7 +409,6 @@ class PatchSysVolume: self.gpu_accel_legacy() self.add_new_binaries(sys_patch_data.AddAMDAccelLegacy, self.constants.legacy_amd_path) elif self.constants.detected_os in [os_data.os_data.big_sur, os_data.os_data.monterey] and self.constants.allow_ts2_accel is True: - # TODO: Enable for Monterey when acceleration patches proress print("- Installing TeraScale 2 Acceleration Kext patches for Big Sur") self.delete_old_binaries(sys_patch_data.DeleteAMDAccel11) self.delete_old_binaries(sys_patch_data.DeleteAMDAccel11TS2) @@ -514,6 +518,9 @@ class PatchSysVolume: if self.constants.detected_os == os_data.os_data.monterey: self.add_legacy_dropbox_patch() + if self.legacy_keyboard_backlight is True: + self.add_legacy_keyboard_backlight_patch() + print("- Merging general legacy Frameworks") utilities.elevated(["rsync", "-r", "-i", "-a", f"{self.constants.payload_apple_frameworks_path_accel}/", self.mount_frameworks], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) if self.constants.detected_os > os_data.os_data.big_sur: @@ -551,6 +558,10 @@ class PatchSysVolume: def patch_root_vol(self): print(f"- Running patches for {self.model}") + + # Before starting, clean out old plugins + self.clean_skylight_plugins() + # Graphics patches if self.nvidia_legacy is True: print("- Installing legacy Nvidia Patches") @@ -638,10 +649,6 @@ class PatchSysVolume: if self.legacy_gmux is True: print("- Installing Legacy Mux Brightness support") self.add_legacy_mux_patch() - - if self.legacy_keyboard_backlight is True: - print("- Installing Legacy Keyboard Backlight support") - self.add_legacy_keyboard_backlight_patch() if self.validate is False: self.rebuild_snapshot() diff --git a/resources/sys_patch_detect.py b/resources/sys_patch_detect.py index 709dba276..f362dacf7 100644 --- a/resources/sys_patch_detect.py +++ b/resources/sys_patch_detect.py @@ -73,11 +73,13 @@ class detect_root_patch: if self.constants.detected_os > non_metal_os: self.iron_gpu = True self.amfi_must_disable = True + self.legacy_keyboard_backlight = self.check_legacy_keyboard_backlight() elif gpu.arch == device_probe.Intel.Archs.Sandy_Bridge: if self.constants.detected_os > non_metal_os: self.sandy_gpu = True self.amfi_must_disable = True self.check_board_id = True + self.legacy_keyboard_backlight = self.check_legacy_keyboard_backlight() elif gpu.arch == device_probe.Intel.Archs.Ivy_Bridge: if self.constants.detected_os > os_data.os_data.big_sur: self.ivy_gpu = True @@ -90,6 +92,7 @@ class detect_root_patch: self.amd_ts2 = False self.iron_gpu = False self.sandy_gpu = False + self.legacy_keyboard_backlight = False def check_dgpu_status(self): dgpu = self.constants.computer.dgpu @@ -111,14 +114,10 @@ class detect_root_patch: return False def check_legacy_keyboard_backlight(self): - # With Big Sur and newer, Skylight patch set unfortunately breaks native keyboard backlight - # Penryn Macs are able to re-enable the keyboard backlight by simply running '/usr/libexec/TouchBarServer' - # For Arrendale and newer, this has no effect. - if self.model.startswith("MacBookPro") or self.model.startswith("MacBookAir"): - # non-Metal MacBooks never had keyboard backlight - if smbios_data.smbios_dictionary[self.model]["CPU Generation"] <= cpu_data.cpu_data.penryn.value: - if self.constants.detected_os > os_data.os_data.catalina: - return True + # iMac12,x+ have an 'ACPI0008' device, but it's not a keyboard backlight + # Best to assume laptops will have a keyboard backlight + if self.model.startswith("MacBook"): + return self.constants.computer.ambient_light_sensor return False def detect_patch_set(self):