Skip to content

Commit

Permalink
Only try to pass window ids to synaptic in an x11 session.
Browse files Browse the repository at this point in the history
  • Loading branch information
mtwebster committed Feb 17, 2024
1 parent 72593db commit f9e73eb
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 17 deletions.
15 changes: 11 additions & 4 deletions usr/bin/mint-refresh-cache
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,17 @@ if __name__ == "__main__":
if os.getuid() == 0:
if len(sys.argv) > 2 and sys.argv[1] == "--use-synaptic":
import subprocess
subprocess.run(["/usr/sbin/synaptic", "--hide-main-window",
"--update-at-startup", "--non-interactive",
"--parent-window-id", sys.argv[2]],
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
cmd = [
"/usr/sbin/synaptic",
"--hide-main-window",
"--update-at-startup",
"--non-interactive"
]

if os.environ.get("XDG_SESSION_TYPE", "x11") == "x11":
cmd += ["--parent-window-id", sys.argv[2]]

subprocess.run(cmd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
else:
try:
import apt
Expand Down
14 changes: 11 additions & 3 deletions usr/lib/linuxmint/mintUpdate/kernelwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,17 @@ def run(self):
if not do_regular:
do_regular = True
f = tempfile.NamedTemporaryFile()
cmd = ["pkexec", "/usr/sbin/synaptic", "--hide-main-window", \
"--non-interactive", "--parent-window-id", "%s" % self.application.window.get_window().get_xid(), \
"-o", "Synaptic::closeZvt=true", "--set-selections-file", "%s" % f.name]
cmd = [
"pkexec", "/usr/sbin/synaptic",
"--hide-main-window",
"--non-interactive",
"-o", "Synaptic::closeZvt=true",
"--set-selections-file", "%s" % f.name
]

if os.environ.get("XDG_SESSION_TYPE", "x11") == "x11":
cmd += ["--parent-window-id", "%s" % self.application.window.get_window().get_xid()]

if not self.cache:
self.cache = apt.Cache()
_KERNEL_PKG_NAMES = KERNEL_PKG_NAMES.copy()
Expand Down
25 changes: 17 additions & 8 deletions usr/lib/linuxmint/mintUpdate/mintUpdate.py
Original file line number Diff line number Diff line change
Expand Up @@ -596,9 +596,16 @@ def run(self):
self.application.logger.write("Ready to launch synaptic")
f = tempfile.NamedTemporaryFile()

cmd = ["pkexec", "/usr/sbin/synaptic", "--hide-main-window", \
"--non-interactive", "--parent-window-id", "%s" % self.application.window.get_window().get_xid(), \
"-o", "Synaptic::closeZvt=true", "--set-selections-file", "%s" % f.name]
cmd = [
"pkexec", "/usr/sbin/synaptic",
"--hide-main-window",
"--non-interactive",
"-o", "Synaptic::closeZvt=true",
"--set-selections-file", "%s" % f.name,
]

if os.environ.get("XDG_SESSION_TYPE", "x11") == "x11":
cmd += ["--parent-window-id", "%s" % self.application.window.get_window().get_xid()]

for pkg in packages:
pkg_line = "%s\tinstall\n" % pkg
Expand Down Expand Up @@ -832,7 +839,7 @@ def run(self):
# Refresh the APT cache
if self.root_mode:
refresh_command = ["sudo", "/usr/bin/mint-refresh-cache"]
if not self.application.app_hidden():
if (not self.application.app_hidden()) and os.environ.get("XDG_SESSION_TYPE", "x11") == "x11":
refresh_command.extend(["--use-synaptic",
str(self.application.window.get_window().get_xid())])
subprocess.run(refresh_command)
Expand Down Expand Up @@ -2746,10 +2753,12 @@ def get_inhibitor_info(self, reason):
# LOGOUT | SUSPEND
flags = 1 | 4

try:
xid = self.window.get_window().get_xid()
except:
xid = 0
xid = 0
if os.environ.get("XDG_SESSION_TYPE", "x11") == "x11":
try:
xid = self.window.get_window().get_xid()
except:
pass

name = "org.gnome.SessionManager"
path = "/org/gnome/SessionManager"
Expand Down
20 changes: 18 additions & 2 deletions usr/lib/linuxmint/mintUpdate/rel_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,16 @@ def build_assistant(self):


def install_pkgs(self, widget, event, packages):
cmd = ["pkexec", "/usr/sbin/synaptic", "--hide-main-window", "--non-interactive", "--parent-window-id", "%s" % self.assistant.get_window().get_xid(), "-o", "Synaptic::closeZvt=true"]
cmd = [
"pkexec", "/usr/sbin/synaptic",
"--hide-main-window",
"--non-interactive",
"-o", "Synaptic::closeZvt=true"
]

if os.environ.get("XDG_SESSION_TYPE", "x11") == "x11":
xmd += ["--parent-window-id", "%s" % self.assistant.get_window().get_xid()]

f = tempfile.NamedTemporaryFile()
for pkg in packages:
pkg_line = "%s\tinstall\n" % pkg
Expand Down Expand Up @@ -238,7 +247,14 @@ def apply_button_pressed(self, assistant):
else:
os.system("gsettings set %s false" % screensaver_setting)

cmd = ["pkexec", "/usr/bin/mint-release-upgrade-root", "%s" % self.current_codename, "%s" % self.assistant.get_window().get_xid()]
cmd = [
"pkexec", "/usr/bin/mint-release-upgrade-root",
"%s" % self.current_codename
]

if os.environ.get("XDG_SESSION_TYPE", "x11") == "x11":
cmd += ["%s" % self.assistant.get_window().get_xid()]

comnd = Popen(' '.join(cmd), shell=True)
returnCode = comnd.wait()

Expand Down

0 comments on commit f9e73eb

Please sign in to comment.