Hello community,
here is the log from the commit of package suse-prime for openSUSE:Factory checked in at 2019-10-03 14:10:23
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/suse-prime (Old)
and /work/SRC/openSUSE:Factory/.suse-prime.new.2352 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "suse-prime"
Thu Oct 3 14:10:23 2019 rev:10 rq:734774 version:0.7
Changes:
--------
--- /work/SRC/openSUSE:Factory/suse-prime/suse-prime.changes 2019-05-22 15:41:23.478427228 +0200
+++ /work/SRC/openSUSE:Factory/.suse-prime.new.2352/suse-prime.changes 2019-10-03 14:10:25.551951152 +0200
@@ -1,0 +2,178 @@
+Wed Oct 2 15:29:37 UTC 2019 - Stefan Dirsch
+
+- Update to version 0.7.0
+ * no changes to 0.6.14 and the patches on top of that we had
+ before ...
+- supersedes patches:
+ * 0001-Implement-and-document-PRIME-Render-Offload-and-Dyna.patch
+ * 0002-Fix-NVIDIA-PRIME-Render-Offload.patch
+ * 0003-prime-select.sh-mention-PRIME-Render-Offload-in-usag.patch
+
+-------------------------------------------------------------------
+Wed Oct 2 13:13:43 UTC 2019 - Stefan Dirsch
+
+- 0001-Implement-and-document-PRIME-Render-Offload-and-Dyna.patch
+ 0002-Fix-NVIDIA-PRIME-Render-Offload.patch
+- 0003-prime-select.sh-mention-PRIME-Render-Offload-in-usag.patch
+ * adds support for NVIDIA PRIME Render Offload of 435.xx/G05 driver
+- add new config files (modprobe.d/dracut.d/udev.d) to package;
+ regenerate initrd during installation and also during update of
+ nvidia G05 KMP
+
+-------------------------------------------------------------------
+Wed Jun 26 13:41:03 UTC 2019 - Stefan Dirsch
+
+- Update to version 0.6.14
+ * changes since 0.6.11
+ + fix Plasma scaling for laptop panel when changing driver;
+ see comment in function update_kdeglobals for details
+ + fixed issues when switching with Xorg started with
+ startx/xinit (multi-user.target)
+ + fixed issues when switching from console
+ + replaced usage of runlevel command by use of systemctl to
+ determine current target. runlevel did not always
+ + returns a defined runlevel and caused a bash error (on first
+ script run)
+ + made grepping for xinit process more strict
+ + fixed issue where 'prime-select user_logout_waiter'
+ execution would not exit for a while after switching
+ + Fix check for existing NVIDIA GPU
+
+-------------------------------------------------------------------
+Wed May 22 08:47:20 UTC 2019 - Stefan Dirsch
+
+- renamed package to suse-prime-beta
+
+-------------------------------------------------------------------
+Tue Apr 23 13:02:27 UTC 2019 - Stefan Dirsch
+
+- exit successfully from pre/post/preun/postun scripts in order to
+ prevent build fails ...
+
+-------------------------------------------------------------------
+Mon Apr 8 12:39:13 UTC 2019 - Stefan Dirsch
+
+- Update to version 0.6.11
+ * Allow to work without service
+ + work without bbswitch if prime-select.service is not installed (for
+ suse-prime package)
+ + cleaned up script usage, only displays relevant commands
+ + service, boot and next-boot commands are not available if running without
+ service
+ + handle the case when booting with nvidia config but no nvidia card is available
+ (disabled in BIOS) by forcing intel. Only works if service is running
+ + replaced shell commands using backquotes with more modern $() for consistency
+ + when appropriate, changed nvidia => NVIDIA for consistency
+ + reindented script with emacs for consistency
+ + minor updates to README
+ * Add 30s timeout to service to make sure system boots if service doesnt work.
+
+-------------------------------------------------------------------
+Wed Apr 3 09:42:22 UTC 2019 - Stefan Dirsch
+
+- Update to version 0.6.9
+ * Resolved issue with plymouth (it hangs during boot)
+ * Updated readme
+
+-------------------------------------------------------------------
+Mon Apr 1 18:11:12 UTC 2019 - Mykola Krachkovsky
+
+- Repair broken suse-prime-bbswitch package
+
+-------------------------------------------------------------------
+Mon Apr 1 14:03:36 UTC 2019 - Stefan Dirsch
+
+- Update to version 0.6.8
+ * Big Update (changes in systemd services)
+ + prime-boot-selector service deprecated, all features are
+ now handled with one only service.
+ + used journalctl to check if system is booting or if
+ "logout-switch" is needed
+ + no more multiple service enable/disable needed during
+ switch, prime-select service is enabled everytime
+ + removed all "prime-boot-selector" references in logging
+ and help command
+ + boot_status file has now only two states (S > wait for
+ switching, N > not waiting)
+ + changed systemd call from "prime-select apply_current"
+ to "prime-select systemd_call"
+ + updated README
+
+-------------------------------------------------------------------
+Mon Apr 1 14:03:36 UTC 2019 - Stefan Dirsch
+
+- Update to version 0.6.7
+ * Corrected DPI value in xorg-nvidia.conf (boo#1130723)
+
+-------------------------------------------------------------------
+Mon Apr 1 14:03:36 UTC 2019 - Stefan Dirsch
+
+- Update to version 0.6.6
+ * Add logging to journal as well
+
+-------------------------------------------------------------------
+Mon Apr 1 14:03:36 UTC 2019 - Stefan Dirsch
+
+- Split power support into separate package suse-prime-bbswitch
+ which don't need manual work
+
+-------------------------------------------------------------------
+Mon Apr 1 14:03:36 UTC 2019 - Stefan Dirsch
+
+- Update to version 0.6.5
+ * augmented README
+ * do not mention "intel" driver issue with kwin since it is obsolete
+ * improved "intel" xorg config to work properly with compositors
+
+-------------------------------------------------------------------
+Mon Apr 1 14:03:36 UTC 2019 - Stefan Dirsch
+
+- Update to version 0.6.4
+ * added support for xdm and kdm
+ * removed useless "sudo" in journalctl calls
+
+-------------------------------------------------------------------
+Mon Apr 1 14:03:36 UTC 2019 - Stefan Dirsch
+
+- Update to version 0.6.3
+ * Best DM support (lightdm added)
+
+-------------------------------------------------------------------
+Mon Apr 1 14:03:36 UTC 2019 - Stefan Dirsch
+
+- Update to version 0.6.2
+ - fixes all known issues with GDM, runlevel 3 and manually-started
+ x sessions
+ * Xorg logfile comparision no longer necessary, let's use
+ journalctl to check user logout
+ * other DM(s) than sddm/gdm will be implemented in the future
+
+-------------------------------------------------------------------
+Mon Apr 1 14:03:36 UTC 2019 - Stefan Dirsch
+
+- Update to version 0.6.1
+ * mainly bugfixes
+- supersedes 0001-Resolved-multiple-unexistent-file-error.patch
+
+-------------------------------------------------------------------
+Mon Apr 1 14:03:36 UTC 2019 - Stefan Dirsch
+
+- Update to version 0.6
+ * new systemd service file prime-boot-selector in addition to prime-select
+ + Service prime-select chooses with whatever driver was previously set by user.
+ + Service prime-boot-selector sets all things during boot [MUST BE ENABLED]
+ * new prime-select command options
+ + prime-select boot intel|intel2|nvidia|last
+ + prime-select next-boot intel|intel2|nvidia|abort
+ + prime-select service check|disable|restore
+- 0001-Resolved-multiple-unexistent-file-error.patch (post 0.6)
+ * Resolved multiple unexistent file errors
+ * Resolved a big issue in switch command if prime_logfile doesn't exist,
+ file check added
+ * Added non existent file handling in various parts of script (next-boot,
+ log-view, unset, current_check) Those issues manifested themselves
+ after a fresh installation, because some config files still were not
+ present
+- supersedes U_Corrected-DPI-value-in-xorg-nvidia.conf.patch
+
+-------------------------------------------------------------------
Old:
----
SUSEPrime-0.5.tar.gz
U_Corrected-DPI-value-in-xorg-nvidia.conf.patch
New:
----
SUSEPrime-0.7.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ suse-prime.spec ++++++
--- /var/tmp/diff_new_pack.Ftqr1q/_old 2019-10-03 14:10:26.035949907 +0200
+++ /var/tmp/diff_new_pack.Ftqr1q/_new 2019-10-03 14:10:26.039949897 +0200
@@ -12,22 +12,22 @@
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
-# Please submit bugfixes or comments via http://bugs.opensuse.org/
+# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
Name: suse-prime
-Version: 0.5
+Version: 0.7
Release: 0
Summary: GPU (nvidia/intel) selection for NVIDIA optimus laptops
License: SUSE-Public-Domain
Group: System/X11/Utilities
Url: https://github.com/openSUSE/SUSEPrime
Source0: https://github.com/openSUSE/SUSEPrime/archive/%{version}.tar.gz#/SUSEPrime-%{version}.tar.gz
-Patch0: U_Corrected-DPI-value-in-xorg-nvidia.conf.patch
Recommends: nvidia_driver
Supplements: modalias(nvidia_driver:pci:v00008086d*sv*sd*bc03sc*i*)
Conflicts: suse-prime-alt
+Conflicts: suse-prime-bbswitch
BuildArch: noarch
%description
@@ -35,9 +35,24 @@
NVIDIA GPU on a Optimus Laptop. The switching is similar to
the feature provided by the nvidia-prime package in Ubuntu.
+%package bbswitch
+Summary: GPU (nvidia/intel) selection for NVIDIA optimus laptops with bbswitch support
+Group: System/X11/Utilities
+BuildRequires: systemd
+Requires: bbswitch
+Conflicts: suse-prime
+Conflicts: suse-prime-alt
+BuildArch: noarch
+%{?systemd_requires}
+
+%description bbswitch
+A collection of shell scripts that makes it possible to use the
+NVIDIA GPU on a Optimus Laptop. The switching is similar to
+the feature provided by the nvidia-prime package in Ubuntu.
+Uses bbswitch to switch on/of power of NVIDIA GPU.
+
%prep
%setup -n SUSEPrime-%{version}
-%patch0 -p1
%build
:
@@ -47,27 +62,94 @@
install -m 0644 xorg-intel.conf %{buildroot}%{_sysconfdir}/prime/
install -m 0644 xorg-intel-intel.conf %{buildroot}%{_sysconfdir}/prime/
install -m 0644 xorg-nvidia.conf %{buildroot}%{_sysconfdir}/prime/
-install -m 0644 09-nvidia-blacklist.conf %{buildroot}%{_sysconfdir}/prime/
-install -m 0644 prime-select.service %{buildroot}%{_sysconfdir}/prime/
+mkdir -p %{buildroot}%{_sysconfdir}/modprobe.d
+install -m 0644 09-nvidia-modprobe-bbswitch-G04.conf %{buildroot}%{_sysconfdir}/modprobe.d/
+install -m 0644 09-nvidia-modprobe-pm-G05.conf %{buildroot}%{_sysconfdir}/modprobe.d/
+mkdir -p %{buildroot}%{_unitdir}
+install -m 0644 prime-select.service %{buildroot}%{_unitdir}/
echo "undefined" > %{buildroot}%{_sysconfdir}/prime/current_type
install -D -m 0755 prime-select.sh %{buildroot}%{_sbindir}/prime-select
+mkdir -p %{buildroot}/usr/lib/dracut/dracut.conf.d/
+install -m 0644 90-nvidia-dracut-G05.conf %{buildroot}/usr/lib/dracut/dracut.conf.d/
+mkdir -p %{buildroot}/usr/lib/udev/rules.d
+install -m 0644 90-nvidia-udev-pm-G05.rules %{buildroot}/usr/lib/udev/rules.d
+mkdir -p %{buildroot}/usr/sbin
+ln -snf service %{buildroot}/usr/sbin/rcprime-select
%preun
if [ "$1" -eq 0 ]; then
# cleanup before uninstalling the package completely
+ export PATH=$PATH:/usr/sbin
+ %{_sbindir}/prime-select unset
+fi
+exit 0
+
+%postun
+if [ "$1" -eq 0 ]; then
+ # regenerate initrd without any suse-prime modprobe config files
+ test -x /sbin/mkinitrd && /sbin/mkinitrd
+fi
+exit 0
+
+%triggerin -- nvidia-gfxG05-kmp-default
+# get rid of nvidia kernel modules in initrd
+rm -f /etc/dracut.conf.d/50-nvidia-default.conf
+test -x /sbin/mkinitrd && /sbin/mkinitrd
+exit 0
+
+%pre bbswitch
+%service_add_pre prime-select.service
+exit 0
+
+%post bbswitch
+%{?regenerate_initrd_post}
+%service_add_post prime-select.service
+systemctl enable prime-select.service
+exit 0
+
+%preun bbswitch
+%service_del_preun prime-select.service
+if [ "$1" -eq 0 ]; then
+ # cleanup before uninstalling the package completely
+ export PATH=$PATH:/usr/sbin
%{_sbindir}/prime-select unset
fi
+exit 0
+
+%postun bbswitch
+%{?regenerate_initrd_post}
+%service_del_postun prime-select.service
+exit 0
+
+%posttrans bbswitch
+%{?regenerate_initrd_posttrans}
+exit 0
%files
%defattr(-,root,root)
%doc README.md
+%dir /usr/lib/dracut/
+%dir /usr/lib/dracut/dracut.conf.d/
+%{_sysconfdir}/prime
+%config %{_sysconfdir}/prime/xorg-intel.conf
+%config %{_sysconfdir}/prime/xorg-intel-intel.conf
+%config %{_sysconfdir}/prime/xorg-nvidia.conf
+%config(noreplace) %{_sysconfdir}/prime/current_type
+%{_sbindir}/prime-select
+%config %{_sysconfdir}/modprobe.d/09-nvidia-modprobe-pm-G05.conf
+/usr/lib/dracut/dracut.conf.d/90-nvidia-dracut-G05.conf
+/usr/lib/udev/rules.d/90-nvidia-udev-pm-G05.rules
+
+%files bbswitch
+%doc README.md
%{_sysconfdir}/prime
%config %{_sysconfdir}/prime/xorg-intel.conf
%config %{_sysconfdir}/prime/xorg-intel-intel.conf
%config %{_sysconfdir}/prime/xorg-nvidia.conf
-%config %{_sysconfdir}/prime/09-nvidia-blacklist.conf
-%config %{_sysconfdir}/prime/prime-select.service
%config(noreplace) %{_sysconfdir}/prime/current_type
%{_sbindir}/prime-select
+%{_sbindir}/rcprime-select
+%config %{_sysconfdir}/modprobe.d/09-nvidia-modprobe-bbswitch-G04.conf
+%{_unitdir}/prime-select.service
%changelog
++++++ SUSEPrime-0.5.tar.gz -> SUSEPrime-0.7.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/SUSEPrime-0.5/09-nvidia-blacklist.conf new/SUSEPrime-0.7/09-nvidia-blacklist.conf
--- old/SUSEPrime-0.5/09-nvidia-blacklist.conf 2019-01-24 21:08:13.000000000 +0100
+++ new/SUSEPrime-0.7/09-nvidia-blacklist.conf 1970-01-01 01:00:00.000000000 +0100
@@ -1,5 +0,0 @@
-blacklist nvidia
-blacklist nvidia-drm
-blacklist nvidia-modeset
-blacklist nouveau
-options nvidia-drm modeset=1
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/SUSEPrime-0.5/09-nvidia-modprobe-bbswitch-G04.conf new/SUSEPrime-0.7/09-nvidia-modprobe-bbswitch-G04.conf
--- old/SUSEPrime-0.5/09-nvidia-modprobe-bbswitch-G04.conf 1970-01-01 01:00:00.000000000 +0100
+++ new/SUSEPrime-0.7/09-nvidia-modprobe-bbswitch-G04.conf 2019-10-02 17:22:32.000000000 +0200
@@ -0,0 +1,5 @@
+blacklist nvidia
+blacklist nvidia-drm
+blacklist nvidia-modeset
+blacklist nouveau
+options nvidia-drm modeset=1
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/SUSEPrime-0.5/09-nvidia-modprobe-pm-G05.conf new/SUSEPrime-0.7/09-nvidia-modprobe-pm-G05.conf
--- old/SUSEPrime-0.5/09-nvidia-modprobe-pm-G05.conf 1970-01-01 01:00:00.000000000 +0100
+++ new/SUSEPrime-0.7/09-nvidia-modprobe-pm-G05.conf 2019-10-02 17:22:32.000000000 +0200
@@ -0,0 +1 @@
+options nvidia NVreg_DynamicPowerManagement=0x02
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/SUSEPrime-0.5/90-nvidia-dracut-G05.conf new/SUSEPrime-0.7/90-nvidia-dracut-G05.conf
--- old/SUSEPrime-0.5/90-nvidia-dracut-G05.conf 1970-01-01 01:00:00.000000000 +0100
+++ new/SUSEPrime-0.7/90-nvidia-dracut-G05.conf 2019-10-02 17:22:32.000000000 +0200
@@ -0,0 +1,5 @@
+# Omit the nvidia driver from the ramdisk, to avoid needing to regenerate
+# the ramdisk on updates, and to ensure the power-management udev rules run
+# on module load
+omit_drivers+=" nvidia nvidia-drm nvidia-modeset nvidia-uvm "
+
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/SUSEPrime-0.5/90-nvidia-udev-pm-G05.rules new/SUSEPrime-0.7/90-nvidia-udev-pm-G05.rules
--- old/SUSEPrime-0.5/90-nvidia-udev-pm-G05.rules 1970-01-01 01:00:00.000000000 +0100
+++ new/SUSEPrime-0.7/90-nvidia-udev-pm-G05.rules 2019-10-02 17:22:32.000000000 +0200
@@ -0,0 +1,23 @@
+# Remove NVIDIA USB xHCI Host Controller devices, if present
+ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}==
+"0x0c0330", ATTR{remove}="1"
+
+# Remove NVIDIA USB Type-C UCSI devices, if present
+ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}==
+"0x0c8000", ATTR{remove}="1"
+
+# Remove NVIDIA Audio devices, if present
+ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}==
+"0x040300", ATTR{remove}="1"
+
+# Enable runtime PM for NVIDIA VGA/3D controller devices on driver bind
+ACTION=="bind", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}==
+"0x030000", TEST=="power/control", ATTR{power/control}="auto"
+ACTION=="bind", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}==
+"0x030200", TEST=="power/control", ATTR{power/control}="auto"
+
+# Disable runtime PM for NVIDIA VGA/3D controller devices on driver unbind
+ACTION=="unbind", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}==
+"0x030000", TEST=="power/control", ATTR{power/control}="on"
+ACTION=="unbind", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}==
+"0x030200", TEST=="power/control", ATTR{power/control}="on"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/SUSEPrime-0.5/README.md new/SUSEPrime-0.7/README.md
--- old/SUSEPrime-0.5/README.md 2019-01-24 21:08:13.000000000 +0100
+++ new/SUSEPrime-0.7/README.md 2019-10-02 17:22:32.000000000 +0200
@@ -1,22 +1,22 @@
-OpenSUSE nvidia-prime like package
+openSUSE nvidia-prime like package
==================================
Assumptions
-----------
-* You are running OpenSUSE Tumbleweed
+* You are running openSUSE Tumbleweed
* You don't have bumblebee installed
-* You installed nvidia drivers using http://opensuse-community.org/nvidia.ymp
+* You installed NVIDIA drivers using http://opensuse-community.org/nvidia.ymp
Installation/usage
------------------
-1. Run "prime-select nvidia" log out and login again, hopefully you are
- using nvidia GPU. To switch back to intel GPU run "prime-select intel" (modesetting driver) or
- "prime-select intel2" (Intel Open Source driver, requires xf86-video-intel package).
- Remember to run as root.
-2. To check which GPU you're currently using run "prime-select get-current".
-3. In intel configurations, powering off the NVIDIA card with bbswitch to save power and decrease temperature is supported but requires additional manual setup. Refer to instructions below.
+1. Run `sudo prime-select nvidia` log out and login again, hopefully you are
+ using the NVIDIA card. To switch back to te Intel card run `sudo prime-select intel` (modesetting driver) or
+ `sudo prime-select intel2` (Intel Open Source driver, requires xf86-video-intel package).
+2. To check which video card you're currently using run `/usr/sbin/prime-select get-current`.
+3. On intel configurations, powering off the NVIDIA card with bbswitch (legacy 390.xxx driver) or DynamicPowerManagement option (current 435.xx driver) to save power and decrease temperature is supported but requires additional manual setup. Refer to instructions below.
+4. With current 435.xx driver you can make use of NVIDIA's PRIME Render Offload feature in intel configurations. `Option "AllowNVIDIAGPUScreens"` is already taken care of by intel X configs. You only need to set the __NV* environment variables. Check https://download.nvidia.com/XFree86/Linux-x86_64/435.21/README/primerenderof... for more details.
Contact
-------
@@ -24,9 +24,36 @@
* Bo Simonsen
* Michal Srb
+Related projects
+----------------
-NVIDIA power off support
--------------------------
+* SUSEPrimeQT https://github.com/simopil/SUSEPrimeQt/ Provides a simple GUI for SUSEPrime
+
+NVIDIA power off support with 435.xxx driver (=G05 driver packages)
+-------------------------------------------------------------------
+
+Recreate your initrd with some special settings, which are needed to enable DynamicPowerManagement and remove NVIDIA kernel modules from initrd, so some special udev rules can be applied to disable NVIDIA Audio and NVIDIA USB and make runtime PM for NVIDIA GPU active. This is needed as workaround, since NVIDIA Audio/USB currently cannot be enabled at the same time as NVIDIA GPU DynamicPowerManagement. This is easily done with:
+
+```
+cp /etc/prime/09-nvidia-modprobe-pm-G05.conf /etc/modprobe.d
+rm /etc/dracut.conf.d/50-nvidia-default.conf
+cp /etc/prime/90-nvidia-dracut-G05.conf /etc/dracut.conf.d/
+cp /etc/prime/90-nvidia-udev-pm-G05.rules /etc/udev/rules.d/
+dracut -f
+```
+
+Unfortunately for now you need to recreate your initrd each time after you updated the nvidia driver packages in that way:
+
+```
+rm /etc/dracut.conf.d/50-nvidia-default.conf
+dracut -f
+```
+
+But we try to get rid of the dracut config file in our nvidia driver
+packages, so hopefully this won't be needed any longer in the future!
+
+NVIDIA power off support with 390.xxx driver (=G04 legacy driver packages)
+--------------------------------------------------------------------------
Powering off the NVIDIA card when not in use is very efficient for significantly decreasing power consumption (thus increase battery life) and temperature. However, this is complicated by the fact that the card can be powered off
only when the NVIDIA kernel modules are not loaded.
@@ -40,74 +67,58 @@
zypper in bbswitch
```
-### Blacklist the nvidia modules so it can be loaded only when necessary
+### Blacklist the NVIDIA modules so it can be loaded only when necessary
The NVIDIA openSUSE package adds the NVIDIA driver modules to the kernel initrd image. This will make the system always load them on boot. This is problematic for disabling the NVIDIA card with bbswitch as it can only turn off the card when the modules are not loaded. Instead of unloading the modules before making use of bbswitch, the reverse is way easier: have the NVIDIA modules always unloaded and load them only when needed.
To prevent the modules from being automatically loaded on boot, we need to blacklist them in initrd.
This is easily done with:
```
-cp /etc/prime/09-nvidia-blacklist.conf /etc/modprobe.d
+cp /etc/prime/09-nvidia-modprobe-bbswitch-G04.conf /etc/modprobe.d
dracut -f
```
This will also blacklist the `nouveau` module which can really get in the way with Optimus and causing black screens.
-### Install the systemd service for loading NVIDIA module when needed
+### Install the systemd services for doing switch and set correct card during boot
```
-cp /etc/prime/prime-select.service /usr/lib/systemd/system
+cp /etc/prime/prime-select.service /usr/lib/systemd/system
systemctl enable prime-select
```
-This service calls prime-select with whatever driver was previously set by user.
-If nvidia is set, it will load the NVIDIA modules before starting the Display Manager (login screen).
+If nvidia is set, it will load the NVIDIA modules before starting the Graphical Target.
Moreover, if an intel config is set but the Intel card was disabled in BIOS (leaving only the dGPU), this service will automatically switch to the nvidia config.
+The reverse is also true (nvidia config set but BIOS configured to use iGPU only).
## FAQ
-### What are the script parameters to select a driver ?
+### How do I select a driver ?
-prime-select `<driver>`
+sudo prime-select `<driver>`
-Where `driver` is one of:
+Where `<driver>` is one of:
-- `intel`: uses the modesetting driver
-- `intel2`: uses the intel driver (xf86-video-intel). If you use Plasma you might get corrupted flickering display. To fix this make sure to disable vsync in the Plasma compositor settings first. Vsync will be handled by the intel driver
-- `nvidia`: use the NVIDIA binary driver
+- `intel`: use the `modesetting` driver (PRIME Render Offload possible with >= 435.xx driver)
+- `intel2`: use the `intel` driver (xf86-video-intel) (PRIME Render Offload possible with >= 435.xx driver)
+- `nvidia`: use the NVIDIA proprietary driver
-### How do I switch from nvidia to intel with NVIDIA power off support ?
-
-
-It requires switching runlevels for the script to be able to remove the NVIDIA modules and power off the card:
-
-Exit Xorg, going into runlevel 3 (multi-user):
-
-```
-
-sudo init 3
-<login as root on console>
-```
-
-Use the script to change driver:
+### How do I check the current driver configured and the power state of the NVIDIA card (390.xxx legacy driver)?
```
-prime-select intel
+/usr/sbin/prime-select get-current
+Driver configured: intel
+[bbswitch] NVIDIA card is OFF
```
-Restart in run level 5 (graphical mode) with the new driver:
+To get more details on the Xorg driver, install package `inxi` if necessary and use `inxi -G`:
```
-init 5
+inxi -G
+Graphics: Device-1: Intel UHD Graphics 630 driver: i915 v: kernel
+ Device-2: NVIDIA GP107GLM [Quadro P600 Mobile] driver: N/A
+ Display: x11 server: X.Org 1.20.4 driver: intel resolution: 3840x2160~60Hz
+ OpenGL: renderer: Mesa DRI Intel UHD Graphics 630 (Coffeelake 3x8 GT2) v: 4.5 Mesa 18.3.4
```
-
-### How to I check that the NVIDIA card is powered off ?
-
-```
-cat /proc/acpi/bbswitch
-0000:01:00.0 OFF
-```
-
-
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/SUSEPrime-0.5/prime-select.service new/SUSEPrime-0.7/prime-select.service
--- old/SUSEPrime-0.5/prime-select.service 2019-01-24 21:08:13.000000000 +0100
+++ new/SUSEPrime-0.7/prime-select.service 2019-10-02 17:22:32.000000000 +0200
@@ -1,10 +1,11 @@
[Unit]
-Description=Prime Select Service
-Before=display-manager.service
+Description=SUSEPrime systemd service
+Before=display-manager.service
[Service]
Type=oneshot
-ExecStart=prime-select apply-current
+ExecStart=prime-select systemd_call
+TimeoutSec=30
[Install]
-WantedBy=graphical.target
+WantedBy=multi-user.target
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/SUSEPrime-0.5/prime-select.sh new/SUSEPrime-0.7/prime-select.sh
--- old/SUSEPrime-0.5/prime-select.sh 2019-01-24 21:08:13.000000000 +0100
+++ new/SUSEPrime-0.7/prime-select.sh 2019-10-02 17:22:32.000000000 +0200
@@ -7,26 +7,79 @@
# Adapted for OpenSUSE Tumbleweed by Michal Srb
# Extended for TUXEDO Computers by Vinzenz Vietzke
# Augmented by bubbleguuum
+# Improved by simopil
type=$1
xorg_nvidia_conf="/etc/prime/xorg-nvidia.conf"
xorg_intel_conf_intel="/etc/prime/xorg-intel.conf"
xorg_intel_conf_intel2="/etc/prime/xorg-intel-intel.conf"
+prime_logfile="/var/log/prime-select.log"
nvidia_modules="nvidia_drm nvidia_modeset nvidia_uvm nvidia"
driver_choices="nvidia|intel|intel2"
lspci_intel_line="VGA compatible controller: Intel"
+lspci_nvidia_vga_line="VGA compatible controller: NVIDIA"
+lspci_nvidia_3d_line="3D controller: NVIDIA"
+
+# name of the laptop panel output as returned by 'xrandr -q'. Driver dependent, because why not
+panel_nvidia=eDP-1-1
+panel_intel=eDP-1
+panel_intel2=eDP1
+
+# Check if prime-select systemd service is present (in that case service_test value is 0)
+# If it is present (suse-prime-bbswitch package), the script assumes that bbswitch is to be used
+# otherwise (suse-prime package) it works without bbswitch
+[ -f /usr/lib/systemd/system/prime-select.service ]
+service_test=$?
function usage {
echo
- echo "usage: `basename $0` $driver_choices|unset|get-current|apply-current"
+ echo "NVIDIA/Intel video card selection for NVIDIA Optimus laptops."
echo
- echo "intel: use the Intel card with the modesetting driver"
- echo "intel2: use the Intel card with the Intel open-source driver (xf86-video-intel). If you use this driver in a Plasma session, make sure to first disable vsync in the Plasma compositor settings to prevent video corruption"
- echo "nvidia: use the NVIDIA binary driver"
- echo "unset: disable effects of this script and let Xorg decide what driver to use"
- echo "get-current: display driver currently in use by this tool"
- echo "apply-current: re-apply this script using previously set driver (used by prime-select systemd service)"
+
+ if (( service_test == 0 )); then
+ echo "usage: $(basename $0) $driver_choices|unset|get-current|get-boot|log-view|log-clean"
+ echo "usage: $(basename $0) boot $driver_choices|last"
+ echo "usage: $(basename $0) next-boot $driver_choices|abort"
+ echo "usage: $(basename $0) service check|disable|restore"
+ else
+ echo "usage: $(basename $0) $driver_choices|unset|get-current|log-view|log-clean"
+ fi
+
echo
+ echo "nvidia: use the NVIDIA proprietary driver"
+ echo "intel: use the Intel card with the \"modesetting\" driver"
+ echo " PRIME Render Offload possible with >= 435.xx NVIDIA driver"
+ echo "intel2: use the Intel card with the \"intel\" Open Source driver (xf86-video-intel)"
+ echo " PRIME Render Offload possible with >= 435.xx NVIDIA driver"
+ echo "unset: disable effects of this script and let Xorg decide what driver to use"
+ echo "get-current: display driver currently configured"
+ echo "log-view: view logfile"
+ echo "log-clean: clean logfile"
+
+ if (( service_test == 0 )); then
+ echo "boot: select default card at boot or set last used"
+ echo "next-boot: select card ONLY for next boot, it not touches your boot preference. abort: restores next boot to default"
+ echo "get-boot: display default card at boot"
+ echo "service: disable, check or restore prime-select service. Could be useful disabling service"
+ echo " before isolating multi-user.target to prevent service execution."
+ fi
+
+ #if (( service_test == 0)); then
+ # echo
+ # echo "##FOLLOWING COMMANDS ARE USED BY prime-select SERVICEs, DON'T USE THEM MANUALLY##"
+ # echo "systemd_call: called during boot or after user logout for switch"
+ # echo "user_logout_waiter: waits user logout (used by prime-select systemd service)"
+ #fi
+
+ echo
+}
+
+function logging {
+ if ! [ -f $prime_logfile ]; then
+ echo "##SUSEPrime logfile##" > $prime_logfile
+ fi
+ echo "[ $(date +"%H:%M:%S") ] ${1}" >> $prime_logfile
+ echo "${1}" | systemd-cat -t suse-prime -p info
}
function check_root {
@@ -36,105 +89,157 @@
fi
}
-function clean_files {
+function check_service {
+ if (( service_test != 0)); then
+ exit 1;
+ fi
+}
+
+function bbcheck {
+ if rpm -q bbswitch > /dev/null; then
+ if grep OFF /proc/acpi/bbswitch > /dev/null; then
+ echo "[bbswitch] NVIDIA card is OFF"
+ elif grep ON /proc/acpi/bbswitch > /dev/null; then
+ echo "[bbswitch] NVIDIA card is ON"
+ else
+ echo "bbswitch is installed but seems broken. Cannot get NVIDIA power status"
+ fi
+ elif (( service_test == 0)); then
+ # should never happen with suse-prime-bbswitch package as bbswitch is a dependency
+ echo "bbswitch is not installed. NVIDIA card will not be powered off"
+ fi
+}
+
+function clean_xorg_conf_d {
rm -f /etc/X11/xorg.conf.d/90-nvidia.conf
rm -f /etc/X11/xorg.conf.d/90-intel.conf
}
-case $type in
+function update_kdeglobals {
+
+ # The KDE kscreen5 module ('Display and Monitor' settings) stores the user-defined scaling for all detected monitors
+ # in file ~/.config/kdeglobals, in the ScreenScaleFactors line. For example:
+ #
+ # ScreenScaleFactors=eDP-1-1=2;DP-0=2;DP-1=2;HDMI-0=2;DP-2=2;DP-3=2;DP-4=2;
+ #
+ # /usr/bin/startkde reads this value and assigns it to environment variable QT_SCREEN_SCALE_FACTORS:
+ #
+ # QT_SCREEN_SCALE_FACTORS=eDP-1-1=2;DP-0=2;DP-1=2;HDMI-0=2;DP-2=2;DP-3=2;DP-4=2;
+ #
+ # The value of this variable is crucial to have KDE scale the QT widgets properly
+ #
+ # The problem is that the laptop panel output name (eDP-1-1 in that example, always listed first) is not the same depending
+ # on whether the intel (modesetting), intel2 (intel) or nvidia driver is used, resulting in that variable
+ # not being up-to-date when user switches drivers with this script and scaling not working properly
+ #
+ # code below is a workaround that edits file ~/.config/kdeglobals with the proper panel name
+ # passed as first parameter of this function
+
+ [ -z "$user" ] && return
- apply-current)
-
- if [ -f /etc/prime/current_type ]; then
-
- current_type=`cat /etc/prime/current_type`
-
- if [ "$current_type" != "nvidia" ] && ! lspci | grep "$lspci_intel_line" > /dev/null; then
-
- # this can happen if user set intel but changed to "Discrete only" in BIOS
- # in that case the Intel card is not visible to the system and we must switch to nvidia
-
- echo "Forcing nvidia due to Intel card not found"
- current_type="nvidia"
- fi
-
- $0 $current_type
- fi
- ;;
+ panel_name=${1}
+
+ kdeglobals="$(sudo -u $user -i eval 'echo -n $HOME')/.config/kdeglobals"
- nvidia)
+ if [ -f $kdeglobals ]; then
+ sudo -u $user sed -i -r "s/(ScreenScaleFactors=)$panel_nvidia|$panel_intel|$panel_intel2/\1$panel_name/" "$kdeglobals"
+ logging "updated $kdeglobals"
+ fi
+}
- check_root
+function set_nvidia {
+
+ if (( service_test == 0)); then
- if [ -f /proc/acpi/bbswitch ]; then
+ if [ -f /proc/acpi/bbswitch ]; then
tee /proc/acpi/bbswitch > /dev/null < /dev/null
+ nvidia_busid=$(echo "$gpu_info" | grep -i "PCI BusID" | head -n 1 | sed 's/PCI BusID ://' | sed 's/ //g')
- clean_files
+ if [ -f /usr/lib*/xorg/modules/extensions/nvidia/nvidia-libglx.so ]; then
+ libglx_nvidia=$(update-alternatives --list libglx.so|grep nvidia-libglx.so)
+ update-alternatives --set libglx.so $libglx_nvidia > /dev/null
+ fi
- cat $xorg_nvidia_conf | sed 's/PCI:X:X:X/'${nvidia_busid}'/' > /etc/X11/xorg.conf.d/90-nvidia.conf
+ clean_xorg_conf_d
- echo "$type" > /etc/prime/current_type
+ cat $xorg_nvidia_conf | sed 's/PCI:X:X:X/'${nvidia_busid}'/' > /etc/X11/xorg.conf.d/90-nvidia.conf
- $0 get-current
- ;;
+ update_kdeglobals $panel_nvidia
- intel|intel2)
+ echo "nvidia" > /etc/prime/current_type
+ logging "NVIDIA card correctly set"
+}
- check_root
-
- if [ "$type" = "intel2" ]; then
- if ! rpm -q xf86-video-intel > /dev/null; then
- echo "package xf86-video-intel is not installed";
- exit 1
- fi
-
- conf=$xorg_intel_conf_intel2
- else
- # modesetting driver is part of xorg-x11-server and always available
- conf=$xorg_intel_conf_intel
- fi
+function set_intel {
+ # modesetting driver is part of xorg-x11-server and always available
+ conf=$xorg_intel_conf_intel
+ echo "intel" > /etc/prime/current_type
+ #jump to common function intel1/intel2
+ common_set_intel
+ update_kdeglobals $panel_intel
+}
- # find Intel card bus id. Without this Xorg may fail to start
- line=`lspci | grep "$lspci_intel_line" | head -1`
- if [ $? -ne 0 ]; then
- echo "Failed to find Intel card with lspci"
- exit 1
- fi
+function set_intel2 {
+ conf=$xorg_intel_conf_intel2
+ echo "intel2" > /etc/prime/current_type
+ #jump to common function intel1/intel2
+ common_set_intel
+ update_kdeglobals $panel_intel2
+}
- intel_busid=`echo $line | cut -f 1 -d ' ' | sed -e 's/\./:/g;s/:/ /g' | awk -Wposix '{printf("PCI:%d:%d:%d\n","0x" $1, "0x" $2, "0x" $3 )}'`
- if [ $? -ne 0 ]; then
- echo "Failed to build Intel card bus id"
- exit 1
- fi
-
- libglx_xorg=`update-alternatives --list libglx.so|grep xorg-libglx.so`
+function common_set_intel {
+ # find Intel card bus id. Without this Xorg may fail to start
+ line=$(lspci | grep "$lspci_intel_line" | head -1)
+ if [ $? -ne 0 ]; then
+ logging "Failed to find Intel card with lspci"
+ exit 1
+ fi
- update-alternatives --set libglx.so $libglx_xorg > /dev/null
-
- clean_files
+ intel_busid=$(echo $line | cut -f 1 -d ' ' | sed -e 's/\./:/g;s/:/ /g' | awk -Wposix '{printf("PCI:%d:%d:%d\n","0x" $1, "0x" $2, "0x" $3 )}')
+ if [ $? -ne 0 ]; then
+ logging "Failed to build Intel card bus id"
+ exit 1
+ fi
+
+ gpu_info=$(nvidia-xconfig --query-gpu-info)
+ # This may easily fail, if no NVIDIA kernel module is available or alike
+ if [ $? -ne 0 ]; then
+ logging "PCI BusID of NVIDIA card could not be detected!"
+ exit 1
+ fi
- cat $conf | sed 's/PCI:X:X:X/'${intel_busid}'/' > /etc/X11/xorg.conf.d/90-intel.conf
+ # There could be more than on NVIDIA card/GPU; use the first one in that case
+ nvidia_busid=$(echo "$gpu_info" | grep -i "PCI BusID" | head -n 1 | sed 's/PCI BusID ://' | sed 's/ //g')
+
+ libglx_xorg=$(update-alternatives --list libglx.so | grep xorg-libglx.so)
+
+ update-alternatives --set libglx.so $libglx_xorg > /dev/null
+
+ clean_xorg_conf_d
+
+ cat $conf | sed -e 's/PCI:X:X:X/'${intel_busid}'/' -e 's/PCI:Y:Y:Y/'${nvidia_busid}'/' > /etc/X11/xorg.conf.d/90-intel.conf
+
+ if (( service_test == 0)); then
modprobe -r $nvidia_modules
@@ -142,17 +247,273 @@
tee /proc/acpi/bbswitch > /dev/null < /dev/null || echo "Failed to power off NVIDIA card"
+ fi
+
+ logging "trying switch OFF nvidia: $(bbcheck)"
+
+ fi
+
+ logging "Intel card correctly set"
+}
+
+function apply_current {
+ if [ -f /etc/prime/current_type ]; then
+
+ current_type=$(cat /etc/prime/current_type)
+
+ if [ "$current_type" != "nvidia" ] && ! lspci | grep "$lspci_intel_line" > /dev/null; then
+
+ # this can happen if user set intel but changed to "Discrete only" in BIOS
+ # in that case the Intel card is not visible to the system and we must switch to nvidia
+
+ logging "Forcing nvidia due to Intel card not found"
+ current_type="nvidia"
+ elif [ "$current_type" = "nvidia" ] && \
+ ! lspci | grep -q "$lspci_nvidia_vga_line" && \
+ ! lspci | grep -q "$lspci_nvidia_3d_line"; then
+
+ # this can happen if user set nvidia but changed to "Integrated only" in BIOS (possible
+ # on some MUXED Optimus laptops) in that case the NVIDIA card is not visible to the
+ # system and we must switch to intel
+
+ logging "Forcing intel due to NVIDIA card not found"
+ current_type="intel"
+ fi
+
+
+ set_$current_type
+ fi
+}
+
+function current_check {
+ if [ "$(pgrep -f "prime-select user_logout_waiter")" > /dev/null ]; then
+ echo "Error: a switch operation already in execution"
+ echo "You can undo it using sudo killall prime-select"
+ exit 1
+ fi
+ if ! [ -f /etc/prime/current_type ]; then
+ echo "Preparing first configuration"
+ elif [ "$type" = "$(cat /etc/prime/current_type)" ]; then
+ echo "$type driver already in use!"
+ exit 1
+ fi
+}
+
+function booting {
+ if ! [ -f /etc/prime/boot_state ]; then
+ echo "N" > /etc/prime/boot_state
+ fi
+ if ! [ -f /etc/prime/boot ]; then
+ echo "last" > /etc/prime/boot
+ fi
+
+ if [ -f /etc/prime/forced_boot ]; then
+ echo "$(cat /etc/prime/forced_boot)" > /etc/prime/current_type
+ rm /etc/prime/forced_boot
+ logging "Boot: forcing booting with $(cat /etc/prime/current_type), boot preference ignored"
+ logging "Boot: setting-up $(cat /etc/prime/current_type) card"
+ apply_current
+ else
+ boot_type=$(cat /etc/prime/boot)
+ if [ "$boot_type" != "last" ]; then
+ echo "$boot_type" > /etc/prime/current_type
+ fi
+ logging "Boot: setting-up $(cat /etc/prime/current_type) card"
+ apply_current
+ fi
+}
+
+function logout_switch {
+ apply_current
+ echo "N" > /etc/prime/boot_state
+ logging "HotSwitch: Reaching graphical.target [ boot_state > N ]"
+ systemctl isolate graphical.target &
+ systemctl stop prime-select
+}
+
+function logout_switch_no_dm {
+ apply_current
+ echo "N" > /etc/prime/boot_state
+ systemctl stop prime-select
+}
+
+function set_user {
+ [ -n "$1" ] && echo $1 > /etc/prime/user
+}
+
+case $type in
+
+ nvidia|intel|intel2)
+
+ current_check
+ check_root
+
+ if ! [ -f /var/log/prime-select.log ]; then
+ echo "##SUSEPrime logfile##" > $prime_logfile
+ fi
+
+ if [ $(wc -l < $prime_logfile) -gt 1000 ]; then
+ #cleaning logfile if has more than 1k events
+ rm $prime_logfile &> /dev/null
+ echo "##SUSEPrime logfile##" > $prime_logfile
+ fi
+
+ if [ "$type" = "intel2" ];then
+ if ! rpm -q xf86-video-intel > /dev/null; then
+ echo "package xf86-video-intel is not installed";
+ exit 1
+ fi
+ fi
+
+ if (( service_test == 0)); then
+
+ if ! [ -f /etc/systemd/system/multi-user.target.wants/prime-select.service ]; then
+ echo "ERROR: prime-select service seems broken or disabled by user. Try prime-select service restore"
+ exit 1
+ fi
+
+ if ! { [ "$(bbcheck)" = "[bbswitch] NVIDIA card is ON" ] || [ "$(bbcheck)" = "[bbswitch] NVIDIA card is OFF" ]; }; then
+ bbcheck
+ fi
+
+ #DM_check
+
+ # use this to determine current target as this is more reliable than legacy runlevel command that can return 'undefined' or 'N'
+ # see https://serverfault.com/questions/835515/systemd-how-to-get-the-running-targ...
+ # cannot use 'systemctl get-default' as default target may be different than current target
+ target=$(systemctl list-units --type target | egrep "^multi-user|^graphical" | head -1 | cut -f 1 -d ' ')
+
+ # might be empty if script not invoked by sudo, ie directly by root
+ user=$SUDO_USER
+
+ if [ "$target" = "graphical.target" ]; then
+ #GDM_mode
+ if [ "$(systemctl status display-manager | grep gdm)" > /dev/null ]; then
+ $0 user_logout_waiter $type gdm $user &
+ logging "user_logout_waiter: started"
+ #SDDM_mode
+ elif [ "$(systemctl status display-manager | grep sddm)" > /dev/null ]; then
+ $0 user_logout_waiter $type sddm $user &
+ logging "user_logout_waiter: started"
+ #lightdm_mode
+ elif [ "$(systemctl status display-manager | grep lightdm)" > /dev/null ]; then
+ $0 user_logout_waiter $type lightdm $user &
+ logging "user_logout_waiter: started"
+ #XDM_mode
+ elif [ "$(systemctl status display-manager | grep xdm)" > /dev/null ]; then
+ $0 user_logout_waiter $type xdm $user &
+ logging "user_logout_waiter: started"
+ #KDM_mode(uses xdm->calls xdm_mode)
+ elif [ "$(systemctl status display-manager | grep kdm)" > /dev/null ]; then
+ $0 user_logout_waiter $type xdm $user &
+ logging "user_logout_waiter: started"
+ #unsupported_dm_force_close_option
+ else
+ echo "Unsupported display-manager, please report this to project page to add support."
+ echo "Script works even in init 3"
+ echo "You can force-close session and switch graphics [could be dangerous],"
+ read -p "ALL UNSAVED DATA IN SESSION WILL BE LOST, CONTINUE? [Y/N]: " choice
+ case "$choice" in
+ y|Y )
+ killall xinit
+ $0 user_logout_waiter $type now $user
+ ;;
+ * ) echo "Aborted. Exit."; exit ;;
+ esac
+ fi
+ #manually_started_X_case
+ elif [ "$target" = "multi-user.target" ] && [ "$(pgrep -x xinit)" > /dev/null ]; then
+ $0 user_logout_waiter $type x_only $user &
+ logging "user_logout_waiter: started"
+ # from console without Xorg running
+ else
+ echo $type > /etc/prime/current_type
+ apply_current
+ exit
+ fi
+
+ else # no service used
+
+ echo $type > /etc/prime/current_type
+ apply_current
- else
- rpm -q bbswitch > /dev/null || echo "bbswitch is not installed. NVIDIA card will not be powered off"
fi
- echo "$type" > /etc/prime/current_type
+ echo -e "Logout to switch graphics"
+ ;;
+
+ boot)
- $0 get-current
+ check_service
+ check_root
+
+ case $2 in
+
+ nvidia|intel|intel2|last)
+
+ if [ "$2" = "intel2" ]; then
+ if ! rpm -q xf86-video-intel > /dev/null; then
+ echo "package xf86-video-intel is not installed";
+ exit 1
+ fi
+ fi
+
+ echo "$2" > /etc/prime/boot
+ set_user $SUDO_USER
+
+ $0 get-boot
+ ;;
+
+ *)
+
+ echo "Invalid choice"
+ usage
+ ;;
+ esac
;;
+ next-boot)
+
+ check_service
+ check_root
+
+ case $2 in
+
+ nvidia|intel|intel2)
+
+ if [ "$2" = "intel2" ]; then
+ if ! rpm -q xf86-video-intel > /dev/null; then
+ echo "package xf86-video-intel is not installed";
+ exit 1
+ fi
+ fi
+
+ echo "$2" > /etc/prime/forced_boot
+ set_user $SUDO_USER
+
+ $0 get-boot
+ ;;
+
+ abort)
+
+ if [ -f /etc/prime/forced_boot ]; then
+ rm /etc/prime/forced_boot
+ echo "Next boot forcing aborted"
+ else
+ echo "Next boot is NOT forced"
+ exit 1
+ fi
+ ;;
+
+ *)
+
+ echo "Invalid choice"
+ usage
+ ;;
+ esac
+ ;;
+
+
get-current)
if [ -f /etc/prime/current_type ]; then
@@ -162,17 +523,190 @@
echo "No driver configured."
usage
fi
- ;;
+
+ bbcheck
+ ;;
unset)
check_root
+ $0 service disable
+ clean_xorg_conf_d
+ rm /etc/prime/current_type &> /dev/null
+ rm /etc/prime/boot_state &> /dev/null
+ rm /etc/prime/boot &> /dev/null
+ rm /etc/prime/forced_boot &> /dev/null
+ rm /etc/prime/user &> /dev/null
+ rm $prime_logfile &> /dev/null
+ ;;
+
+ service)
+
+ check_service
+
+ case $2 in
+
+ check)
+
+ if [ -f /etc/systemd/system/multi-user.target.wants/prime-select.service ]; then
+ echo "prime-select: service is set correctly"
+ exit
+ fi
+ echo "prime-select: service has a wrong setting or is disabled by user, please do prime-select service restore"
+ echo "If you are running this command in multi-user.target please ignore this message"
+ ;;
+
+ restore)
+
+ check_root
+ systemctl enable prime-select
+ echo "prime-select: service restored"
+ logging "service restored by user"
+ ;;
+
+ disable)
+
+ check_root
+ systemctl disable prime-select
+ echo -e "prime-select: service disabled. Remember prime-select needs this service to work correctly.\nUse prime-select service restore to enable service again "
+ logging "service disabled by user"
+ ;;
+
+ *)
+
+ echo "Invalid choice"
+ usage
+ ;;
+ esac
+
+
+ ;;
+
+ user_logout_waiter)
+
+ echo "S" > /etc/prime/boot_state
- clean_files
- rm /etc/prime/current_type
+ currtime=$(date +"%T");
+ #manage journalctl to check when X restarted, then jump init 3
+ case "$3" in
+
+ gdm )
+ #GDM_mode
+ until [ "$(journalctl --since "$currtime" | grep "pam_unix(gdm-password:session): session closed")" > /dev/null ]; do
+ sleep 0.5s
+ done
+ logging "user_logout_waiter: X restart detected, preparing switch to $2 [ boot_state > S ]"
+ ;;
+
+ #SDDM_mode
+ sddm )
+ until [ "$(journalctl --since "$currtime" -e _COMM=sddm | grep "Removing display")" > /dev/null ]; do
+ sleep 0.5s
+ done
+ logging "user_logout_waiter: X restart detected, preparing switch to $2 [ boot_state > S ]"
+ ;;
+
+ #lightdm_mode
+ lightdm )
+ until [ "$(journalctl --since "$currtime" -e | grep "pam_unix(lightdm:session): session closed")" > /dev/null ]; do
+ sleep 0.5s
+ done
+ logging "user_logout_waiter: X restart detected, preparing switch to $2 [ boot_state > S ]"
+ ;;
+
+ #xdm/kdm_mode
+ xdm )
+ until [ "$(journalctl --since "$currtime" -e | grep "pam_unix(xdm:session): session closed for user")" > /dev/null ]; do
+ sleep 0.5s
+ done
+ logging "user_logout_waiter: X restart detected, preparing switch to $2 [ boot_state > S ]"
+ #stopping display-manager before runlev.3 seems work faster
+ systemctl stop display-manager
+ ;;
+
+ #manually_started_X_case
+ x_only )
+ while [ "$(pgrep -x xinit)" > /dev/null ]; do
+ sleep 0.5s
+ done
+ logging "user_logout_waiter: X stop detected, preparing switch to $2 [ boot_state > S2 ]"
+
+ # S2 = special switch state to indicate that we must not switch to graphical.target (in systemd_call) since we are using xinit/startx
+ echo "S2" > /etc/prime/boot_state
+ ;;
+
+ esac
+
+ echo $2 > /etc/prime/current_type
+ set_user $4
+
+ logging "HotSwitch: Reaching multi-user.target"
+ systemctl isolate multi-user.target &
;;
+
+ systemd_call)
+ # user is used in update_kdeglobals
+ # it is the last user that invoked this script via sudo
+ [ -f /etc/prime/user ] && user=$(cat /etc/prime/user)
+
+ #checks if system is booting or switching only
+ if [ "$(journalctl -b 0 | grep suse-prime)" > /dev/null ]; then
+
+ boot_state=$(cat /etc/prime/boot_state)
+
+ case $boot_state in
+
+ S)
+ logout_switch
+ ;;
+ S2)
+ logout_switch_no_dm
+ ;;
+ esac
+
+ else
+ booting
+ fi
+ ;;
+
+ get-boot)
+
+ check_service
+
+ if [ -f /etc/prime/boot ]; then
+ echo "Default at system boot: $(cat /etc/prime/boot)"
+ else
+ echo "Default at system boot: auto (last)"
+ echo "You can configure it with prime-select boot intel|intel2|nvidia|last"
+ fi
+ if [ -f /etc/prime/forced_boot ]; then
+ echo "Next boot forced to $(cat /etc/prime/forced_boot) by user"
+ fi
+
+ ;;
+
+ log-view)
+
+ if [ -f $prime_logfile ]; then
+ less +G -e $prime_logfile
+ else
+ echo "No logfile in /var/log/prime-select.log"
+ fi
+ ;;
+
+ log-clean)
+
+ if [ -f $prime_logfile ]; then
+ check_root
+ rm $prime_logfile
+ echo "$prime_logfile removed!"
+ else
+ echo "$prime_logfile is already clean!"
+ fi
+ ;;
+
*)
- usage
+ usage
;;
esac
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/SUSEPrime-0.5/xorg-intel-intel.conf new/SUSEPrime-0.7/xorg-intel-intel.conf
--- old/SUSEPrime-0.5/xorg-intel-intel.conf 2019-01-24 21:08:13.000000000 +0100
+++ new/SUSEPrime-0.7/xorg-intel-intel.conf 2019-10-02 17:22:32.000000000 +0200
@@ -1,14 +1,36 @@
Section "ServerLayout"
Identifier "layout"
Screen "intel"
+ Option "AllowNVIDIAGPUScreens"
EndSection
Section "Device"
Identifier "intel"
Driver "intel"
+
+ # DRI3 is necessary, otherwise DRI2 is used by default
+ # and this causes issues with compositors (scrolling stutter in
+ # particular)
+
+ Option "DRI" "3"
+
+ # Unlike what man "intel" says, TearFree is enabled by default
+ # It is unecessary to have it enabled (consumes memory, see man) when a competent compositor with
+ # vsync enabled is used.
+ # Comment this line (or set to "true") if not using a compositor (not recommended)
+
+ Option "TearFree" "false"
+
BusID "PCI:X:X:X"
EndSection
+# needed for NVIDIA PRIME Render Offload
+Section "Device"
+ Identifier "nvidia"
+ Driver "nvidia"
+ BusID "PCI:Y:Y:Y"
+EndSection
+
Section "Screen"
Identifier "intel"
Device "intel"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/SUSEPrime-0.5/xorg-intel.conf new/SUSEPrime-0.7/xorg-intel.conf
--- old/SUSEPrime-0.5/xorg-intel.conf 2019-01-24 21:08:13.000000000 +0100
+++ new/SUSEPrime-0.7/xorg-intel.conf 2019-10-02 17:22:32.000000000 +0200
@@ -1,6 +1,7 @@
Section "ServerLayout"
Identifier "layout"
Screen "intel"
+ Option "AllowNVIDIAGPUScreens"
EndSection
Section "Device"
@@ -9,6 +10,13 @@
BusID "PCI:X:X:X"
EndSection
+# needed for NVIDIA PRIME Render Offload
+Section "Device"
+ Identifier "nvidia"
+ Driver "nvidia"
+ BusID "PCI:Y:Y:Y"
+EndSection
+
Section "Screen"
Identifier "intel"
Device "intel"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/SUSEPrime-0.5/xorg-nvidia.conf new/SUSEPrime-0.7/xorg-nvidia.conf
--- old/SUSEPrime-0.5/xorg-nvidia.conf 2019-01-24 21:08:13.000000000 +0100
+++ new/SUSEPrime-0.7/xorg-nvidia.conf 2019-10-02 17:22:32.000000000 +0200
@@ -34,5 +34,6 @@
Identifier "nvidia"
Driver "nvidia"
BusID "PCI:X:X:X"
+ Option "DPI" "96 x 96"
Option "AllowEmptyInitialConfiguration"
EndSection