Skip to content

Commit 06eb1f2

Browse files
committed
Add support for rotating output, on RPi 7" touch screen
Signed-off-by: Joachim Wiberg <[email protected]>
1 parent e9d7f15 commit 06eb1f2

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ RUN apk add --no-cache \
3737
xf86-video-modesetting \
3838
xf86-input-libinput \
3939
xdpyinfo \
40+
xrandr \
4041
xinit
4142

4243
WORKDIR /app

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,32 @@ docker run --rm -it \
140140
/app/start.sh -d 30 0 2 6
141141
```
142142

143+
**With display rotation (e.g., RPi 7" touchscreen):**
144+
145+
```bash
146+
# Rotate display 180 degrees
147+
docker run --rm -it \
148+
--privileged \
149+
-v /dev/fb0:/dev/fb0 \
150+
-v /dev/tty1:/dev/tty1 \
151+
-e DISPLAY_ROTATE=inverted \
152+
ghcr.io/kernelkit/demo:latest
153+
```
154+
143155
#### Using docker-compose
144156

145157
```bash
146158
docker compose up
147159
```
148160

161+
#### Environment Variables
162+
163+
- **`DISPLAY_ROTATE`** - Rotate the display (values: `normal`, `left`, `right`, `inverted`)
164+
- `normal` - 0° (default)
165+
- `left` - 90° counter-clockwise
166+
- `right` - 90° clockwise
167+
- `inverted` - 180° upside down
168+
149169
**Notes:**
150170
- The container automatically detects if X11 is available via `xdpyinfo`
151171
- With X11: Uses the host's X server

start.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ else
3030
XPID=$!
3131
sleep 2
3232

33+
# Apply display rotation if requested
34+
if [ -n "$DISPLAY_ROTATE" ]; then
35+
echo "Applying display rotation: $DISPLAY_ROTATE"
36+
OUTPUT=$(DISPLAY=:0 xrandr | grep " connected" | head -1 | cut -d' ' -f1)
37+
DISPLAY=:0 xrandr --output "$OUTPUT" --rotate "$DISPLAY_ROTATE"
38+
fi
39+
3340
# Run demo in background so we can handle signals
3441
DISPLAY=:0 ./demo "$@" &
3542
DEMOPID=$!

0 commit comments

Comments
 (0)