Skip to content

Commit

Permalink
CI Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexhuszagh committed Sep 7, 2024
1 parent c9dda88 commit a44ed6d
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions example/breeze_theme.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,8 @@ def macos_supported_version() -> bool:
def _get_theme_macos() -> Theme:
'''Get the current theme, as light or dark, for the system on macOS.'''

# NOTE: This can segfault on M1 and M2 Macs on Big Sur 11.4+. So, we also try reading
# directly using subprocess.
# NOTE: This can segfault on M1 and M2 Macs on Big Sur 11.4+. So, we also
# try reading directly using subprocess.
try:
command = ['defaults', 'read', '-globalDomain', 'AppleInterfaceStyle']
process = subprocess.run(command, capture_output=True, check=True)
Expand All @@ -303,11 +303,14 @@ def _get_theme_macos() -> Theme:
except UnicodeDecodeError:
return Theme.LIGHT
except subprocess.CalledProcessError as error:
# We can't read these defaults, just try using our libcs
print(error.stderr)
print(error.stdout)
# TODO: Reset to pass...
raise
# If this keypair does not exist, then it's a specific error because the style
# hasn't been set before, so then it specifically is a light theme. this can
# affect no-UI systems like CI.
not_exist = b'does not exist' in error.stderr
any_app = b'kCFPreferencesAnyApplication' in error.stderr
interface_style = b'AppleInterfaceStyle' in error.stderr
if not_exist and any_app and interface_style:
return Theme.LIGHT

# NOTE: We do this so we don't need imports at the global level.
try:
Expand Down

0 comments on commit a44ed6d

Please sign in to comment.