Нечеткая графика после приостановки работы драйверов nvidia

Я боролся с тем же самым. Я нашел несколько других сообщений, в которых говорилось об использовании pactl для проверки статуса pulseaudio. Вот одна ссылка:

https://superuser.com/questions/393448/detecting-audio-playing-in-a-bash-script

Я попытался собрать очень простой скрипт, который изменит тайм-аут приостановки в настройках питания Cinnamon, чтобы никогда не временно, пока играет музыка, а затем возвращаться, когда музыка останавливается. Это моя первая реальная попытка написать сценарий, поэтому, если вы можете улучшить его, не стесняйтесь. Однако, скорее всего, это будет работать только в Cinnamon.

#!/bin/sh

# Script to temporarily set Cinnamon's suspend timout for AC and battery to "Never"
# while audio is playing.  It then reverts the settings when audio is no longer detected.

# Create directory to store settings if it doesn't exist.
if [ ! -d ~/.config/audiocaffeine ]; then
    echo "Configuration directory not found!"
    echo "Creating ~/.config/audiocaffeine"
    mkdir ~/.config/audiocaffeine
fi

# Restore previous value for AC suspend timeout if script
# was interrupted.
if [ -f ~/.config/audiocaffeine/acsuspend ]; then
    echo "Restoring previous AC suspend timeout."
    read acsuspendtime < ~/.config/audiocaffeine/acsuspend
    gsettings set org.cinnamon.settings-daemon.plugins.power sleep-inactive-ac-timeout $acsuspendtime
    echo "Removing temporary file ~/.config/audiocaffeine/acsuspend"
    rm ~/.config/audiocaffeine/acsuspend
fi

# Restore previous value for battery suspend timeout if script
# was interrupted.
if [ -f ~/.config/audiocaffeine/battsuspend ]; then
    echo "Restoring previous battery suspend timeout."
    read battsuspendtime < ~/.config/audiocaffeine/battsuspend
    gsettings set org.cinnamon.settings-daemon.plugins.power sleep-inactive-battery-timeout $battsuspendtime
    echo "Removing temporary file ~/.config/audiocaffeine/battsuspend"
    rm ~/.config/audiocaffeine/battsuspend
fi

# Start main loop to check if audio is playing

while true; do

    # Use pactl to detect if there are any running audio sources.
    if pactl list | grep -q RUNNING; then

        echo "Audio detected."

        # If AC timeout was not previously saved, then save it.
        if [ ! -f ~/.config/audiocaffeine/acsuspend ]; then
            echo "Saving current AC suspend timeout."
            gsettings get org.cinnamon.settings-daemon.plugins.power sleep-inactive-ac-timeout > ~/.config/audiocaffeine/acsuspend
        fi

        # If battery timeout was not previously saved, then save it.
        if [ ! -f ~/.config/audiocaffeine/battsuspend ]; then
            echo "Saving current battery suspend timeout."
            gsettings get org.cinnamon.settings-daemon.plugins.power sleep-inactive-battery-timeout > ~/.config/audiocaffeine/battsuspend
        fi

        # Set the suspend timouts to Never using gsettings.
        echo "Changing suspend timeouts."
        gsettings set org.cinnamon.settings-daemon.plugins.power sleep-inactive-ac-timeout 0
        gsettings set org.cinnamon.settings-daemon.plugins.power sleep-inactive-battery-timeout 0

    else
        echo "No audio detected."

        # Restore previous value for AC suspend timeout and delete the
        # temporary file storing it.
        if [ -f ~/.config/audiocaffeine/acsuspend ]; then
            echo "Restoring previous AC suspend timeout."
            read acsuspendtime < ~/.config/audiocaffeine/acsuspend
            gsettings set org.cinnamon.settings-daemon.plugins.power sleep-inactive-ac-timeout $acsuspendtime
            echo "Removing temporary file ~/.config/audiocaffeine/acsuspend"
            rm ~/.config/audiocaffeine/acsuspend
        fi

        # Restore previous value for battery suspend timeout and delete the
        # temporary file storing it.
        if [ -f ~/.config/audiocaffeine/battsuspend ]; then
            echo "Restoring previous battery suspend timeout."
            read battsuspendtime < ~/.config/audiocaffeine/battsuspend
            gsettings set org.cinnamon.settings-daemon.plugins.power sleep-inactive-battery-timeout $battsuspendtime
            echo "Removing temporary file ~/.config/audiocaffeine/battsuspend"
            rm ~/.config/audiocaffeine/battsuspend
        fi

    fi

    # Pause the script for 60 seconds before doing the loop again.
    sleep 60s

done

3
29.07.2020, 00:22
1 ответ

У NVIDIA есть несколько скриптов, которые вы должны добавить в свою systemd приостановку/возобновление(systemd-hibernate.service.requiresи systemd-suspend.service.requires), чтобы решить эту проблему. Для получения дополнительной информации, пожалуйста, прочитайте:

https://download.nvidia.com/XFree86/Linux-x86_64/450.57/README/powermanagement.html

2
18.03.2021, 23:16

Теги

Похожие вопросы