This repository has been archived by the owner on Oct 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
prime-switch
executable file
·70 lines (68 loc) · 2.16 KB
/
prime-switch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/bash
has_prime_select=false
if command -v zenity &> /dev/null; then
dialog_helper=zenity
elif command -v kdialog &> /dev/null; then
dialog_helper=kdialog
fi
($(exec prime-test))
case $? in
0)
has_prime_select=true
;;
esac
if $has_prime_select; then
current=($(exec /usr/sbin/prime-select get-current))
driver=${current[2]}
case $driver in
intel)
case $dialog_helper in
zenity)
selected=$(zenity --list --radiolist --column="" --column="Title" --hide-header FALSE "offload" FALSE "nvidia" --hide-header --text="$(exec prime-i18n ToggleOffload)" --title="$(exec prime-i18n TitleSelect)")
;;
kdialog)
selected=$(kdialog --radiolist "$(exec prime-i18n BootDriver)" "offload" "offload" off "nvidia" "nvidia" off)
;;
esac
;;
nvidia)
case $dialog_helper in
zenity)
selected=$(zenity --list --radiolist --column="" --column="Title" --hide-header FALSE "offload" FALSE "intel" --hide-header --text="$(exec prime-i18n ToggleOffload)" --title="$(exec prime-i18n TitleSelect)")
;;
kdialog)
selected=$(kdialog --radiolist "$(exec prime-i18n BootDriver)" "offload" "offload" off "intel" "intel" off)
;;
esac
;;
offload)
case $dialog_helper in
zenity)
selected=$(zenity --list --radiolist --column="" --column="Title" --hide-header FALSE "nvidia" FALSE "intel" --hide-header --text="$(exec prime-i18n ToggleOffload)" --title="$(exec prime-i18n TitleSelect)")
;;
kdialog)
selected=$(kdialog --radiolist "$(exec prime-i18n BootDriver)" "nvidia" "nvidia" off "intel" "intel" off)
;;
esac
;;
esac
case $? in
0)
pkexec /usr/sbin/prime-select $selected
case $? in
0)
case $dialog_helper in
zenity)
zenity --info --title="Logout" --text="$(prime-i18n Logout)."
gnome-session-quit --logout
;;
kdialog)
kdialog --msgbox "$(exec prime-i18n TitleSuccess)" --title="Logout"
qdbus org.kde.ksmserver /KSMServer logout 1 0 3
;;
esac
;;
esac
;;
esac
fi