- Fix Bazzite autostart tickbox
- fixes #320 - The approach is a bit heavy-handed but functionally will work fine.
This commit is contained in:
parent
7a2bc9845e
commit
fdb8a48267
1 changed files with 11 additions and 13 deletions
|
|
@ -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"""
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue