Enable Bluetooth Headset on Jogger(2)

Since trying to enable BT headset failed on Ubuntu12.04 Server, I decide to try xubuntu version. So I download the image from http://joggler.exotica.org.uk/ubuntu/, then extract it to get the image.
###Get the filesystem Use fdisk to get the img layout

	root@joggler:/media/nfs/xubuntu# fdisk -l xubuntu_12.04-v1.4-ext4.img 
	                      Device Boot      Start         End      Blocks   Id  System
	xubuntu_12.04-v1.4-ext4.img1   *        2048      126975       62464    e  W95 FAT16 (LBA)
	xubuntu_12.04-v1.4-ext4.img2          126976      626687      249856   82  Linux swap / Solaris
	xubuntu_12.04-v1.4-ext4.img3          626688     7800831     3587072   83  Linux

So we can caculate the offset is 626688X512=320864256.
Use following commands to copy the filesystem out to the actual disk:

	$ mount ./xubuntu_12.04-v1.4-ext4.img  -o offset=320864256 /mnt3/
	$ mount /dev/uba5 /mnt
	$ cp -ar /mnt3/* /mnt/

My disk layout is:
playout.jpg ###Modification for bootup Xubuntu ####Add new item for grub: Get the disk labels:

	$ ls /dev/disk/by-label/
	Xubuntu  linux-boot  linux-root  linux-swap  mmc-boot  mmc-root

The newly added label “Xubuntu” is the one we store the filesystem of Xubuntu. We need to add a new item to point at this partition.

	root@joggler:/boot# cat grub.cfg
	loadfont /unicode.pf2
	terminal_output gfxterm
	set timeout=5
	menuentry "XUbuntu 12.04 LTS (Precise) - 3.2.32joggler1" {
	  linux /vmlinuz-3.2.32joggler1 root=LABEL=Xubuntu ro quiet splash text
	  initrd /initrd.img-3.2.32joggler1
	}

#####Change the fstab We have to change the root partition to “Xubuntu”

	root@joggler:/mnt3# cat /mnt3/etc/fstab
	# /etc/fstab: static file system information.
	#
	# Use 'blkid -o value -s UUID' to print the universally unique identifier
	# for a device; this may be used with UUID= as a more robust way to name
	# devices that works even if disks are added and removed. See fstab(5).
	#
	# <file system> <mount point>   <type>  <options>       <dump>  <pass>
	proc             /proc		proc	nodev,noexec,nosuid	0       0
	LABEL=Xubuntu	 /		ext4	errors=remount-ro,noatime		0       1
	LABEL=linux-boot /boot		vfat	defaults		0       0
	LABEL=linux-swap none		swap	sw			0       0

Now reboot to see if we could enter xubuntu? Since we cannot use keyboard in grub, we could only enable one distribution, this is different from the tranditional grub. ####Configure Bluetooth Install module for pulseaudio

	apt-get install pulseaudio-module-bluetooth

Then reboot. Currently connect the bluetooth, then in pulseaudio you will select the corresponding sound card. Enjoy it!
Tips for avoiding auto hiberate of usb disk, as root:

	$ crontab -e
	*/4 * * * * fdisk -l /dev/uba >/dev/null

Now your disk will never be hiberate, avoiding system from broken.

Enable Bluetooth headset on Joggler

###TroubleShooting on alsa Current user canot use alsamixer

	Trusty@joggler:~$ alsamixer 
	cannot open mixer: No such file or directory

This is because the current user is not in the “audio” group, use root to add current user into “audio” group:

	root@joggler:~# usermod -a -G audio Trusty

Unmute the channel:

	$ amixer sset Master unmute
	Simple mixer control 'Master',0
	  Capabilities: pvolume pswitch penum
	  Playback channels: Front Left - Front Right
	  Limits: Playback 0 - 31
	  Mono:
	  Front Left: Playback 24 [77%] [-10.50dB] [on]
	  Front Right: Playback 24 [77%] [-10.50dB] [on]

Now we can use wired headset for listening music. ###Setup Bluetooth Scan the available equipments:

	Trusty@joggler:~$ hcitool scan
	Scanning ...
		geougwoguw  geige 	
		geougwoguw  geige521
		geougwoguw  geige 	
		geougwoguw  geige723

Repair:

	bluez-simple-agent hci0 dd:64:22:KK:FF:BD repair

Then edit your /etc/asound.conf file:

	#/etc/asound.conf
	
	pcm.btheadset {
	   type plug
	   slave {
	       pcm {
	           type bluetooth
	           device XX:XX:XX:XX:XX:XX 
	           profile "auto"
	       }   
	   }   
	   hint {
	       show on
	       description "BT Headset"
	   }   
	}
	ctl.btheadset {
	  type bluetooth
	}  

mplayer using bluetooth:

	mplayer -ao alsa:device=btheadset bad.mp3

###Set the default sound card to bluetooth Edit the .asoundrc file.

	Trusty@joggler:~$ cat .asoundrc    
	pcm.!default {
	   type plug
	   slave {
	       pcm {
	           type bluetooth
	           device dd:64:22:KK:FF:BD
	           profile "auto"
	       }   
	   }   
	   hint {
	       show on
	       description "BT Headset"
	   }   
	}
	##ctl.btheadset {
	##  type bluetooth
	##}
	
	bluez-simple-agent hci0 dd:64:22:KK:FF:BD repair

Then edit your /etc/asound.conf file:

	#/etc/asound.conf
	
	pcm.btheadset {
	   type plug
	   slave {
	       pcm {
	           type bluetooth
	           device XX:XX:XX:XX:XX:XX 
	           profile "auto"
	       }   
	   }   
	   hint {
	       show on
	       description "BT Headset"
	   }   
	}
	ctl.btheadset {
	  type bluetooth
	}  

mplayer using bluetooth:

	mplayer -ao alsa:device=btheadset bad.mp3

###Set the default sound card to bluetooth TBD, here I meet lots of problems. Edit the .asoundrc file.

	
	
	apt-get autoremove pulseaudio
	pulseaudio --start

Why aplay -L and aplay -l will get different result? I have no idea.

Fastly search package infos in ArchLinux

You can use pkgfile to view the metadata of the pacman files:

	pacman -Ss pkgfile
	extra/pkgfile 11-1 [installed]
	    a pacman .files metadata explorer

Usage:

	pkgfile ls

Then you will see “ls” belogns to which package.

Alsa Configuration(Adding bluetooth headset

After upgrading 3.12.5, my archlinux dropped its alsa configuration, also I bought a new bluetooth headset MW600, following is the steps for catching back the alsa sound, and let bluetooth headset working together with alsa.
###Fetching back sound Found out the hadware

	$ sudo alsactl init
	Found hardware: "HDA-Intel" "Intel CougarPoint HDMI" "HDA:111d7605,103c3587,00100105 HDA:11c11040,103c3066,00100200 HDA:80862805,80860101,00100000" "0x103c" "0x161c"
	Hardware is initialized using a generic method

The acl should be reset via:

	sudo setfacl -m u:Trusty:rw /dev/snd/*

Bluetooth headset in ArchLinux

I have a Nokia bluetooth headset BH-105,and a bluetooth usb dongle. And I want to connect them together. Following are the steps.
###Software Preparation On ArchLinux, Install “bluez” and “bluez-utils”

	$ sudo pacman -S bluez bluez-utils
	$ sudo systemctl start bluetooth && sudo systemctl enable bluetooth