Skip to content
This repository has been archived by the owner on Oct 27, 2019. It is now read-only.

[DO NOT MERGE] Update for 0.8.8 #35

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
7 changes: 0 additions & 7 deletions usr/lib/prime-indicator/gpuswitcher
Original file line number Diff line number Diff line change
Expand Up @@ -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
46 changes: 9 additions & 37 deletions usr/lib/prime-indicator/prime-indicator
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -283,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
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be "not in", or should change "Off" to the opposite which I believe is "Pwr" but I need to confirm


def switch_gpu(self) -> None:
if self.active_gpu in [INTEL, NVIDIA]:
Expand Down Expand Up @@ -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()
Expand All @@ -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:
Expand Down