Skip to content

Instantly share code, notes, and snippets.

@khronokernel
Last active November 10, 2025 06:35
Show Gist options
  • Select an option

  • Save khronokernel/122dc28114d3a3b1673fa0423b5a9b39 to your computer and use it in GitHub Desktop.

Select an option

Save khronokernel/122dc28114d3a3b1673fa0423b5a9b39 to your computer and use it in GitHub Desktop.
Electron and Chrome patcher to force OpenGL rendering
"""
electron_patcher.py: Enforce 'use-angle@1' in Chrome and Electron applications
Version 1.0.0 (2024-08-11)
"""
import enum
import json
from pathlib import Path
class ChromiumSettingsPatcher:
class AngleVariant(enum.Enum):
Default = "0"
OpenGL = "1"
Metal = "2"
def __init__(self, state_file: str) -> None:
self._local_state_file = Path(state_file).expanduser()
def patch(self) -> None:
"""
Ensure 'use-angle@1' is set in Chrome's experimental settings
"""
_desired_key = "use-angle"
_desired_value = self.AngleVariant.OpenGL.value
if not self._local_state_file.exists():
print(" Local State missing, creating...")
self._local_state_file.parent.mkdir(parents=True, exist_ok=True)
state_data = {}
else:
print(" Parsing Local State file")
state_data = json.loads(self._local_state_file.read_bytes())
if "browser" not in state_data:
state_data["browser"] = {}
if "enabled_labs_experiments" not in state_data["browser"]:
state_data["browser"]["enabled_labs_experiments"] = []
for key in state_data["browser"]["enabled_labs_experiments"]:
if "@" not in key:
continue
key_pair = key.split("@")
if len(key_pair) < 2:
continue
if key_pair[0] != _desired_key:
continue
if key_pair[1] == _desired_value:
print(f" {_desired_key}@{_desired_value} is already set")
break
index = state_data["browser"]["enabled_labs_experiments"].index(key)
state_data["browser"]["enabled_labs_experiments"][index] = f"{_desired_key}@{_desired_value}"
print(f" Updated {_desired_key}@{_desired_value}")
if f"{_desired_key}@{_desired_value}" not in state_data["browser"]["enabled_labs_experiments"]:
state_data["browser"]["enabled_labs_experiments"].append(f"{_desired_key}@{_desired_value}")
print(f" Added {_desired_key}@{_desired_value}")
print(" Writing to Local State file")
self._local_state_file.write_text(json.dumps(state_data, indent=4))
def main():
# Patch all Electron applications
for directory in Path("~/Library/Application Support").expanduser().iterdir():
if not directory.is_dir():
continue
state_file = directory / "Local State"
if not state_file.exists():
continue
print(f"Patching {directory.name}")
patcher = ChromiumSettingsPatcher(state_file)
patcher.patch()
# Patch all Chrome variants
if Path("~/Library/Application Support/Google").expanduser().exists():
for directory in Path("~/Library/Application Support/Google").expanduser().iterdir():
if not directory.is_dir():
continue
state_file = directory / "Local State"
if not state_file.exists():
continue
print(f"Patching {directory.name}")
patcher = ChromiumSettingsPatcher(state_file)
patcher.patch()
if __name__ == "__main__":
main()
@fablarosa
Copy link

FYI today I installed the 15.4.1 Sequoia update on my MacPro 6,1 and after rebooting OCLP notified me that I had to reinstall some patches:
OCLP_notification_15 4 1_update
Since I had read the @edilAraujo comments about Docker Desktop I tried to start 1Password before re-applying the patches ... and it works! I was therefore able to modify some of its settings to prevent the password request to come up every day with its red-window-of-death.
@khronokernel sorry to bother again, but is there any chance that issue #1145 is going to be fixed in a future release of OCLP?

@fablarosa
Copy link

fablarosa commented Apr 28, 2025

Ok I've found a workaround for 1Password, just disable "Use Hardware Acceleration" in Settings > Advanced before installing the root patches:
1Password_NoHwAccel

If you have already installed the OCLP root patches, the same result can be achieved adding this line
"app.useHardwareAcceleration": false,
to the 1Password settings file:
~/Library/Group\ Containers/2BUA8C4S2C.com.1password/Library/Application\ Support/1Password/Data/settings/settings.json
but before doing so you have to be sure that the 1Password app is not running and its menu item is disabled.

@trulow I guess that the latter could be useful for your fork of electron_patcher.py but I'm not a Python expert and this needs some specific detection/patch methods for 1Password.

@NeonPickle
Copy link

NeonPickle commented May 9, 2025

I installed Sequoia on my MacPro6,1 and it works very well. Using this patcher fixed Chrome and Opera for me and the only remaining app so far is Obsidian for which I have found the following fix. First launch Obsidian from using this command

open /Applications/Obsidian.app --args --use-angle=gl

Then once you are up and running go to Settings>Appearance>Hardware Acceleration and turn it off. You can now run obsidian as normal.

@Webs101
Copy link

Webs101 commented Oct 7, 2025

I have to run this and restart for Chrome and Chrome only every time I want to use it. It’s like Chrome overwrites the change on quitting.

Screenshot 2025-10-07 at 14 13 30

macPro6,1 using Ventura with OCLP. Chrome v. 141.0.7390.55

@RezzZ
Copy link

RezzZ commented Oct 8, 2025

I have to run this and restart for Chrome and Chrome only every time I want to use it. It’s like Chrome overwrites the change on quitting.

Screenshot 2025-10-07 at 14 13 30 macPro6,1 using Ventura with OCLP. Chrome v. 141.0.7390.55

for me this script isn't working any more. only way to start chrome for now is with the command:
open /Applications/Google\ Chrome.app --args --use-angle=gl

the flag use-angle seems to have been removed from chrome itself. I cannot change it anymore from the chrome://flags page. Guess I need a different way to force GL to start with chrome now

update:
i created a apple script like this to create a new app to launch chrome with above commandline.
then I used this trick to change the icon.

@Webs101
Copy link

Webs101 commented Oct 8, 2025

Haha, thanks. I was just about to post that I created an Automator applet for this (and also that your command line is for Discord). And here it is! Feel free to make this a gist if you'd like to.

@RezzZ
Copy link

RezzZ commented Oct 8, 2025

Haha, thanks. I was just about to post that I created an Automator applet for this (and also that your command line is for Discord). And here it is! Feel free to make this a gist if you'd like to.

yeah, saw that already and fixed it :). Thanks for the share. I had to do the same with my visual studio code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment