#!/usr/bin/env python3 import os import subprocess import traceback def loaded(option, value=None): print(f'Loaded {option}' + (f': {value}' if value is not None else '')) def store(option, value): print(f'Store {option}: {value}') def write_as_sudo(file, value): try: if os.geteuid() == 0: with open(file, 'w') as f: f.write(value) else: subprocess.call([ 'pkexec', 'sh', '-c', f'echo "{value}" > {file}' ]) except: traceback.print_exc() pass