Skip to content

Commit f9e73eb

Browse files
committed
Only try to pass window ids to synaptic in an x11 session.
1 parent 72593db commit f9e73eb

File tree

4 files changed

+57
-17
lines changed

4 files changed

+57
-17
lines changed

usr/bin/mint-refresh-cache

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,17 @@ if __name__ == "__main__":
66
if os.getuid() == 0:
77
if len(sys.argv) > 2 and sys.argv[1] == "--use-synaptic":
88
import subprocess
9-
subprocess.run(["/usr/sbin/synaptic", "--hide-main-window",
10-
"--update-at-startup", "--non-interactive",
11-
"--parent-window-id", sys.argv[2]],
12-
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
9+
cmd = [
10+
"/usr/sbin/synaptic",
11+
"--hide-main-window",
12+
"--update-at-startup",
13+
"--non-interactive"
14+
]
15+
16+
if os.environ.get("XDG_SESSION_TYPE", "x11") == "x11":
17+
cmd += ["--parent-window-id", sys.argv[2]]
18+
19+
subprocess.run(cmd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
1320
else:
1421
try:
1522
import apt

usr/lib/linuxmint/mintUpdate/kernelwindow.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,17 @@ def run(self):
6060
if not do_regular:
6161
do_regular = True
6262
f = tempfile.NamedTemporaryFile()
63-
cmd = ["pkexec", "/usr/sbin/synaptic", "--hide-main-window", \
64-
"--non-interactive", "--parent-window-id", "%s" % self.application.window.get_window().get_xid(), \
65-
"-o", "Synaptic::closeZvt=true", "--set-selections-file", "%s" % f.name]
63+
cmd = [
64+
"pkexec", "/usr/sbin/synaptic",
65+
"--hide-main-window",
66+
"--non-interactive",
67+
"-o", "Synaptic::closeZvt=true",
68+
"--set-selections-file", "%s" % f.name
69+
]
70+
71+
if os.environ.get("XDG_SESSION_TYPE", "x11") == "x11":
72+
cmd += ["--parent-window-id", "%s" % self.application.window.get_window().get_xid()]
73+
6674
if not self.cache:
6775
self.cache = apt.Cache()
6876
_KERNEL_PKG_NAMES = KERNEL_PKG_NAMES.copy()

usr/lib/linuxmint/mintUpdate/mintUpdate.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -596,9 +596,16 @@ def run(self):
596596
self.application.logger.write("Ready to launch synaptic")
597597
f = tempfile.NamedTemporaryFile()
598598

599-
cmd = ["pkexec", "/usr/sbin/synaptic", "--hide-main-window", \
600-
"--non-interactive", "--parent-window-id", "%s" % self.application.window.get_window().get_xid(), \
601-
"-o", "Synaptic::closeZvt=true", "--set-selections-file", "%s" % f.name]
599+
cmd = [
600+
"pkexec", "/usr/sbin/synaptic",
601+
"--hide-main-window",
602+
"--non-interactive",
603+
"-o", "Synaptic::closeZvt=true",
604+
"--set-selections-file", "%s" % f.name,
605+
]
606+
607+
if os.environ.get("XDG_SESSION_TYPE", "x11") == "x11":
608+
cmd += ["--parent-window-id", "%s" % self.application.window.get_window().get_xid()]
602609

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

2749-
try:
2750-
xid = self.window.get_window().get_xid()
2751-
except:
2752-
xid = 0
2756+
xid = 0
2757+
if os.environ.get("XDG_SESSION_TYPE", "x11") == "x11":
2758+
try:
2759+
xid = self.window.get_window().get_xid()
2760+
except:
2761+
pass
27532762

27542763
name = "org.gnome.SessionManager"
27552764
path = "/org/gnome/SessionManager"

usr/lib/linuxmint/mintUpdate/rel_upgrade.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,16 @@ def build_assistant(self):
173173

174174

175175
def install_pkgs(self, widget, event, packages):
176-
cmd = ["pkexec", "/usr/sbin/synaptic", "--hide-main-window", "--non-interactive", "--parent-window-id", "%s" % self.assistant.get_window().get_xid(), "-o", "Synaptic::closeZvt=true"]
176+
cmd = [
177+
"pkexec", "/usr/sbin/synaptic",
178+
"--hide-main-window",
179+
"--non-interactive",
180+
"-o", "Synaptic::closeZvt=true"
181+
]
182+
183+
if os.environ.get("XDG_SESSION_TYPE", "x11") == "x11":
184+
xmd += ["--parent-window-id", "%s" % self.assistant.get_window().get_xid()]
185+
177186
f = tempfile.NamedTemporaryFile()
178187
for pkg in packages:
179188
pkg_line = "%s\tinstall\n" % pkg
@@ -238,7 +247,14 @@ def apply_button_pressed(self, assistant):
238247
else:
239248
os.system("gsettings set %s false" % screensaver_setting)
240249

241-
cmd = ["pkexec", "/usr/bin/mint-release-upgrade-root", "%s" % self.current_codename, "%s" % self.assistant.get_window().get_xid()]
250+
cmd = [
251+
"pkexec", "/usr/bin/mint-release-upgrade-root",
252+
"%s" % self.current_codename
253+
]
254+
255+
if os.environ.get("XDG_SESSION_TYPE", "x11") == "x11":
256+
cmd += ["%s" % self.assistant.get_window().get_xid()]
257+
242258
comnd = Popen(' '.join(cmd), shell=True)
243259
returnCode = comnd.wait()
244260

0 commit comments

Comments
 (0)