Skip to content

Commit

Permalink
client: ios: add backlight control
Browse files Browse the repository at this point in the history
  • Loading branch information
doronz88 committed Feb 21, 2022
1 parent d230dc1 commit 5b42963
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/rpcclient/rpcclient/ios/backlight.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import logging

from rpcclient.exceptions import BadReturnValueError


class Backlight:
def __init__(self, client):
self._client = client

BrightnessSystemClient = self._client.symbols.objc_getClass('BrightnessSystemClient')
if not BrightnessSystemClient:
logging.error('failed to load BrightnessSystemClient class')
self._brightness = BrightnessSystemClient.objc_call('new')

@property
def brighness(self) -> float:
""" get brightness value in range: 0.0 - 1.0 """
return self._brightness.objc_call('copyPropertyForKey:', self._client.cf('DisplayBrightness')).py['Brightness']

@brighness.setter
def brighness(self, value: float):
""" set brighness in range: 0.0 - 1.0 """
if not self._brightness.objc_call('setProperty:forKey:', self._client.cf(value),
self._client.cf('DisplayBrightness')):
raise BadReturnValueError('failed to set DisplayBrightness')
5 changes: 5 additions & 0 deletions src/rpcclient/rpcclient/ios/client.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import typing

from rpcclient.darwin.client import DarwinClient
from rpcclient.ios.backlight import Backlight


class IosClient(DarwinClient):
def __init__(self, sock, sysname: str, hostname: str, port: int = None):
super().__init__(sock, sysname, hostname, port)
self.backlight = Backlight(self)

@property
def roots(self) -> typing.List[str]:
""" get a list of all accessible darwin roots when used for lookup of files/preferences/... """
Expand Down

0 comments on commit 5b42963

Please sign in to comment.