2024-07-06 00:11:56 +02:00
|
|
|
#!/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}')
|
|
|
|
|
|
|
|
|
2024-07-07 16:53:24 +02:00
|
|
|
def write_as_sudo(file, value):
|
2024-07-06 00:11:56 +02:00
|
|
|
try:
|
|
|
|
if os.geteuid() == 0:
|
|
|
|
with open(file, 'w') as f:
|
|
|
|
f.write(value)
|
|
|
|
else:
|
|
|
|
subprocess.call([
|
|
|
|
'pkexec',
|
|
|
|
'sh',
|
|
|
|
'-c',
|
2024-07-07 16:53:24 +02:00
|
|
|
f'echo "{value}" > {file}'
|
2024-07-06 00:11:56 +02:00
|
|
|
])
|
|
|
|
except:
|
|
|
|
traceback.print_exc()
|
|
|
|
pass
|