Code44free's Blog

Ubuntu 12.04 tips & tricks

Posted in linux by code44free on January 3, 2014

How to disable screen blanking while mplayer is running
Mplayer freezes and stopping while play movie
Disable external monitor turn off when notebook lid is closed
Set HDMI sound output automatically on cable plugin/out


– How to disable screen blanking while mplayer is running

add to ~/.mplayer/config

stop-xscreensaver=1

– Mplayer freezes and stopping with error report:

[AO_ALSA] Write error: Broken pipe
[AO_ALSA] Trying to reset soundcard.

add to ~/.mplayer/config

ao=sdl,oss

or another preferred sound system from output

$ mplayer -ao help

– Disable external monitor turn off when notebook lid is closed

add to the beginning /etc/acpi/lid.sh command exit 0


#!/bin/bash

exit 0

test -f /usr/share/acpi-support/state-funcs || exit 0

– Set HDMI sound output automatically on cable plugin/out

Create file /etc/udev/rules.d/hdmi_sound.rules as root with following content:


SUBSYSTEM=="drm", ACTION=="change", RUN+="/usr/local/bin/hdmi_sound_toggle"

Create script /usr/local/bin/hdmi_sound_toggle with the content:

#!/bin/sh
USER=`who | grep tty | awk {' print $1 '}`
HDMI_STATUS=`cat /sys/class/drm/card0/*HDMI*/status`
PACTL=/usr/bin/pactl

if [ $HDMI_STATUS = "connected" ]
then
        sudo -u $USER $PACTL set-card-profile 0 output:hdmi-stereo+input:analog-stereo
else
        sudo -u $USER $PACTL set-card-profile 0 output:analog-stereo+input:analog-stereo
fi

make it executable and reload udev rules:

$ sudo chmod +x /usr/local/bin/hdmi_sound_toggle
$ sudo udevadm control --reload-rules

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: