diff --git a/usr/lib/linuxmint/mintUpdate/mintUpdate.py b/usr/lib/linuxmint/mintUpdate/mintUpdate.py index 479c364e..b9a8dcdd 100755 --- a/usr/lib/linuxmint/mintUpdate/mintUpdate.py +++ b/usr/lib/linuxmint/mintUpdate/mintUpdate.py @@ -594,7 +594,10 @@ def show_dpkg_lock_msg(parent): dialog.destroy() @_idle - def show_infobar(self, title, msg, msg_type, icon, callback): + def show_infobar(self, title, msg, msg_type, icon, callback, ok_label=None): + if not ok_label: + ok_label = _("OK") + infobar = Gtk.InfoBar() infobar.set_margin_bottom(2) infobar.set_message_type(msg_type) @@ -620,7 +623,7 @@ def show_infobar(self, title, msg, msg_type, icon, callback): infobar.add_button(_("Yes"), Gtk.ResponseType.YES) infobar.add_button(_("No"), Gtk.ResponseType.NO) else: - infobar.add_button(_("OK"), Gtk.ResponseType.OK) + infobar.add_button(ok_label, Gtk.ResponseType.OK) infobar.connect("response", callback) infobar.show_all() for child in self.ui_infobar.get_children(): @@ -2082,7 +2085,11 @@ def refresh(self, refresh_cache): if self.reboot_required: self.show_infobar(_("Reboot required"), - _("You have installed updates that require a reboot to take effect. Please reboot your system as soon as possible."), Gtk.MessageType.WARNING, "system-reboot-symbolic", None) + _("You have installed updates that require a reboot to take effect. Please reboot your system as soon as possible."), + Gtk.MessageType.WARNING, + "system-reboot-symbolic", + self._on_infobar_reboot, + _("Reboot")) if refresh_cache: # Note: All cache refresh happen asynchronously @@ -2111,6 +2118,19 @@ def refresh(self, refresh_cache): self.refresh_updates() + def _on_infobar_reboot(self, parent, response_id): + session = os.environ.get("XDG_CURRENT_DESKTOP") + # Trigger reboot based on DE + if session in ["Cinnamon", "X-Cinnamon"]: + subprocess.run(['/usr/bin/cinnamon-session-quit', '--reboot']) + elif session == 'MATE': + subprocess.run(['/usr/bin/dbus-send', '--dest=org.gnome.SessionManager', '--type=method_call', + '/org/gnome/SessionManager', 'org.gnome.SessionManager.RequestReboot']) + elif session == 'XFCE': + subprocess.run(['/usr/bin/xfce4-session-logout', '--reboot']) + else: + subprocess.run(['/usr/bin/systemctl', 'reboot']) + @_async def refresh_apt_cache_externally(self): try: