HTPCHouse.com

  • Increase font size
  • Default font size
  • Decrease font size
Home Configuration Miscellaneous

Misc Home Theater PC tweaks

E-mail Print PDF

Additional repositories

Debian's main issue, at least as far our HTPC setup is considered, is its policy not to support any non-free component in its official release. Although noble, such policy also cuts off support for most audio/video codecs and applications that relies on them (mplayer, for example). Luckily, lots of semi-official repos are available on the Net, and all we have to do is include their addresses in /etc/apt/sources.list file:

deb http://debian-mirrors.sdinet.de/debian-multimedia testing main
deb-src http://debian-mirrors.sdinet.de/debian-multimedia testing main

Tweak udev

Udev is most popular service for mapping hardware devices to /dev filesystem nodes. It's a bit obscure, but is also very powerful and very very well documented. What we'll need it for is to make custom automounter for USB disk drives and to make order in naming video devices. Although USB automounting is also available through autofs (which we use for automounting DVD-ROM drives), udev provides better control over naming mount points which is important if you often plug more than one USB disk drive. udev rule that I'm using look like this:

KERNEL=="sd*[0-9]|dasd*[0-9]", ENV{ID_SERIAL}=="?*", \

RUN+="/usr/local/bin/mount_usb $env{ID_BUS}-$env{ID_SERIAL}-part%n"

Enter this rule in file /etc/udev/rules.d/z900_mount-usb.rules, restart udev and download script mount_usb from download section to your /usr/local/bin/ directory. Script itself if pretty self-explanatory.

But more importantly, udev allows us to make order with naming of Video4Linux devices: since for some strange reason, Linux on boot probes firstly USB devices and then PCI devices, if you boot you computer with USB camers pluged in, it will receive device node /dev/video0 and TV tuner card receives node /dev/video1 (and /dev/video2 if aou have card with two tuners). However, if you boot your box without USB webcam attached, TV tuner will be assigned to node /dev/video0 which makes impossible configuration of MythTV to work in both scenarios. My solution is to write custom udev rule to create symlinks that uniquely identify webcam's video and microphone device:

SUBSYSTEMS=="usb", SUBSYSTEM=="video4linux", \
ATTRS{idVendor}="046d", ATTRS{idProduct}=="08ad", SYMLINK+="webcam"
SUBSYSTEMS=="usb", SUBSYSTEM=="sound", KERNEL=="dsp[0-9]*", \
ATTRS{idVendor}="046d", ATTRS{idProduct}=="08ad", SYMLINK+="webcam_dsp"

This rule creates symlinks /dev/webcam and /dev/webcam_dsp that points to real dev nodes that kernel assigned to my devices, whatever they may be. Save them to file /etc/udev/rules.d/010_webcam.rules and use path to those symlinks in your application instead of paths to real dev nodes. Just note that you'll probably have to tweak idVendor and idProduct attributes to match your webcam. Similar tweak I applied to my TV tuner, look for file 010_ivtv.rules in download section.

Automounting optical drives

Since optical drives are physically mounted and are not hot-pluggable (drives, not medias) and also media from them can not be ejected while they are mounted, udev rules for (un)mounting do not suite well. For that reason, to automount my two optical drives I'm using autofs - look for my auto.master and auto.optical files in download section. They provides custom automount points in /var/autofs/optical/ that I symlink from /media/ directory which holds all my automatically mounted devices.

Reconfigure Power and Reset switches

Case buttons for powering your box and performing cold restart are not of any use to us with their default functions. However, power switch is ACPI event that can be easily reconfigured to perform any action that we want. For powering down your box, if you need that function for anything, use some GUI invocable script, possibly accessible through one of the global remote keys. Note that function of Power switch in its low-level mode (press and hold for 4 seconds) is not configurable and can still be used for emergency unconditional powering down your box. Script that is called when you just press and immediately release Power button is /etc/acpi/powerbtn.sh - in my case it displays GUI dialog prompting for user confirmation and then restarts all relevant services (kills X session of TV on VT 8, restart MythBackend daemon etc.) - look for it in download section. I'm using this way to quickly repair my box without use of keyboard in case any component hangs up or crashes (most often it is MythTV).

Reset button is unfortunately not programmable and I considered it harmful and obsolete: accidentally pressing it would immediately restart whole HTPC and with kids moving around your room, it happens more often than you think :). And if I still need emergency restart, I'm using press-and-hold action of power switch, and reset switch is physically disconnected from motherboard and has no effect whatsoever.


Hack DPI settings

Graphical user interface of X server provides very decent support for display devices of various resolutions and physical dimensions. In other words, X "knows" physical dimensions of your displaying device and its resolution, so when you choose to display some font in size of 12 points (which is physical measure, independent of resolution in pixels on screen) it "knows" exactly how many pixels it should be wide and tall. Same goes for mostly all the other GUI elements and this is what makes X's and it's applications more resolution-independent than those on Microsoft Windows (to be honest, problem on MS Windows is not in OS itself which has decent support for different DPI settings, as it is in almost all applications which are hard-coded for default resolution of 96 DPI).

This configurable nature of X and its applications comes handy when we notice that default sizes of GUI elements are defined so that they are perfectly visible from distance of approximately 50 cm which is your average distance from your computer monitor. With HTPC's display, however, situation is a bit different: you are going to watch you screen from the distance of several meters and fonts with physical size in several millimeters are just too small to be readable. Simple solution would be to just increase size of your fonts, but that would still leave other GUI elements on their default, way too small dimensions. Moreover, large fonts would look awful if you remotely start GUI applications from HTPC box on different machines using their local displays (that *are* watched from distance of ~50 cm).

Small hack that I found to work best in all cases (zoom all GUI elements on HTPC's display and leave everything as it is on others) is to override default DPI settings with xrandr. Simply place proper call to xrandr in your .xsession startup script giving it new DPI value before you start any graphical programs and all GUI elements will be properly scaled. Value of new DPI setting varies on your display's physical dimensions and its resolution, but as a general rule of thumb it is advisable to read the default value with command:

xdpyinfo | grep resolution

and to set new one three times bigger with xrandr:

xrandr --dpi <new value>

Disable X shutdown

For some unknown reason, most X setups still support old keyboard shortcut for immediate and unconditional killing of running X server: Ctrl+Alt+Backspace. Providing us nothing but trouble, it is advisable to disable it by placing the line:

Option "DontZap" "true"

to your /etc/X11/xorg.conf file in section ServerFlags (add it if it does not exist) and restart X.

 

Last Updated on Thursday, 14 February 2008 22:17