-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathredshift_process.py
More file actions
35 lines (25 loc) · 1.04 KB
/
Copy pathredshift_process.py
File metadata and controls
35 lines (25 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
''' redshift process '''
import subprocess
from redshift_config import RedshiftConfig
class RedshiftNotInstalledException(Exception):
''' Redshift Not Installed Exception '''
class RedshiftProcess:
''' redshift process manager '''
config: RedshiftConfig
bin_name = 'redshift'
def __init__(self, config: RedshiftConfig):
self.config = config
def apply(self) -> None:
''' apply new config to redshift '''
temp = str(self.config.get_property(RedshiftConfig.TEMP_DAY))
brightness = str(self.config.get_property(RedshiftConfig.BRIGHTNESS))
args = [self.bin_name, '-x', '-P', '-O',
temp, '-b', brightness]
try:
subprocess.Popen(args, close_fds=True, shell=False)
except FileNotFoundError as no_redshift:
raise RedshiftNotInstalledException from no_redshift
def reset(self) -> None:
''' apply reset redshift to default values '''
args = [self.bin_name, '-x', '-P']
subprocess.Popen(args, close_fds=True, shell=False)