Thank you oh so very much for this!
I followed steps 1-6, skipped 7 and ran systemctl restart gdm.service
instead. It worked beautifully.
I did run into a few problems afterwards and was wondering if you guys could help out:
Apparently my laptop has a muxless GPU and even after updating and installing proprietary drivers I couldn't get an image without the xorg.conf
file suggested in step 6. I had almost the same issue with Manjaro, but the problem there was that if I had Open Source Drivers I could use my laptop screen and if I had proprietary drivers I could my second screen with the HDMI port. I installed a hybrid AMD-Nvidia driver in Manjaro, but still had no image in both screens. I found this: https://wiki.archlinux.org/index.php/PRIME#Reverse_PRIME and after reading this I understood about the muxless issue I was having. I got to this: https://us.download.nvidia.com/XFree86/Linux-x86_64/450.57/README/randr14.html and successfully implemented an xorg.conf
to run everything from my Nvidia card.
Now the problem I have is that apparently I have to run: (EDIT: I fixed it, it's on the next reply. I think I did it wrong, but it works. Any input on the matter would be greatly appreciated)
$ xrandr --setprovideroutputsource modesetting NVIDIA-0
$ xrandr --auto
in order to get picture both on my HDMI port AND my onboard laptop screen. If I don't run this then my HDMI port works, but my laptop screen doesn't. After login I can simply run the commands and that's all great, but if I'm not carrying an secondary monitor I basically have to log-in blind.
The Nvidia manual suggests adding the the lines to ~/.xinitrc
but I just couldn't do it? I don't know what I failed at. Then I thought about making a service to be called BEFORE login screen, but I also failed at that (I was following these instructions: https://www.golinuxcloud.com/run-script-systemd-before-login-prompt-linux/ but changed the unit file to:
[Unit]
Description=Run script with systemd right before login prompt
After=gdm.service
Before=getty@tty1.service
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/home/kurt/bin/scripts/screenFix.sh start
[Install]
WantedBy=multi-user.target
The script itself looks like this:
#!/bin/bash
# Run this small script before login screen in order to get image on laptop
# screen. Otherwise, just HDMI works
xrandr --setprovideroutputsource modesetting NVIDIA-0
xrandr --auto
Any help would be greatly appreciated!
EDIT:
Modified my Unit File to:
[Unit]
Description=Run script with systemd right before login prompt
After=gdm.service
Before=getty@tty1.service
[Service]
ExecStart=/home/kurt/bin/scripts/screenFix.sh
[Install]
WantedBy=multi-user.target
because I realized I don't have a start
command inside my script... still not working 🙁
EDIT2:
Unit file now looks like this:
[Unit]
Description=Run script with systemd right before login prompt
After=gdm.service
[Service]
Type=oneshot
ExecStart=/bin/sleep 10
ExecStart=/usr/bin/xrandr --setprovideroutputsource modesetting NVIDIA-0
ExecStart=/usr/bin/xrandr --auto
[Install]
WantedBy=multi-user.target
I tried starting the service using systemctl start fix-screen.service
and it returns an error. Status returns the following:
kurt@kurt-lin ~ $ systemctl status fix-screen.service
● fix-screen.service - Run script with systemd right before login prompt
Loaded: loaded (/etc/systemd/system/fix-screen.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Thu 2020-09-17 16:43:24 CST; 13s ago
Process: 5435 ExecStart=/bin/sleep 10 (code=exited, status=0/SUCCESS)
Process: 5440 ExecStart=/usr/bin/xrandr --setprovideroutputsource modesetting NVIDIA-0 (code=exited, status=1/FAILURE)
Main PID: 5440 (code=exited, status=1/FAILURE)
Sorry for spamming... I'm justa bit desperate here...