Skip to content

Instantly share code, notes, and snippets.

@webghostx
Created June 17, 2024 15:13
Show Gist options
  • Save webghostx/1737cce10f21bf9747e465940d8c5e08 to your computer and use it in GitHub Desktop.
Save webghostx/1737cce10f21bf9747e465940d8c5e08 to your computer and use it in GitHub Desktop.

Deactivating HDMI Power Saving Mode on Lubuntu

This guide demonstrates how to disable the HDMI power saving mode on Lubuntu and automatically execute a script during system startup to ensure the screen remains active.

Step 1: Creating the Bash Script

  1. Open a terminal.

  2. Create a Bash script named prevent_hdmi_sleep.sh:

    nano ~/prevent_hdmi_sleep.sh
    
  3. Add the following content:

    #!/bin/bash
    
    # Disable HDMI power saving mode
    xset -display :0.0 dpms 0 0 0
  4. Save the script (Ctrl + O in Nano) and exit the editor (Ctrl + X).

  5. Make the script executable:

    chmod +x ~/prevent_hdmi_sleep.sh
    

Step 2: Creating the Desktop Entry for Autostart with a Variable

  1. Open the autostart directory:

    mkdir -p ~/.config/autostart/
    
  2. Create a new desktop file prevent_hdmi_sleep.desktop in the autostart directory:

    nano ~/.config/autostart/prevent_hdmi_sleep.desktop
    
  3. Add the following content:

    [Desktop Entry]
    Type=Application
    Exec=sh -c "sleep 5 && $HOME/prevent_hdmi_sleep.sh"
    Hidden=false
    NoDisplay=false
    X-GNOME-Autostart-enabled=true
    Name=Prevent HDMI Sleep
    Comment=Prevents HDMI power saving mode.
    • Exec=sh -c "sleep 5 && $HOME/prevent_hdmi_sleep.sh": This line executes the script located in the user's home directory ($HOME). Using sh -c "sleep 5 && ..." ensures the script runs with a slight delay after desktop startup (in this case, 5 seconds).
  4. Save the file (Ctrl + O in Nano) and exit the editor (Ctrl + X).

Step 3: Verification and Testing

  1. Ensure the script and the .desktop file are correctly created and configured:

    ls -l ~/prevent_hdmi_sleep.sh
    ls -l ~/.config/autostart/prevent_hdmi_sleep.desktop
    cat ~/.config/autostart/prevent_hdmi_sleep.desktop
  2. Restart your Lubuntu system and verify if the HDMI screen remains active and does not enter standby mode.

  3. After restarting, check the DPMS settings again to ensure Standby, Suspend, and Off are set to 0:

    xset -display :0.0 q

    Ensure the values now appear as follows:

    DPMS (Energy Star):
      Standby: 0
      Suspend: 0
      Off: 0
      ...
    

This guide provides a reliable method to deactivate the HDMI power saving mode on Lubuntu and ensure the settings persist after system restarts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment