Last active
August 19, 2025 15:10
-
-
Save gaulatti/05988590563a62505fc6394b239a5970 to your computer and use it in GitHub Desktop.
resolution
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ### ✅ Checking if it’s installed | |
| ```bash | |
| which wlr-randr | |
| ``` | |
| * If you see `/usr/bin/wlr-randr`, it’s already installed. | |
| * If nothing is returned, you’ll need to install it. | |
| --- | |
| ### 📦 Installing `wlr-randr` | |
| It’s part of the **wlroots utilities**. On Bookworm you can install it with: | |
| ```bash | |
| sudo apt update | |
| sudo apt install wlroots-utils | |
| ``` | |
| This package provides `wlr-randr` (and sometimes other Wayland tools). | |
| --- | |
| ### 🔍 Why not installed by default? | |
| * Raspberry Pi OS Bookworm ships with **Wayfire** (a Wayland compositor). | |
| * The core OS does not force-install all wlroots tools, since not everyone needs to change modes manually. | |
| * So you often need to add `wlroots-utils` yourself if you want `wlr-randr`. | |
| --- | |
| 👉 So: if `wlr-randr` already works for you, it means `wlroots-utils` was installed (maybe by default in your image or pulled as a dependency). If not, just install it with the command above and you’ll have it. | |
| --- | |
| # 1) Find the exact output name and mode | |
| In a terminal on the Pi (logged into the desktop): | |
| ```bash | |
| wlr-randr | |
| ``` | |
| Note the connector (e.g. `HDMI-A-1`) and the precise mode string you want (often `1280x720` or `1280x720@60`). Use those **exact** strings below. | |
| --- | |
| # 2) Create the user systemd unit | |
| ```bash | |
| mkdir -p ~/.config/systemd/user | |
| nano ~/.config/systemd/user/set-720p.service | |
| ``` | |
| Paste this (edit `HDMI-A-1` and the mode if yours differ): | |
| ```ini | |
| [Unit] | |
| Description=Set display to 1280x720 after the graphical session starts | |
| After=graphical-session.target | |
| PartOf=graphical-session.target | |
| [Service] | |
| Type=oneshot | |
| # Hand Wayland env to the service | |
| Environment=WAYLAND_DISPLAY=wayland-0 | |
| Environment=XDG_RUNTIME_DIR=%t | |
| # Tiny delay so the compositor is fully up | |
| ExecStartPre=/bin/sleep 2 | |
| # Direct one-shot call (no loops, no X11 fallback) | |
| ExecStart=/usr/bin/wlr-randr --output HDMI-A-1 --mode 1280x720 | |
| TimeoutStartSec=10 | |
| [Install] | |
| WantedBy=default.target | |
| ``` | |
| > If `wlr-randr` showed `1280x720@60`, use `--mode 1280x720@60`. | |
| --- | |
| # 3) Enable and start it (for your user) | |
| ```bash | |
| systemctl --user daemon-reload | |
| systemctl --user enable --now set-720p.service | |
| ``` | |
| Check status/logs: | |
| ```bash | |
| systemctl --user status set-720p.service | |
| journalctl --user -u set-720p.service -b --no-pager | |
| ``` | |
| Verify the mode: | |
| ```bash | |
| wlr-randr | |
| # Expect your HDMI output to show: 1280x720 ... (current) | |
| ``` | |
| --- | |
| ## Will it auto-launch at boot? | |
| **Yes — when your user session starts.** | |
| * If you use **auto-login to the desktop**, this runs automatically on boot. | |
| * If you **don’t** auto-login, it runs when you log in graphically. | |
| ### Make it run even without logging in (optional) | |
| Enable lingering so your user services start at boot: | |
| ```bash | |
| loginctl enable-linger "$USER" | |
| ``` | |
| > On Raspberry Pi OS, the simplest path is enabling **Desktop auto-login** (via `raspi-config` → *System Options* → *Boot / Auto Login* → *Desktop Autologin*). | |
| --- | |
| ## Edit/disable/remove later | |
| * Edit the command: | |
| ```bash | |
| nano ~/.config/systemd/user/set-720p.service | |
| systemctl --user daemon-reload | |
| systemctl --user restart set-720p.service | |
| ``` | |
| * Disable: | |
| ```bash | |
| systemctl --user disable --now set-720p.service | |
| ``` | |
| * Remove: | |
| ```bash | |
| rm ~/.config/systemd/user/set-720p.service | |
| systemctl --user daemon-reload | |
| ``` | |
| --- | |
| ### Troubleshooting (quick) | |
| * If it doesn’t change resolution, re-run: | |
| ```bash | |
| wlr-randr # confirm connector name & available mode | |
| journalctl --user -u set-720p.service -b --no-pager | |
| ``` | |
| * If your output isn’t `HDMI-A-1`, update the unit accordingly. | |
| * If your mode requires the refresh (e.g., `1280x720@60`), use that exact string. | |
| Nice—let’s chain your 720p step with an **mpv autostart** that runs after the resolution change. | |
| Below is a clean, **user-level** systemd unit for mpv that: | |
| * waits for your graphical session, | |
| * runs **after** the 720p unit, | |
| * restarts if mpv crashes, | |
| * uses your exact command/URL. | |
| --- | |
| # 1) (Assumed) You already have the 720p user unit | |
| If you don’t, create it first (this is the minimal Wayland one that worked for you): | |
| ```ini | |
| # ~/.config/systemd/user/set-720p.service | |
| [Unit] | |
| Description=Set display to 1280x720 after the graphical session starts | |
| After=graphical-session.target | |
| PartOf=graphical-session.target | |
| [Service] | |
| Type=oneshot | |
| Environment=WAYLAND_DISPLAY=wayland-0 | |
| Environment=XDG_RUNTIME_DIR=%t | |
| ExecStartPre=/bin/sleep 2 | |
| ExecStart=/usr/bin/wlr-randr --output HDMI-A-1 --mode 1280x720 | |
| TimeoutStartSec=10 | |
| [Install] | |
| WantedBy=default.target | |
| ``` | |
| Enable it (if not already): | |
| ```bash | |
| systemctl --user daemon-reload | |
| systemctl --user enable --now set-720p.service | |
| ``` | |
| --- | |
| # 2) Create the **mpv autostart** user service | |
| ```bash | |
| mkdir -p ~/.config/systemd/user | |
| nano ~/.config/systemd/user/play-stream.service | |
| ``` | |
| Paste this (the URL & flags are exactly what you used): | |
| ```ini | |
| [Unit] | |
| Description=Start mpv full-screen HLS after 720p is applied | |
| After=graphical-session.target set-720p.service | |
| Wants=set-720p.service | |
| PartOf=graphical-session.target | |
| [Service] | |
| Type=simple | |
| # mpv on Wayland usually runs via Xwayland; set DISPLAY to :0 | |
| Environment=DISPLAY=:0 | |
| # small delay so the 720p change is settled visually | |
| ExecStartPre=/bin/sleep 1 | |
| ExecStart=/usr/bin/mpv --fs \ | |
| --cache=yes \ | |
| --cache-secs=10 \ | |
| --demuxer-max-bytes=15MiB \ | |
| --demuxer-readahead-secs=5 \ | |
| --audio-spdif=off \ | |
| "https://jireh-5-hls-video-us-isp.dps.live/hls-video/339f69c6122f6d8f4574732c235f09b7683e31a5/bbtv/bbtv.smil/bbtv/livestream1/chunks.m3u8?dpssid=b299913362268a48296805ba&sid=ba5t1l1xb214888372268a48296805b8&ndvc=1" | |
| Restart=on-failure | |
| RestartSec=5 | |
| KillMode=control-group | |
| [Install] | |
| WantedBy=default.target | |
| ``` | |
| Enable & start: | |
| ```bash | |
| systemctl --user daemon-reload | |
| systemctl --user enable --now play-stream.service | |
| ``` | |
| --- | |
| # 3) Check it’s working | |
| ```bash | |
| systemctl --user status play-stream.service | |
| journalctl --user -u play-stream.service -b --no-pager | |
| ``` | |
| If you see the video on the HDMI screen in fullscreen, you’re set. | |
| --- | |
| ## Notes & tips | |
| * **Runs on boot?** Yes—this user service starts when your **graphical session** starts. If you use desktop auto-login (recommended), it comes up automatically on boot. | |
| * If you don’t auto-login, the service starts when you log in graphically. | |
| * To stop it: | |
| ```bash | |
| systemctl --user stop play-stream.service | |
| ``` | |
| To disable auto-start: | |
| ```bash | |
| systemctl --user disable play-stream.service | |
| ``` | |
| * If that URL changes often (tokens), consider putting it in a small file and ExecStart with `bash -lc 'mpv " $(cat ~/.config/stream.url) "'` so you only edit the file next time. | |
| Want me to bundle both units (720p + mpv) into a single “meta” unit or script? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment