Skip to content
This repository was archived by the owner on Apr 5, 2024. It is now read-only.

Commit 1f6d5f2

Browse files
committed
add ability to switch HDMI displays with scheduler
Change-type: minor
1 parent adb1574 commit 1f6d5f2

File tree

4 files changed

+52
-4
lines changed

4 files changed

+52
-4
lines changed

scheduler/Dockerfile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,28 @@ FROM balenalib/raspberrypi3-alpine
33
COPY scripts /usr/src/
44
RUN chmod +x /usr/src/*.sh
55

6+
RUN apk --no-cache add raspberrypi raspberrypi-libs raspberrypi-dev alpine-sdk \
7+
eudev-dev python3-dev libxrandr-dev swig \
8+
p8-platform-dev cmake && \
9+
adduser -S builder -G abuild
10+
11+
USER builder
12+
13+
RUN cd && \
14+
wget https://git.alpinelinux.org/aports/plain/community/libcec/APKBUILD && \
15+
sed -i \
16+
-e '23a-DRPI_INCLUDE_DIR=/opt/vc/include \\' \
17+
-e '23a-DRPI_LIB_DIR=/opt/vc/lib \\' \
18+
APKBUILD && \
19+
abuild-keygen -a -i && \
20+
abuild
21+
22+
USER root
23+
24+
RUN apk --allow-untrusted --no-cache add \
25+
/home/builder/packages/home/*/libcec-4*.apk && \
26+
deluser --remove-home builder && \
27+
apk del raspberrypi-dev alpine-sdk eudev-dev python3-dev libxrandr-dev \
28+
swig p8-platform-dev cmake
29+
630
CMD /usr/src/start.sh

scheduler/scripts/backlight_off.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,12 @@
11
#!/bin/bash
2-
echo -n 1 > /sys/class/backlight/rpi_backlight/bl_power
2+
3+
export PATH="$PATH:/opt/vc/bin/"
4+
export LD_LIBRARY_PATH="/opt/vc/lib/"
5+
6+
output=$(tvservice -s)
7+
8+
if [[ $output =~ "0x400000 [LCD]" ]]; then
9+
echo -n 1 > /sys/class/backlight/rpi_backlight/bl_power
10+
else
11+
echo standby 0 | cec-client -d 1 -s
12+
fi

scheduler/scripts/backlight_on.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,12 @@
11
#!/bin/bash
2-
echo -n 0 > /sys/class/backlight/rpi_backlight/bl_power
2+
3+
export PATH="$PATH:/opt/vc/bin/"
4+
export LD_LIBRARY_PATH="/opt/vc/lib/"
5+
6+
output=$(tvservice -s)
7+
8+
if [[ $output =~ "0x400000 [LCD]" ]]; then
9+
echo -n 0 > /sys/class/backlight/rpi_backlight/bl_power
10+
else
11+
echo as 0 | cec-client -d 1 -s
12+
fi

scheduler/scripts/start.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
#!/bin/bash
2+
23
if [ ! -z ${ENABLE_BACKLIGHT_TIMER+x} ] && [ "$ENABLE_BACKLIGHT_TIMER" -eq "1" ]
34
then
4-
(crontab -l; echo "${BACKLIGHT_ON:-0 8 * * *} /usr/src/backlight_on.sh") | crontab -
5-
(crontab -l; echo "${BACKLIGHT_OFF:-0 23 * * *} /usr/src/backlight_off.sh") | crontab -
5+
(
6+
crontab -l
7+
echo "${BACKLIGHT_ON:-0 8 * * *} /usr/src/backlight_on.sh"
8+
echo "${BACKLIGHT_OFF:-0 23 * * *} /usr/src/backlight_off.sh"
9+
) | crontab -
610
fi
711

812
crond -f

0 commit comments

Comments
 (0)