Turning Debian 11+LXDE into a HTPC

HTPCs are amazing devices, and everyone should really have one. HTPCs (Home Theatre Personal Computer)s, are dedicated devices that integrate with a home entertainment setup to serve and a centralized hub for managing media, and providing access to a variety of media sources, both internal an external.

I’ve found Debian 11 to be a pretty good base for an HTPC, there are however a few things that need to be changed to allow Debian to be used as a HTPC

Disable the screensaver: There is a xscreensaver line in the lxde autostart settings that will automatically blank the screen after a certain amount of time, this should be disabled:

Delete the xscreensaver line from /etc/xdg/lxsession/LXDE/autostart

Add user to sudoers to make things easier:

$ su
$ /sbin/usermod -a -G sudo mcarpenter

Install dependencies. These are needed for pyenv and a full python install, which is helpful for helper applications like our launcher.py.

$ sudo apt update
$ sudo apt install git build-essential libssl-dev zlib1g-dev \
libbz2-dev libreadline-dev libsqlite3-dev curl llvm \
libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev

Install pyenv for easy dependency management: https://github.com/pyenv/pyenv

I love pyenv, and try to use it as much as possible. It manages python dependencies and versions in a very lightweight low-impact way.

$ git clone https://github.com/pyenv/pyenv.git ~/.pyenv
$ echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
$ echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
$ echo 'eval "$(pyenv init -)"' >> ~/.bashrc

Install pyenv-virtualenv https://github.com/pyenv/pyenv-virtualenv

$ git clone https://github.com/pyenv/pyenv-virtualenv.git $(pyenv root)/plugins/pyenv-virtualenv
$ echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bashrc

Create autostart.sh. This is the script that will disable dpms screen blanking (This is very important! We disabled xscreensaver, but we also have to disable dpms!), and also launch our launcher application!

# Set display so xset and input both work properly for the primary display
export DISPLAY=:0
# Disable screenblanking and dpms.
# This keeps the screen from turning off
xset s noblank
xset -dpms

# Set up pyenv environment. ~/.bashrc can't be sourced from within scripts
export PYENV_ROOT="$HOME/.pyenv"
command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
pyenv activate launcher
cd /home/mcarpenter/code/launcher
# Run the launcher
python launcher.py

Install dependencies

cd ~/code/launcher
pyenv install 3.9.1
pyenv local 3.9.1
pyenv virtualenv launcher
pyenv activate launcher
pip install -r requirements.txt

Add autostart.sh to rc.local

Disable light-locker

In /etc/xdg/autostart$ sudo mv light-locker.desktop light-locker.desktop.bak

Last step is to grab the launcher from here: https://gist.github.com/malcom2073/7b1a78c58ff1cb4464702aac50b2e796

It’s a pretty simple script that listens for keyboard commands from a pre-programmed FLIRC device for starting youtube or netflix in a firefox window using Kiosk mode!

Leave a Reply

Your email address will not be published. Required fields are marked *