Output switching
Weve been putting together an HTPC using a Dell Wyse 3040 thin client PC. We’re using Arch Linux as an OS, and installed media applications Kodi and Chromium (to give us Netflix). We also installed Openbox to provide a window manager, and set up control of applications via remote using FLIRC. Now I’d like extend my viewing options with an extra display.
Interested in more info on the Wyse 3040? ParkyTowers has a treasure trove of info on the hardware, disassembly, firmware, installing TinyCore Linux, and some further reading. Enjoy!
Wyse3040 Video Outputs
The Wyse 3040 is pretty small as computers go, about the size of a hand. It’s bigger than a Roku stick or a single-board computer like a Raspberry Pi or an Odroid, but still small. Thankfully on the back along with power, network and USB it packs in two DisplayPort outputs.
I’ve been using one output with a cheap active DisplayPort-HDMI adapter, which goes to the old Samsung 50″ plasma TV via an Onkyo audio receiver (HDMI in ? audio out via speakers + video out via HDMI). The problem is that plasma TVs are incredibly power-hungry.
I measured it, and got between ~250 and 325 W! That’s… not fun given energy bills have shot up (ca. 47p per kWh at time of writing). I don’t want to buy a whole new TV when i got this one for free when someone was disposing of it, but nor do I particularly want to fall asleep with the thing on all night! Extra-unfortunately it doesn’t standby when losing signal (a big deficit for a plasma TV- keeping that “No Signal” on the screen must be horrid for burn-in), nor does it have a sleep timer/mode.
Enter this tiny 15″ monitor! Drawing a respectable 9W, if I did fall asleep with this on it would still consume less power than an hour of watching the plasma TV. Even better, it does sleep when it loses signal, so I can configure Kodi to disable the display output when idle and the monitor will drop to standby for even more power savings. I tested an old 15″ Dell monitor too, and it also draws 9W. I knew keeping those around for years would pay off!
Kodi Doesn’t Want to Switch Display
Having hooked the 15″ monitor via an active DisplayPort-VGA adapter (I can’t remember what I bought it for, but it came in handy!) I can see that Kodi runs just fine on a small resolution.
(: Side note: I remember when 1024×768 was a big step up from 800×600, around the Jedi Knight era? Not quite the dizzying heights of 1280×1024 in the BF2 days, but more than 1000 horizontal pixels- what a step up!)
Unfortunately, using Kodi’s own menu didn’t actually change the display; just made it display the 1280×720 TV-sized output on the monitor itself. D’oh. I was able to get this working via xrandr
:
# Monitor xrandr --output DP-1 --primary --mode 1024x768 --pos 0x0 --rotate normal --output HDMI-1 --off --output DP-2 --off --output HDMI-2 --off --output DP-3 --off --output HDMI-3 --off # TV xrandr --output DP-1 --off --output HDMI-1 --off --output DP-2 --off --output HDMI-2 --off --output DP-3 --off --output HDMI-3 --primary --mode 1280x720 --pos 0x0 --rotate normal
From there I created one liner executable scripts with these incantations, and hey presto! I can change resolution from the command line (remembering to prefix with DISPLAY=:0
), which is nice, if a little inconvenient.
Kodi Loses Text and Updating Arch
Unfortunately, something in here caused Kodi to forget how to display text after playing a video or going into screen-dim mode.
It turns out this was a known issue, which was subsequently fixed in a merged PR. This being an HTPC — motto: “get it working then don’t dare touch it” — it hadn’t been updated in quite a while (er, 2020) and was still running Kodi 18.8.
Arch needed to be updated, and good practice is to:
- review the homepage for breaking changes
- update
archlinux-keyring
(avoids eg “error: libffi: signature from "Levente Polyak (anthraxx) levente@leventepolyak.net" is unknown trust
“) - full system update
Unfortunately I hit a couple of stumbling blocks:
pacman claims that “archlinux-keyring-20210110-1 is up to date”
For some reason, the mirror I had a the top of my mirrorlist (/etc/pacman.d/mirrorlist
), UK Fast, was distressingly out-of-date. Using Mirrorservice sorted that and got archlinux-keyring 20220424-1
installed nicely.
pacman: error: Partition / too full: 237835 blocks needed, 90267 blocks free
(ie Wyse3040 is too small to update)
Oh, um.
df -h /
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg-root 6.7G 6.0G 353M 95% /
That’s a problem. The Wyse3040 I have has a comparatively tiny amount of storage. I went through the filesystem with ncdu
and removed a few bits of low-hanging fruit, but it was clear deleting a few things here and there wasn’t going to butter the parsnips.
Instead I remote-mounted the package cache (/var/cache/pacman/pkg
) on my desktop PC. If that sounds horribly janky to you… you’d be right. But it worked!
Side note: no chance it would have succeeded on the Wyse-
# on PC
$ du -sh /tmp/wyse3040/
1.9G /tmp/wyse3040/
# <.< >.>
Switching Outputs Nicely
Now that we have a script that can switch between the monitor and a TV, it’s time to make it work more conveniently than ssh-ing in from a phone. Yup, it’s FLIRC time again!
[ flirc image ]
My preference is to map this on to the audio receiver’s remote. I think this works better than the TV remote for a couple of reasons:
- there’s quite a lot mapped on there, and I don’t want to accidentally hit the “change output” button[s] during normal video interaction- “I meant to hit pause, or mute, where did the picture go?”
- I already have audio balance (all L / all R / centre) mapped on the audio receiver remote, and this feels like a video analogue- instead of shifting the direction the audio si coming from, I’m shifting the direction the video is coming from
First, set up (add) the keyboard shortcuts in (to) ~/.config/openbox/rc.xml
:
<?xml version="1.0" encoding="UTF-8"?> <openbox_config xmlns="http://openbox.org/3.4/rc" xmlns:xi="http://www.w3.org/2001/XInclude"> <keyboard> <!-- Run Kodi or Netflix --> <keybind key="W-k"> <action name="Execute"> <command>/home/robert/code/media_switcher/media_switcher.sh "kodi"</command> </action> </keybind> <keybind key="W-n"> <action name="Execute"> <command>/home/robert/code/media_switcher/media_switcher.sh "netflix"</command> </action> </keybind> <keybind key="W-c"> <action name="Execute"> <command>killall chromium && chromium &</command> </action> </keybind> <!-- Change audio balance L | C | R --> <keybind key="W-4"> <action name="Execute"> <command>/home/robert/scripts/balance.sh left</command> </action> </keybind> <keybind key="W-5"> <action name="Execute"> <command>/home/robert/scripts/balance.sh centre</command> </action> </keybind> <keybind key="W-6"> <action name="Execute"> <command>/home/robert/scripts/balance.sh right</command> </action> </keybind> <!-- Switch between TV and monitor --> <keybind key="W-7"> <action name="Execute"> <command>/home/robert/.screenlayout/mon.sh</command> </action> </keybind> <keybind key="W-9"> <action name="Execute"> <command>/home/robert/.screenlayout/tv.sh</command> </action> </keybind> </keyboard> </openbox_config>
The latter two entries map ? Win + 7 and ? Win + 9 to the monitor and TV xrandr scripts respectively.
Then in FLIRC:
Done!
I’ve followed this walkthrough and can’t seem to wrap my head around why the video gets so choppy. What version of Arch / Kodi did you install for this? did you get smooth playback?
Hi Dan, sorry to hear you’re having trouble with this. I am currently running Kodi 19.4-5 according to pacman, and I probably would have installed the from the 2020.1 archiso originally.
Is it all video that is choppy? I’ve not tried any 4k content as my TV is 720p, the highest I’ve gone are 1080 video sources. I’ve also had choppy playback with certain video sources- AI upscales are sometimes encoded in yuv444p, which seems to cause issues; I’ve had to re-encode those to a different pixel format (yuv420p).
Just got a 3040 and have had a hell of a time getting linux on it. Tried gui ubuntu/kubuntu/raspbian (x86) and clearOS with no success. They just halted during the setup. Might have been because i wiped the partitions on the 8gb emmc.
Then I tried DietPi at the suggestion of some RasPi youtube video. Turns out it is a freaking magic wand. Partitioned the storage and installed cleanly, though it took about 20 mins. It has a KODI package, but i have not tried it out yet. Very impressed and suggest you try it!
i’ve installed debian 11 on these and plan to use them as a device to playback random episodes of the simpsons and a few other shows on infinite shuffle / repeat.
you can install Debian pretty easily on this but just make sure to run the ‘expert installer’ and ensure you select ‘Yes’ for the grub option to ‘Force extra installation to the EFI removable media path?’