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