From 7c81f88603c4e287bdb6d05ff7c6dc3bedfbf02b Mon Sep 17 00:00:00 2001 From: Aaahh Ahh Date: Sat, 19 May 2018 12:37:08 -0400 Subject: [PATCH 1/2] Replace Log Out with Reboot --- usr/lib/prime-indicator/prime-indicator | 42 +++++-------------------- 1 file changed, 7 insertions(+), 35 deletions(-) diff --git a/usr/lib/prime-indicator/prime-indicator b/usr/lib/prime-indicator/prime-indicator index 05b9832..afcde5e 100755 --- a/usr/lib/prime-indicator/prime-indicator +++ b/usr/lib/prime-indicator/prime-indicator @@ -239,37 +239,9 @@ class Indicator: def execute(self): Gtk.main() - def logout(self): - env = os.environ.get("XDG_CURRENT_DESKTOP", "UNSUPPORTED") - if env: - env = env.lower() - - if env.startswith("xfce"): - os.system("xfce4-session-logout --logout") - restart() - elif env.startswith("kde"): - os.system("qdbus org.kde.ksmserver /KSMServer logout 0 0 0") - elif env.startswith("lxde"): - os.system("lxsession-logout --prompt 'Please click the Log Out button to continue'") - elif env.startswith("x-cinnamon"): - os.system("cinnamon-session-quit --logout --no-prompt") - elif env.startswith("mate"): - os.system("mate-session-save --logout") - elif env.startswith("budgie"): - os.system("budgie-session --logout") - elif env.startswith("lxqt"): - os.system("lxqt-leave --logout ") - elif env.startswith("gnome") or env.startswith("pantheon") or env.startswith("unity"): - os.system("gnome-session-quit --logout --no-prompt") - elif env.startswith("i3"): - os.system("i3-msg exit") - else: - message = "It seems you're running an unsupported Desktop Environment. " + \ - "Please manually log out and then log in again to complete the switch." - dialog = Gtk.MessageDialog(None, Gtk.DIALOG_MODAL, Gtk.MESSAGE_ERROR, Gtk.BUTTONS_OK, message) - dialog.set_deletable(False) - dialog.run() - restart() + def reboot(self): + os.system("reboot") + restart() def renderer_string(self) -> str: out = subprocess.getoutput("glxinfo | grep 'OpenGL renderer string'") # type:str @@ -314,15 +286,15 @@ class Indicator: def show_reboot_dialog(self): msg_nvidia = "dedicated NVIDIA GPU" msg_intel = "integrated Intel GPU" - message = "You need to log out to switch from the " + \ + message = "You need to reboot to switch from the " + \ (msg_intel if (self.active_gpu == INTEL) else msg_nvidia) + \ " to the " + (msg_nvidia if (self.active_gpu == INTEL) else msg_intel) + \ - ". Save your work before clicking the Log Out button below." + ". Save your work before clicking the reboot button below." dialog = Gtk.MessageDialog(None, Gtk.DialogFlags.MODAL, Gtk.MessageType.INFO, Gtk.ButtonsType.NONE, message) dialog.set_deletable(False) dialog.connect("delete_event", self.ignore) - dialog.add_button("Log Out", Gtk.ResponseType.OK) + dialog.add_button("Reboot", Gtk.ResponseType.OK) dialog.add_button(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL) response = dialog.run() dialog.destroy() @@ -332,7 +304,7 @@ class Indicator: response = self.show_reboot_dialog() if response != Gtk.ResponseType.CANCEL: self.switch_gpu() - self.logout() + self.reboot() def kill_other_instances() -> None: From 7ceecdb38509cf5cedcc7e4e4b8d44fb0bf29409 Mon Sep 17 00:00:00 2001 From: Aaahh Date: Sun, 20 May 2018 15:44:59 -0400 Subject: [PATCH 2/2] Upadte for prime-select 0.8.8 --- usr/lib/prime-indicator/gpuswitcher | 7 ------- usr/lib/prime-indicator/prime-indicator | 4 ++-- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/usr/lib/prime-indicator/gpuswitcher b/usr/lib/prime-indicator/gpuswitcher index 4834eb1..5b6defc 100755 --- a/usr/lib/prime-indicator/gpuswitcher +++ b/usr/lib/prime-indicator/gpuswitcher @@ -26,12 +26,5 @@ else then prime-select nvidia &>/dev/null sync - elif [[ $2 == "on" ]] - then - modprobe nvidia_drm nvidia_modeset nvidia_uvm nvidia &>/dev/null - tee /proc/acpi/bbswitch <<< ON &>/dev/null - else - rmmod nvidia_drm nvidia_modeset nvidia_uvm nvidia &>/dev/null - tee /proc/acpi/bbswitch <<< OFF &>/dev/null fi fi diff --git a/usr/lib/prime-indicator/prime-indicator b/usr/lib/prime-indicator/prime-indicator index afcde5e..f92a819 100755 --- a/usr/lib/prime-indicator/prime-indicator +++ b/usr/lib/prime-indicator/prime-indicator @@ -255,8 +255,8 @@ class Indicator: return "Force NVIDIA GPU to " + ("power OFF" if self.is_nvidia_on() else "power ON") def is_nvidia_on(self) -> bool: - out = subprocess.getoutput("cat /proc/acpi/bbswitch") - return out.lower().endswith("on") + out = subprocess.getoutput("cat /sys/kernel/debug/vgaswitcheroo/switch") + return "DIS: :Off" in out def switch_gpu(self) -> None: if self.active_gpu in [INTEL, NVIDIA]: