3

I'm changing Rpi3 with Ubuntu Mate governor on user login to 'performance' but it seems like the kernel is changing the state back to original value after some time (ALSO THE 7" LCD SCREEN BRIGHTNESS).

How do I save my changes I set up at login to stay permanent (until next reboot)?

I could make this script run as service and check the value and adjust, but let's try not going that route.

I'm pretty sure It's not the script fault, but take a look:

#!/bin/bash

file='/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor'

init_file_read() {
    if [ $# -eq 2 ]; then
        file="$1"
        line="$2"

        if init_file_check "$file"; then
            echo "$(sed -n ${line}p $file)"
        fi
    fi
}

init_file_write() {
    if [ $# -eq 3 ]; then
        action="$1"
        file="$2"
        string="$3"

        if init_file_check "$file"; then
            if [ "$action" == "append" ]; then
                echo -e $(printf '%q' "$string") >> "$file"
            fi

            if [ "$action" == "write" ]; then
                echo -e $(printf '%q' "$string") > "$file"
            fi
        fi
    fi
}

init_file_check() { 
    if [ $# -eq 1 ]; then
        if [ -f "$1" ]; then
            return 0 # true
        fi
    fi

    return 1 # false
}

content="$( init_file_read "$file" 1 )"

if [ "$content" == "performance" ]; then
    echo "Performance on: performance"
else
    echo "Changing governor to: performance"

    init_file_write 'write' "$file" "performance"
fi

exit 0
  • have you checked if cpu temperature is a factor? – Mohammad Ali Feb 19 '17 at 1:48
  • No, I haven't. I have heat sinks and not expecting huge load on the CPU, but maybe I'll take a look. – HelpNeeder Feb 22 '17 at 16:25
  • Tell me the highest temp you see – Mohammad Ali Feb 22 '17 at 17:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.