Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Next] Add system reboot ability to mintUpdate when reboot is needed #905

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 23 additions & 3 deletions usr/lib/linuxmint/mintUpdate/mintUpdate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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():
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down