Skip to content

Commit 30a33b4

Browse files
committed
qtvcp -qt_action: fix system shutdown function
Thanks to Greg of the QtPlasmac crew for the fix!
1 parent ebfce42 commit 30a33b4

1 file changed

Lines changed: 6 additions & 9 deletions

File tree

lib/python/qtvcp/qt_action.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -648,17 +648,14 @@ def ADJUST_GRAPHICS_ROTATE(self, x, y):
648648

649649
def SHUT_SYSTEM_DOWN_PROMPT(self):
650650
import subprocess
651+
import shutil
651652
try:
652-
try:
653+
if shutil.which('gnome-session-quit'):
653654
subprocess.call('gnome-session-quit --power-off', shell=True)
654-
except:
655-
try:
656-
subprocess.call('xfce4-session-logout', shell=True)
657-
except:
658-
try:
659-
subprocess.call('systemctl poweroff', shell=True)
660-
except:
661-
raise
655+
elif shutil.which('xfce4-session-logout'):
656+
subprocess.call('xfce4-session-logout', shell=True)
657+
else:
658+
subprocess.call('systemctl poweroff', shell=True)
662659
except Exception as e:
663660
LOG.warning("Couldn't shut system down: {}".format(e))
664661

0 commit comments

Comments
 (0)