Use system for terminal if it is allowed to
This commit is contained in:
parent
d79a1236a0
commit
15bd4335e8
@ -18,10 +18,15 @@ class terminal(Vte.Terminal):
|
||||
pty = Vte.Pty.new_sync(Vte.PtyFlags.DEFAULT, None)
|
||||
|
||||
self.set_pty(pty)
|
||||
|
||||
env = {
|
||||
"TERM": "xterm-256color"
|
||||
}
|
||||
|
||||
pty.spawn_async(
|
||||
GLib.get_current_dir(),
|
||||
script,
|
||||
[],
|
||||
[f"{key}={value}" for key, value in env.items()],
|
||||
GLib.SpawnFlags.DEFAULT,
|
||||
None,
|
||||
None,
|
||||
|
@ -437,14 +437,25 @@ def run_script_response(self, dialog, task, script, language_name):
|
||||
else:
|
||||
with open(os.path.join(data_dir, 'pyenv', 'requirements.txt'), 'w') as f:
|
||||
f.write('')
|
||||
print(script)
|
||||
script = ';\n'.join(script)
|
||||
|
||||
script += '; echo "\n🦙 {}"'.format(_('Script exited'))
|
||||
if language_name == 'bash':
|
||||
script = script.replace('sudo ', 'pkexec ')
|
||||
if shutil.which('flatpak-spawn') and language_name == 'bash':
|
||||
script = 'echo "🦙 {}\n";'.format(_('The script is contained inside Flatpak')) + script
|
||||
|
||||
self.run_terminal(['bash', '-c', script])
|
||||
sandbox = True
|
||||
try:
|
||||
process = subprocess.run(['flatpak-spawn', '--host', 'bash', '-c', 'echo "test"'], check=True)
|
||||
sandbox = False
|
||||
except Exception as e:
|
||||
pass
|
||||
if sandbox:
|
||||
script = 'echo "🦙 {}\n";'.format(_('The script is contained inside Flatpak')) + script
|
||||
self.run_terminal(['bash', '-c', script])
|
||||
else:
|
||||
self.run_terminal(['flatpak-spawn', '--host', 'bash', '-c', script])
|
||||
else:
|
||||
self.run_terminal(['bash', '-c', script])
|
||||
|
||||
def run_script(self, script:str, language_name:str):
|
||||
dialog = Adw.AlertDialog(
|
||||
|
Loading…
x
Reference in New Issue
Block a user