- Fix Bazzite autostart tickbox

- fixes #320
- The approach is a bit heavy-handed but functionally will work fine.
This commit is contained in:
Trigg 2024-02-23 12:18:24 +00:00
parent 7a2bc9845e
commit fdb8a48267

View file

@ -13,6 +13,7 @@
"""A class to assist auto-start"""
import os
import logging
import shutil
try:
from xdg.BaseDirectory import xdg_config_home, xdg_data_home
except ModuleNotFoundError:
@ -93,19 +94,16 @@ class BazziteAutostart:
self.auto = enable
def change_file(self, value):
newcontent = []
with open("/etc/default/discover-overlay") as f:
content = f.readlines()
for line in content:
if line.startswith("AUTO_LAUNCH_DISCOVER_OVERLAY="):
newcontent.append(
"AUTO_LAUNCH_DISCOVER_OVERLAY=%s\n" % value)
elif len(line) < 2:
pass
else:
newcontent.append(line)
with open("/etc/default/discover-overlay", 'w') as f:
f.writelines(newcontent)
root = ''
if shutil.which('pkexec'):
root = 'pkexec'
else:
log.error("No ability to request root privs. Cancel")
return
command = " sed -i 's/AUTO_LAUNCH_DISCOVER_OVERLAY=./AUTO_LAUNCH_DISCOVER_OVERLAY=%s/g' /etc/default/discover-overlay" % (value)
command_with_permissions = root + command
os.system(command_with_permissions)
def is_auto(self):
"""Check if it's already set to auto-start"""