diff --git a/com.jeffser.Alpaca.json b/com.jeffser.Alpaca.json index 9d96e0e..fe9af44 100644 --- a/com.jeffser.Alpaca.json +++ b/com.jeffser.Alpaca.json @@ -12,7 +12,8 @@ "--socket=wayland", "--filesystem=/sys/module/amdgpu:ro", "--env=LD_LIBRARY_PATH=/app/lib:/usr/lib/x86_64-linux-gnu/GL/default/lib:/usr/lib/x86_64-linux-gnu/openh264/extra:/usr/lib/x86_64-linux-gnu/openh264/extra:/usr/lib/sdk/llvm15/lib:/usr/lib/x86_64-linux-gnu/GL/default/lib:/usr/lib/ollama:/app/plugins/AMD/lib/ollama", - "--env=GSK_RENDERER=ngl" + "--env=GSK_RENDERER=ngl", + "--talk-name=org.freedesktop.Flatpak" ], "add-extensions": { "com.jeffser.Alpaca.Plugins": { diff --git a/src/custom_widgets/terminal_widget.py b/src/custom_widgets/terminal_widget.py index 51fae45..ce74dcd 100644 --- a/src/custom_widgets/terminal_widget.py +++ b/src/custom_widgets/terminal_widget.py @@ -20,13 +20,14 @@ class terminal(Vte.Terminal): self.set_pty(pty) env = { - "TERM": "xterm-256color" + 'TERM': "xterm-256color", + 'SUDO_ASKPASS': "sh -c 'pkexec echo'" } pty.spawn_async( GLib.get_current_dir(), script, - [f"{key}={value}" for key, value in env.items()], + [], GLib.SpawnFlags.DEFAULT, None, None, diff --git a/src/dialogs.py b/src/dialogs.py index 9c41878..bcda64a 100644 --- a/src/dialogs.py +++ b/src/dialogs.py @@ -3,7 +3,7 @@ Handles UI dialogs """ import os -import logging, requests, threading, shutil, subprocess +import logging, requests, threading, shutil, subprocess, re from pytube import YouTube from html2text import html2text from gi.repository import Adw, Gtk @@ -441,7 +441,7 @@ def run_script_response(self, dialog, task, script, language_name): script += '; echo "\n🦙 {}"'.format(_('Script exited')) if language_name == 'bash': - script = script.replace('sudo ', 'pkexec ') + script = re.sub(r'(?m)^\s*sudo', 'pkexec', script) if shutil.which('flatpak-spawn') and language_name == 'bash': sandbox = True try: