Skip to content

Commit 36e13f1

Browse files
Add system reboot ability to mintUpdate when reboot is needed (#905)
* add reboot button to infobar reboot button will present yes/no dialog box asking for user confirmation * pulled latest master code and re-implemented * reworked reboot to integrate with DE
1 parent 281b4e2 commit 36e13f1

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

usr/lib/linuxmint/mintUpdate/mintUpdate.py

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,10 @@ def show_dpkg_lock_msg(parent):
595595
dialog.destroy()
596596

597597
@_idle
598-
def show_infobar(self, title, msg, msg_type, icon, callback):
598+
def show_infobar(self, title, msg, msg_type, icon, callback, ok_label=None):
599+
if not ok_label:
600+
ok_label = _("OK")
601+
599602
infobar = Gtk.InfoBar()
600603
infobar.set_margin_bottom(2)
601604
infobar.set_message_type(msg_type)
@@ -621,7 +624,7 @@ def show_infobar(self, title, msg, msg_type, icon, callback):
621624
infobar.add_button(_("Yes"), Gtk.ResponseType.YES)
622625
infobar.add_button(_("No"), Gtk.ResponseType.NO)
623626
else:
624-
infobar.add_button(_("OK"), Gtk.ResponseType.OK)
627+
infobar.add_button(ok_label, Gtk.ResponseType.OK)
625628
infobar.connect("response", callback)
626629
infobar.show_all()
627630
for child in self.ui_infobar.get_children():
@@ -2084,7 +2087,11 @@ def refresh(self, refresh_cache):
20842087

20852088
if self.reboot_required:
20862089
self.show_infobar(_("Reboot required"),
2087-
_("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)
2090+
_("You have installed updates that require a reboot to take effect. Please reboot your system as soon as possible."),
2091+
Gtk.MessageType.WARNING,
2092+
"system-reboot-symbolic",
2093+
self._on_infobar_reboot,
2094+
_("Reboot"))
20882095

20892096
if refresh_cache:
20902097
# Note: All cache refresh happen asynchronously
@@ -2113,6 +2120,19 @@ def refresh(self, refresh_cache):
21132120

21142121
self.refresh_updates()
21152122

2123+
def _on_infobar_reboot(self, parent, response_id):
2124+
session = os.environ.get("XDG_CURRENT_DESKTOP")
2125+
# Trigger reboot based on DE
2126+
if session in ["Cinnamon", "X-Cinnamon"]:
2127+
subprocess.run(['/usr/bin/cinnamon-session-quit', '--reboot'])
2128+
elif session == 'MATE':
2129+
subprocess.run(['/usr/bin/dbus-send', '--dest=org.gnome.SessionManager', '--type=method_call',
2130+
'/org/gnome/SessionManager', 'org.gnome.SessionManager.RequestReboot'])
2131+
elif session == 'XFCE':
2132+
subprocess.run(['/usr/bin/xfce4-session-logout', '--reboot'])
2133+
else:
2134+
subprocess.run(['/usr/bin/systemctl', 'reboot'])
2135+
21162136
@_async
21172137
def refresh_apt_cache_externally(self):
21182138
try:

0 commit comments

Comments
 (0)