Skip to content

Commit b952fa0

Browse files
committed
Replaced sudo with pkexec in custom scripts
1 parent 15bd433 commit b952fa0

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

com.jeffser.Alpaca.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
"--socket=wayland",
1313
"--filesystem=/sys/module/amdgpu:ro",
1414
"--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",
15-
"--env=GSK_RENDERER=ngl"
15+
"--env=GSK_RENDERER=ngl",
16+
"--talk-name=org.freedesktop.Flatpak"
1617
],
1718
"add-extensions": {
1819
"com.jeffser.Alpaca.Plugins": {

src/custom_widgets/terminal_widget.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,14 @@ def __init__(self, script:list):
2020
self.set_pty(pty)
2121

2222
env = {
23-
"TERM": "xterm-256color"
23+
'TERM': "xterm-256color",
24+
'SUDO_ASKPASS': "sh -c 'pkexec echo'"
2425
}
2526

2627
pty.spawn_async(
2728
GLib.get_current_dir(),
2829
script,
29-
[f"{key}={value}" for key, value in env.items()],
30+
[],
3031
GLib.SpawnFlags.DEFAULT,
3132
None,
3233
None,

src/dialogs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Handles UI dialogs
44
"""
55
import os
6-
import logging, requests, threading, shutil, subprocess
6+
import logging, requests, threading, shutil, subprocess, re
77
from pytube import YouTube
88
from html2text import html2text
99
from gi.repository import Adw, Gtk
@@ -441,7 +441,7 @@ def run_script_response(self, dialog, task, script, language_name):
441441

442442
script += '; echo "\n🦙 {}"'.format(_('Script exited'))
443443
if language_name == 'bash':
444-
script = script.replace('sudo ', 'pkexec ')
444+
script = re.sub(r'(?m)^\s*sudo', 'pkexec', script)
445445
if shutil.which('flatpak-spawn') and language_name == 'bash':
446446
sandbox = True
447447
try:

0 commit comments

Comments
 (0)