From b2bceea2d37452db5ec41b21be28d38ed5ef1c04 Mon Sep 17 00:00:00 2001 From: Sundar Date: Sun, 6 May 2018 18:56:03 +0530 Subject: [PATCH] Fix for GUI crash on certain distros due to "QXcbConnection: Could not connect to display :0" error. --- multibootusb | 3 ++- multibootusb-pkexec | 11 +++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) mode change 100644 => 100755 multibootusb diff --git a/multibootusb b/multibootusb old mode 100644 new mode 100755 index 7535314..5473834 --- a/multibootusb +++ b/multibootusb @@ -9,6 +9,7 @@ import os import getopt import sys import platform +import shutil # The following line is required for distros based on rpm so as to avoid import errors when running from # installed system @@ -160,7 +161,7 @@ if __name__ == '__main__': config.image_path = arg.split(',') elif opt in ('-t', '--target'): # Convert to upper if windows drive name is given - config.usb_disk = len(arg)==2 and arg[0].isalpha() and arg[1]==':'\ + config.usb_disk = len(arg) == 2 and arg[0].isalpha() and arg[1] == ':'\ and arg.upper() or arg elif opt in ('-c', '--command'): gui = False diff --git a/multibootusb-pkexec b/multibootusb-pkexec index ba44ef3..e95f159 100644 --- a/multibootusb-pkexec +++ b/multibootusb-pkexec @@ -2,12 +2,19 @@ # Generic wrapper for locating multibootusb file and execute pkexec accordingly # Bin pat of this file and policy file have to match +# Ensure that root is added in to xhost list to access X-Server +# Otherwise script will fail to launch GUI +if type "xhost" > /dev/null; then + xhost local:root > /dev/null +fi + + if [ $(which pkexec) ]; then - if [ -f /usr/bin/multibootusb ]; then + if [ -f /usr/bin/multibootusb ]; then # path to debian based distros pkexec --disable-internal-agent "/usr/bin/multibootusb" "$@" fi - if [ -f /usr/local/bin/multibootusb ]; then + if [ -f /usr/local/bin/multibootusb ]; then # path to fedora based distros pkexec --disable-internal-agent "/usr/local/bin/multibootusb" "$@" fi else