-
Notifications
You must be signed in to change notification settings - Fork 29
/
system76-daemon
executable file
·75 lines (64 loc) · 2.26 KB
/
system76-daemon
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/python3
# system76-driver: Universal driver for System76 computers
# Copyright (C) 2005-2016 System76, Inc.
#
# This file is part of `system76-driver`.
#
# `system76-driver` is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# `system76-driver` is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with `system76-driver`; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
"""
Test Airplane Mode workaround.
"""
import time
import argparse
import os
import sys
import logging
from gi.repository import GLib
import system76driver
from system76driver import daemon
start_time = time.monotonic()
logging.basicConfig(
level=logging.DEBUG,
style='{',
format='{asctime} {levelname} {message}',
)
log = logging.getLogger()
parser = argparse.ArgumentParser()
parser.add_argument('--model', help='force model rather than detecting it')
parser.add_argument('--debug', action='store_true', default=False,
help='print loaded modules',
)
args = parser.parse_args()
if os.getuid() != 0:
sys.exit('Error: system76-daemon must be run as root')
log.info('**** Process start at monotonic time %r', start_time)
if not args.model:
model = daemon.load_json_conf('/etc/system76-daemon.json').get('model')
args.model = (model or system76driver.get_product_version())
log.info('model: %r', args.model)
brightness = daemon.run_brightness(args.model)
airplane = daemon.run_airplane(args.model)
acpi = daemon.run_firmware_acpi_interrupt(args.model)
ess_dac_autoswitch = daemon.run_ess_dac_autoswitch(args.model)
daemon.run_headphone_volume_adjust(args.model)
daemon.run_dpcd_pwm(args.model)
tdp = daemon.run_limit_power_draw(args.model)
mainloop = GLib.MainLoop()
if args.debug:
names = sorted(sys.modules)
for name in names:
print(name)
print(len(names))
mainloop.run()