nan0s7 / nfancurve

A small and lightweight POSIX script for using a custom fan curve in Linux for those with an Nvidia GPU.
GNU General Public License v3.0
314 stars 57 forks source link

usage issues - xorg.conf, service autostart #51

Open AGenchev opened 2 years ago

AGenchev commented 2 years ago

I want to use your script, but I can't get xorg.conf the way you describe in USAGE.md

I have 2 cards, the display is at one of them. Where you connect the display becomes the first GPU in the nvidia-settings panel. It changes it if you plug the display in the other card. nvidia-settings does not create file in /etc/X11/xorg.conf.d. So no way to ensure coolbits are set properly. I'm trying to make the file by manual creating 20-nvidia.conf file:

Section "Device"
        # You may change the identifier number to your use case.
        Identifier      "Device0"
        Driver         "nvidia"
        BusID          "PCI:8:0:0"
        BoardName      "NVIDIA GeForce RTX 3090"
        VendorName     "NVIDIA Corporation"
        Option         "Coolbits" "28"
EndSection

Section "Device"
        # You may change the identifier number to your use case.
        Identifier      "Device1"
        Driver         "nvidia"
        BusID          "PCI:9:0:0"
        BoardName      "NVIDIA GeForce RTX 3090"
        VendorName     "NVIDIA Corporation"
        Option         "Coolbits" "28"
EndSection

This resulted in blank screen and in the log of Xorg I see "Option Coolbits not used". The BusIDs are taken from the output of lspci

AGenchev commented 2 years ago

This https://bbs.archlinux.org/viewtopic.php?id=257891 got me fixed:

Section "Device"
        # You may change the identifier number to your use case.
        Identifier      "Device0"
        Driver         "nvidia"
        BusID          "PCI:8:0:0"  
        BoardName      "NVIDIA GeForce RTX 3090"
        VendorName     "NVIDIA Corporation"
        Option         "Coolbits" "4"
EndSection

Section "Device"
        # You may change the identifier number to your use case.
        Identifier      "Device1"
        Driver         "nvidia"
        BusID          "PCI:9:0:0"  
        BoardName      "NVIDIA GeForce RTX 3090"
        VendorName     "NVIDIA Corporation"
        Option         "Coolbits" "4"
EndSection

# a layout combining the actual and virtual monitors
Section "ServerLayout"  
    Identifier    "Layout0"     
#   Our real monitor, plugged in the first GPU - Device0
    Screen 0      "Screen0" 0 0     
#   Our virtual/fake monitor
    Screen 1      "Screen1"     
EndSection

Section "Screen"
# A screen, for the real Monitor0 plugged in the first GPU - Device0
    Identifier     "Screen0"
#card0
    Device         "Device0"
# actual monitor
    Monitor        "Monitor0"
    DefaultDepth 24
    SubSection     "Display"
       Depth 24
    EndSubSection
EndSection

Section "Screen"
# A screen, for the fake monitor, plugged in the second GPU - Device1
    Identifier     "Screen1"
# discrete GPU nvidia
    Device         "Device1"
# virtual monitor
    Monitor        "Monitor1"
    DefaultDepth 24
    SubSection     "Display"
       Depth 24
    EndSubSection
EndSection

# These are 2 sections for the real and the fake/virtual monitor, we can omit most settings for now
Section "Monitor"
    Identifier     "Monitor0"
    VendorName     "Unknown"
    Option         "DPMS"
EndSection

Section "Monitor"
    Identifier     "Monitor1"
    VendorName     "Unknown"
    Option         "DPMS"
EndSection

They describe that if one of the cards does not have plugged in monitor, we need to define a fake one (Monitor1 is fake), so I modified my file accordingly. Now nfancurve works but only manually, the service dies. The service unit has this code:

[Unit]
Description=Nfancurve service
After=graphical-session.target
Requires=graphical-session.target

[Service]
ExecStart=/home/user/nfancurve/temp.sh -c /home/user/nfancurve/config
KillSignal=SIGINT
Restart=always
RestartSec=16

[Install]
WantedBy=graphical-session.target

I am not sure that /etc/systemd/user/ is the best place for it though. One related systemd article suggests that the right place is ~/.config/systemd/user/ though the service likely fails for other reasons.

AGenchev commented 2 years ago

If I excecute manually:

systemctl --user daemon-reload
systemctl --user enable nfancurve.service
systemctl --user start nfancurve.service

it starts.

nan0s7 commented 1 year ago

Hey, sorry for not seeing this!

Glad you were able to figure out the xconf issue.

However, what do you mean by "the service dies manually"?

I'll have to add notes to my usage file reflecting the addition of monitors that aren't turned on. Thank you for that.

AGenchev commented 1 year ago

I performed a search in this page by "the service dies manually" and found only one match - in your question (after I post this there will be 2 matches). But the service really dies and does not get restarted by systemd, which is weird. I guess it dies because at the beginning, the user is not logged in yet. So when it tries to call some nvidia tool, the tool fails.