30 lines
612 B
Python
30 lines
612 B
Python
|
#!/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_to_file(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
|