How to configure Power Management by Command Line?

I would like to configure Power Management by command line (CLI) on Ubuntu MATE.

I am already familiar with the GUI to configure Power Management on Ubuntu MATE 20.04 as shown below:

Control Center > Hardware >

  Power Management

    On AC Power tab

      Actions
        Put computer to sleep when inactive for:  Never

      Display
        Put display to sleep when inactive for:   Never


    General tab

      Actions
        When the power button is pressed:    Suspend
        When the suspend button is pressed:  Suspend

I would like to know the following three things.

  1. command statements on command line to set the values of Power Management as shown above

  2. the path to the configuration file that stores the Power Management configuration, and its keys and values to reflect the settings shown above

  3. how to force the new settings of Power Management to take effect promptly without rebooting the computer

Note in particular that, as "Never" indicates above, I want to prevent the display from being automatically put to sleep.


Solution 1:

You can set and apply these settings using

  • GSettings backend with commands below:

    gsettings set org.mate.power-manager sleep-computer-ac 0
    gsettings set org.mate.power-manager sleep-display-ac 0
    
    gsettings set org.mate.power-manager button-power 'suspend'
    gsettings set org.mate.power-manager button-suspend 'suspend'
    
  • DConf backend with single long command below:

    cat <<EOF | dconf load /org/mate/power-manager/
    [/]
    sleep-computer-ac=0
    sleep-display-ac=0
    button-power='suspend'
    button-suspend='suspend'
    EOF