Nov. 5, 2015
I was always a bit confused about how to configure the root logger in Python. I guess I was mostly messing around instead of reading the documentation properly. While the
logger_root configuration options are mentioned several times, most of my logging configurations follow the natural path of parent logger names, up to a blank:
"". And this works for configuring the root logger (except for one corner case). Examples below.
But first, these are all equivalent:
They all log to the root logger, with "root" output as the logger name.
Using, for example,
logging.config.dictConfig(), it is possible to configure the root logger with the
root key (the official way):
Or by specifying a logger with an empty name:
By my experiments, they are equivalent, except that if both are specified, then the official
root takes precedence.
Tested in Python 2.7 and Python 3.4.
Feb. 2, 2013
Enabling XMonad in Lubuntu 12.10 by changing the window manager with
lxsession-edit (the GUI way of doing the same as in Using xmonad in LXDE) didn't quite work for me, but I found a solution.
It seems, from reading the lxsession run log (
~/.cache/lxsession/Lubuntu/run.log), that it actually looks for
lxsession-edit seems to maintain the latter.
I solved this with a symbolic link:
$ cd .config/lxsession
$ ln -s LXDE Lubuntu
Lubuntu -> LXDE
So now, both paths lead to the same configuration file. Voilà!
Finally, in order to keep some of the default Lubuntu settings, I replaced my
desktop.conf file with a modified copy of
/etc/xdg/lxsession/Lubuntu/desktop.conf (notice the "Lubuntu" in the path!).
Also, don't forget to replace the Desktop Pager panel applet with the WNCKPager. The Desktop Pager doesn't work very well with XMonad.
Aug. 6, 2012
Don't worry. It works. But there are some details that you might want to know about, and there are a few configurations to change in order to make the sound setup work nicely. This is a follow-up to HRT HeadStreamer and Xubuntu.
I have been testing with Xubuntu 11.10 and Lubuntu 12.04 on a couple of laptops. Xubuntu comes with PulseAudio 1.1, while Lubuntu comes with plain ALSA. Please be aware of that your favorite GNU/Linux distribution might offer alternatives, or provide different default configurations.
I ended up installing PulseAudio 1.1 on Lubuntu as well, in order to get some preferred behavior, but if you want to stick with ALSA, see the Asoundrc documentation on how to configure it. The dmix section should be of particular interest if you do not want applications to fight for their right to stream to the HRT HeadStreamer, but rather have all audio mixed into one stream before being sent to the HRT HeadStreamer. The suggested configuration worked for me.
Please note that this post is not really specific to the HRT HeadStreamer. It is specific to any pluggable audio device which does not have its own internal mixer. Any USB DAC might apply.
First, this is how I want my computer to behave, which frames everything that follows:
- By default, sound is only coming out of one audio device at a time (internal sound card with speakers or headphones, HRT HeadStreamer, ...). This is how things usually work out of the box.
- Any application can, at any time, output sound to the currently active audio device. The HRT HeadStreamer accepts only one stream, so software needs to merge the audio from the applications (which PulseAudio does, or ALSA configured to use dmix).
- When I plug in the HRT HeadStreamer, all sound should be automatically directed to it.
- When I disconnect the HRT HeadStreamer, all sound should be automatically directed to the internal sound card.
Ideally, I want (I think) to be able to choose, in a preferences dialog, which audio device should be currently active, and which should automatically take priority when plugged/unplugged. I do not have a solution to this, though. It might require developing a new module to PulseAudio, and slapping some nice user interface on top. I am not up for the challenge.
Make sure you have the PulseAudio volume control (pavucontrol) installed! In addition to managing volumes, it can give you an idea of the current situation. It also lets you control which application should output to which audio device, while the application does so. This feature is not very useful to me, although I do not mind the option.
Make sure ALSA is configured to forward audio to PulseAudio, so that applications that would typically use ALSA are picked up. This seems to work out of the box, just by installing PulseAudio, but any custom /etc/asound.conf or ~/.asoundrc file could interfere. If you really need such a configuration file, see the PulseAudio documentation on configuring ALSA.
In order to make the HRT HeadStreamer the default device, you need to set this in the /etc/pulse/default.pa configuration file. First, you need to find the sink name by using the pactl command:
$ pactl list sinks short
0 alsa_output.pci-0000_00_1b.0.analog-stereo module-alsa-card.c s16le 2ch 44100Hz RUNNING
1 alsa_output.usb-www.hirestech.com_2012_Rev_1.2_HeadStreamer-00-HeadStreamer.analog-stereo module-alsa-card.c s16le 2ch 44100Hz SUSPENDED
The second column contains the rather long name. Now add this to the end of /etc/pulse/default.pa as follows:
### Make some devices default
With this, if the HRT HeadStreamer is connected when PulseAudio starts up (for example when you log in), the HRT HeadStreamer will be used by default. It is a good start, but not enough.
If you unplug the HRT HeadStreamer, the audio will be redirected to the internal sound card (by PulseAudio's module-rescue-streams(?)). But if you reconnect the HRT HeadStreamer, nothing is restored until you restart PulseAudio. You could change all streams manually to use the HRT HeadStreamer in the PulseAudio volume control panel, but there is a better way.
To make PulseAudio automatically move all audio to the HRT HeadStreamer when it is reconnected, make PulseAudio load module-switch-on-connect in the /etc/pulse/default.pa configuration file. I placed it just below module-switch-on-port-available, like this:
While module-switch-on-port-available triggers on (un)plugging of headphones on the internal sound card, module-switch-on-connect triggers on connecting devices. This is sweet (although, I would prefer if it could base the switching on a list of preferred devices instead of just the default).
The changes take effect when you restart PulseAudio, for example by logging out and in again. Xubuntu is set up to restart PulseAudio whenever it is killed, so there you can simply run pulseaudio -k instead. In my current Lubuntu, lxpanel seems to go crazy (100% CPU) when PulseAudio is killed, so there I would recommend logging out and in again.
A few observations
In Lubuntu, the volume control applet in the panel seems to be stuck with whichever device was the default at startup, and does not seem to follow the automatic stream switching. In Xubuntu, it seems to work fine.
By default, PulseAudio is configured to resample all streams to 44100 Hz. You can override this in /etc/pulse/daemon.conf. If you like, set the default-sample-rate to something else (without any semi-colon in front). The LEDs on the HRT HeadStreamer reflect this setting.
Apparently, in PulseAudio 2.0, it will be possible to set multiple default sample rates. While this is very interesting, all my music seems to be in 44100 Hz, so it might not make a huge difference right away.