Hmm, isn't it the headphone daemon that does this too? If not we'll have to poke thp ... again. But as Helmuth said, I wouldn't recommend making it a habit of plug/unplug the headophones a gazillion times. Sure the 3.5mm connector is pretty durable but it'll eventually break.
system_bus = dbus.SystemBus() def handler_func(device_path): if device_path == '/org/freedesktop/Hal/devices/computer_logicaldev_input_1' and settings.play_on_headset and not player.playing: player.play() system_bus.add_signal_receiver(handler_func, 'DeviceAdded', 'org.freedesktop.Hal.Manager', None, '/org/freedesktop/Hal/Manager')