1+ """
2+ ##########################################################################
3+ *
4+ * Copyright © 2019-2021 Akashdeep Dhar <[email protected] > 5+ *
6+ * This program is free software: you can redistribute it and/or modify
7+ * it under the terms of the GNU General Public License as published by
8+ * the Free Software Foundation, either version 3 of the License, or
9+ * (at your option) any later version.
10+ *
11+ * This program is distributed in the hope that it will be useful,
12+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+ * GNU General Public License for more details.
15+ *
16+ * You should have received a copy of the GNU General Public License
17+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
18+ *
19+ ##########################################################################
20+ """
21+
122import os
223import subprocess
324import sys
@@ -179,6 +200,23 @@ def main(self):
179200 return data == 0
180201
181202
203+ class CollPrimeSupportEnabler (object ):
204+ def main (self , opts ):
205+ try :
206+ with open ("/usr/share/X11/xorg.conf.d/nvidia.conf" , "r" ) as sharconf :
207+ shardata = sharconf .read ()
208+ primemod = ""
209+ for indx in shardata .split ("\n " ):
210+ primemod += indx + "\n "
211+ if opts is True and indx == "\t Option \" BaseMosaic\" \" on\" " :
212+ primemod += "\t Option \" PrimaryGPU\" \" yes\" " + "\n "
213+ with open ("/etc/X11/xorg.conf.d/nvidia.conf" , "w" ) as etcdconf :
214+ etcdconf .write (primemod )
215+ return True
216+ except Exception :
217+ return False
218+
219+
182220SupportCheck = CollSupportCheck ()
183221RPMFHandler = CollRPMFHandler ()
184222DriverInstaller = CollDriverInstaller ()
@@ -188,6 +226,7 @@ def main(self):
188226VidAccInstaller = CollVidAccInstaller ()
189227VulkanInstaller = CollVulkanInstaller ()
190228SuperuserCheck = CollSuperuserCheck ()
229+ PrimeSupportEnabler = CollPrimeSupportEnabler ()
191230
192231
193232class InstallationMode (object ):
@@ -204,6 +243,7 @@ def __init__(self):
204243 "--getall " : "This mode installs all the above packages." ,
205244 "--cheksu " : "This mode allows you to check the user privilege level." ,
206245 "--compat " : "This mode allows you to check your compatibility." ,
246+ "--primec " : "This mode allows you to setup PRIME configuration." ,
207247 "--version" : "Show the version and exit." ,
208248 "--help " : "Show this message and exit." ,
209249 }
@@ -555,6 +595,56 @@ def compat(self):
555595 DecoratorObject .failure_message ("Leaving installer" )
556596 sys .exit (0 )
557597
598+ def primec (self ):
599+ DecoratorObject .section_heading ("CHECKING SUPERUSER PERMISSIONS..." )
600+ if SuperuserCheck .main ():
601+ DecoratorObject .success_message ("Superuser privilege acquired" )
602+ DecoratorObject .section_heading ("CHECKING AVAILABILITY OF RPM FUSION NVIDIA REPOSITORY..." )
603+ if RPMFHandler .avbl ():
604+ DecoratorObject .warning_message ("RPM Fusion repository for Proprietary NVIDIA Driver was detected" )
605+ DecoratorObject .section_heading ("ATTEMPTING CONNECTION TO RPM FUSION SERVERS..." )
606+ if RPMFHandler .conn ():
607+ DecoratorObject .success_message ("Connection to RPM Fusion servers was established" )
608+ DecoratorObject .section_heading ("LOOKING FOR EXISTING DRIVER PACKAGES..." )
609+ data = DriverInstaller .avbl ()
610+ if data is False :
611+ DecoratorObject .failure_message ("No existing NVIDIA driver packages were detected" )
612+ else :
613+ qant = 0
614+ for indx in data :
615+ if indx != "" :
616+ qant += 1
617+ DecoratorObject .general_message (indx )
618+ DecoratorObject .warning_message ("A total of " + str (qant ) + " driver packages were detected" )
619+ DecoratorObject .section_heading ("SETTING UP PRIME SUPPORT..." )
620+ DecoratorObject .warning_message ("Intervention required" )
621+ DecoratorObject .general_message (click .style ("< Y >" , fg = "green" , bold = True ) + " to enable PRIME support" )
622+ DecoratorObject .general_message (click .style ("< N >" , fg = "red" , bold = True ) + " to disable PRIME support" )
623+ DecoratorObject .general_message (click .style ("< * >" , fg = "yellow" , bold = True ) + " anything else to leave" )
624+ solution = input ("[Y/N] " )
625+ if solution == "Y" or solution == "y" :
626+ DecoratorObject .section_heading ("ENABLING PRIME SUPPORT..." )
627+ if PrimeSupportEnabler .main (True ):
628+ DecoratorObject .success_message ("PRIME Support was successfully enabled" )
629+ else :
630+ DecoratorObject .failure_message ("PRIME Support could not be enabled" )
631+ elif solution == "N" or solution == "n" :
632+ DecoratorObject .section_heading ("DISABLING PRIME SUPPORT..." )
633+ if PrimeSupportEnabler .main (False ):
634+ DecoratorObject .success_message ("PRIME Support was successfully disabled" )
635+ else :
636+ DecoratorObject .failure_message ("PRIME Support could not be disabled" )
637+ else :
638+ DecoratorObject .section_heading ("SAFE AND GOOD ANSWER..." )
639+ else :
640+ DecoratorObject .failure_message ("Connection to RPM Fusion servers could not be established" )
641+ else :
642+ DecoratorObject .failure_message ("RPM Fusion repository for Proprietary NVIDIA Driver was not detected" )
643+ else :
644+ DecoratorObject .failure_message ("Superuser privilege could not be acquired" )
645+ DecoratorObject .failure_message ("Leaving installer" )
646+ sys .exit (0 )
647+
558648 def lsmenu (self ):
559649 DecoratorObject .section_heading ("OPTIONS" )
560650 for indx in self .menudict .keys ():
@@ -563,33 +653,115 @@ def lsmenu(self):
563653
564654
565655@click .command ()
566- @click .option ("--rpmadd" , "instmode" , flag_value = "rpmadd" , help = "This mode enables the RPM Fusion NVIDIA drivers repository" )
567- @click .option ("--driver" , "instmode" , flag_value = "driver" , help = "This mode simply installs the NVIDIA driver" )
568- @click .option ("--x86lib" , "instmode" , flag_value = "x86lib" , help = "This mode installs only the x86 libraries for Xorg" )
569- @click .option ("--nvrepo" , "instmode" , flag_value = "nvrepo" , help = "This mode enables the Official NVIDIA repository for CUDA" )
570- @click .option ("--plcuda" , "instmode" , flag_value = "plcuda" , help = "This mode installs only the CUDA support softwares" )
571- @click .option ("--ffmpeg" , "instmode" , flag_value = "ffmpeg" , help = "This mode installs only the FFMPEG acceleration" )
572- @click .option ("--vulkan" , "instmode" , flag_value = "vulkan" , help = "This mode installs only the Vulkan renderer" )
573- @click .option ("--vidacc" , "instmode" , flag_value = "vidacc" , help = "This mode installs only the VDPAU/VAAPI acceleration" )
574- @click .option ("--getall" , "instmode" , flag_value = "getall" , help = "This mode installs all the above packages" )
575- @click .option ("--cheksu" , "instmode" , flag_value = "cheksu" , help = "This mode allows you to check the user privilege level" )
576- @click .option ("--compat" , "instmode" , flag_value = "compat" , help = "This mode allows you to check your compatibility" )
577- @click .version_option (version = __version__ , prog_name = click .style ("NVAutoInstall by Akashdeep Dhar <[email protected] >" , fg = "green" , bold = True )) 656+ @click .option (
657+ "--rpmadd" ,
658+ "instmode" ,
659+ flag_value = "rpmadd" ,
660+ help = "This mode enables the RPM Fusion NVIDIA drivers repository."
661+ )
662+ @click .option (
663+ "--driver" ,
664+ "instmode" ,
665+ flag_value = "driver" ,
666+ help = "This mode simply installs the NVIDIA driver."
667+ )
668+ @click .option (
669+ "--x86lib" ,
670+ "instmode" ,
671+ flag_value = "x86lib" ,
672+ help = "This mode installs only the x86 libraries for Xorg."
673+ )
674+ @click .option (
675+ "--nvrepo" ,
676+ "instmode" ,
677+ flag_value = "nvrepo" ,
678+ help = "This mode enables the Official NVIDIA repository for CUDA."
679+ )
680+ @click .option (
681+ "--plcuda" ,
682+ "instmode" ,
683+ flag_value = "plcuda" ,
684+ help = "This mode installs only the CUDA support softwares."
685+ )
686+ @click .option (
687+ "--ffmpeg" ,
688+ "instmode" ,
689+ flag_value = "ffmpeg" ,
690+ help = "This mode installs only the FFMPEG acceleration."
691+ )
692+ @click .option (
693+ "--vulkan" ,
694+ "instmode" ,
695+ flag_value = "vulkan" ,
696+ help = "This mode installs only the Vulkan renderer."
697+ )
698+ @click .option (
699+ "--vidacc" ,
700+ "instmode" ,
701+ flag_value = "vidacc" ,
702+ help = "This mode installs only the VDPAU/VAAPI acceleration."
703+ )
704+ @click .option (
705+ "--getall" ,
706+ "instmode" ,
707+ flag_value = "getall" ,
708+ help = "This mode installs all the above packages."
709+ )
710+ @click .option (
711+ "--cheksu" ,
712+ "instmode" ,
713+ flag_value = "cheksu" ,
714+ help = "This mode allows you to check the user privilege level."
715+ )
716+ @click .option (
717+ "--compat" ,
718+ "instmode" ,
719+ flag_value = "compat" ,
720+ help = "This mode allows you to check your compatibility."
721+ )
722+ @click .option (
723+ "--primec" ,
724+ "instmode" ,
725+ flag_value = "primec" ,
726+ help = "This mode allows you to setup PRIME configuration."
727+ )
728+ @click .version_option (
729+ version = __version__ ,
730+ prog_name = click .style (
731+ "NVAutoInstall by Akashdeep Dhar <[email protected] >" , 732+ fg = "green" ,
733+ bold = True
734+ )
735+ )
578736def clim (instmode ):
579737 instobjc = InstallationMode ()
580738 click .echo (click .style ("[ # ] NVIDIA AUTOINSTALLER FOR FEDORA" , fg = "green" , bold = True ))
581- if instmode == "rpmadd" : instobjc .rpmadd ()
582- elif instmode == "driver" : instobjc .driver ()
583- elif instmode == "x86lib" : instobjc .x86lib ()
584- elif instmode == "nvrepo" : instobjc .nvrepo ()
585- elif instmode == "plcuda" : instobjc .plcuda ()
586- elif instmode == "ffmpeg" : instobjc .ffmpeg ()
587- elif instmode == "vulkan" : instobjc .vulkan ()
588- elif instmode == "vidacc" : instobjc .vidacc ()
589- elif instmode == "getall" : instobjc .getall ()
590- elif instmode == "cheksu" : instobjc .cheksu ()
591- elif instmode == "compat" : instobjc .compat ()
592- else : instobjc .lsmenu ()
739+ if instmode == "rpmadd" :
740+ instobjc .rpmadd ()
741+ elif instmode == "driver" :
742+ instobjc .driver ()
743+ elif instmode == "x86lib" :
744+ instobjc .x86lib ()
745+ elif instmode == "nvrepo" :
746+ instobjc .nvrepo ()
747+ elif instmode == "plcuda" :
748+ instobjc .plcuda ()
749+ elif instmode == "ffmpeg" :
750+ instobjc .ffmpeg ()
751+ elif instmode == "vulkan" :
752+ instobjc .vulkan ()
753+ elif instmode == "vidacc" :
754+ instobjc .vidacc ()
755+ elif instmode == "getall" :
756+ instobjc .getall ()
757+ elif instmode == "cheksu" :
758+ instobjc .cheksu ()
759+ elif instmode == "compat" :
760+ instobjc .compat ()
761+ elif instmode == "primec" :
762+ instobjc .primec ()
763+ else :
764+ instobjc .lsmenu ()
593765
594766
595767if __name__ == "__main__" :
0 commit comments