Im_Int
Posts: 2
Joined: Sat Jan 13, 2018 3:45 am

How to disable HDMI in the absence of user input during boot-up?

Sat Jan 13, 2018 5:19 am

I have a bash script that asks the user whether to keep HDMI on, and if no key is pressed within 10 seconds, HDMI is turned off. Unfortunately, calling this script from /etc/rc.local doesn't work — there's no prompt, and HDMI always ends up switched off. If I call the script manually from CLI, everything works as it should.

Code: Select all

#!/bin/bash
if read -n1 -s -r -t10 -p $'Press any key to keep HDMI on\n' KEY
then
    echo "HDMI will remain on"
else
    /usr/bin/tvservice -o
fi

klricks
Posts: 4936
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA
Contact: Website

Re: How to disable HDMI in the absence of user input during boot-up?

Sun Jan 14, 2018 2:44 am

If you are booting to GUI then using autostart is easier. Here is a recent thread with info on how to:viewtopic.php?f=63&t=199672#p1258334
Go here for my RPi writeup. Basic config, Serial Port add-on etc:
http://blackeagle12.net/Comp/RPi/Rpi.html Click contact icon then world icon --->

User avatar
DougieLawson
Posts: 30935
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: How to disable HDMI in the absence of user input during boot-up?

Sun Jan 14, 2018 9:52 am

If you pull the HDMI cable then your Raspberry will automatically disable any HDMI function (unless you force HDMI use in /boot/config.txt).
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

Since 2012: 1B*5, 2B*2, B+, A+, Zero*2, 3B*3

Please post ALL technical questions on the forum. Do not send private messages.

Im_Int
Posts: 2
Joined: Sat Jan 13, 2018 3:45 am

Re: How to disable HDMI in the absence of user input during boot-up?

Tue Jan 16, 2018 1:03 am

DougieLawson wrote:
Sun Jan 14, 2018 9:52 am
If you pull the HDMI cable then your Raspberry will automatically disable any HDMI function (unless you force HDMI use in /boot/config.txt).
I have all HDMI lines commented off in /boot/config.txt (it's a mint installation of raspbian) but /usr/bin/tvservice -o shaves off 20 mA even with the HDMI cable not plugged in

Return to “Raspbian”

Who is online

Users browsing this forum: raunaqss and 34 guests