събота, 28 април 2012 г.

How to mount Motorola Xoom under Sabayon or Gentoo

I never had any problems with my Sabayon recognizing whatever I decided to plug in the usb port. Including my Android Sony Xperia. Obviously, things changed with Android, because yesterday, when I connected my Motorola Xoom, surprise, surprise, Sabayon wouldn't recognize it. After some research, it turned out that the nice people in Android decided to make our lives little bit happier by changing the protocols which Android uses so that now, it is not recognized as mass-storage device, but as media something. Anyway, here's what I discovered as a way to deal with the problem.

The whole thing is that you need mtpfs installed in order to be able to mount the Xoom. On Ubunto, that seems to happen without a problem as this link suggests. On Gentoo, that's not the case. So, here's what I found.

First, here's this site where the process of emerging mftps is described. It didn't work for me, but I suppose it's Sabayon related .

What worked for me was the description from this site, so I'll post here what I did. I did everything as root, though maybe sudo will do the job in most cases.

1. Put Xoom in debugging mode.  (it's done from Android's settings).

2. Connect your Xoom to the computer. You can test whether everything is ok by typing:


After some time (like a minute), this will print a lot of information, which might be eventually useful.

3. How to install mtpfs (following this site)

3.1. $mkdir -p /usr/local/portage/myoverlay (if you don't have it already)

3.2. Edit /etc/make.conf (with nano for example)

Add in the end of the file:

PORTDIR_OVERLAY="/usr/local/portage/myoverlay $PORTDIR_OVERLAY"

(the source site says something else, but this worked for me)

Save and exit.

4. The Ebuild (again from http://klaig.blogspot.com/2011/05/mount-xoomandroid-filesystem-while-in.html)
4.1. $cd /usr/local/portage/myoverlay  
       $mkdir -p sys-fs/mtpfs
       $cd sys-fs/mtpfs

4.4. $nano mtpfs-0.9.ebuild
And paste the following ebuild in the file:

# Copyright 1999-2009 Gentoo Foundation
# Copyright 1999-2009 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $


DESCRIPTION="MTPFS is a Fuse filesystem based on libmtp"

KEYWORDS="~x86 ~amd64"


src_configure() {
   econf $(use_enable debug) || die 'econf failed'

src_compile() {
   emake || die 'emake failed'

src_unpack() {
    unpack ${A}
    mv ${P}.orig ${P}

src_install() {
   emake DESTDIR="${D}" install || die 'installation failed'

pkg_postinst() {
   einfo "To mount your MTP device, issue:"
   einfo " /usr/bin/mtpfs <mountpoint>"
   einfo "To unmount your MTP device, issue:"
   einfo " /usr/bin/fusermount -u <mountpoint>"

5. Now you have to install it:

$ebuild mtpfs-0.9.ebuild digest
$emerge mtpfs

6. Now, you're ready to mount your Xoom:

$mkdir /mnt/xoom
$mtpfs -o allow_other /mnt/xoom

The Xoom can be found in /mnt/xoom (obviously) and that will allow you to transfer files via the USB. It didn't work completely flawlessly for me, but it managed to copy 6GB of movies, which were readable afterwards, so obviously it worked. To unmount, you should use:

$/usr/bin/fusermount -u /mnt/xoom

Now, if you'd like to automate the process, you can use the directions which are for Ubunto (i.e. this link), but I'm not so sure how this will work so I'll leave it for someone feeling more adventurous. I'm quite happy that the USB file transfer is finally working.

Another and easier way to mount Xoom in Gentoo is trough gMTP (http://gmtp.sourceforge.net/). It has nice interface and you can do everything trough GUI (though mtpfs allows you to use Dolphin on everything but then, it has the problem with copying attributes- see the comment). To install gMTP on my Sabayon, I had to install both pkgconfig and extutils-pkgconfig along with the requirements found on the site. Then you just follow the readme and it installs fine. The only thing I noted so far is that it connected to my Xoom after I did mtp-detect from the konsole. Don't know whether this is isolated case, but anyway. It works fine! YAY!!!

петък, 20 април 2012 г.

How to install Latex winfonts in Linux

As unbelievable as it is, for a second time this year, I need to redo scientific publications prepared in Latex, in a way that they will fit the Windows-based journal/proceedings. Shame for physicists and physics as a whole. People simply don't value real quality these days.
So after some wine-emulations of Mathtype, now I have to make a document title "Times New Roman, 9pt, bold". Oh, well.
My research didn't lead to satisfying solution, so I decided to make the whole document in the Times font using \usepackage{pslatex} which seems to do the job. The change of the size was done by:
Later I found this lovely instructions how to install winfonts under Linux, something which the README of the winfonts didn't inform me of.

1. download winfonts.zip from http://www.ctan.org/tex-archive/fonts/winfonts/
2. unzip it to your local texmf tree $unzip winfonts.zip -d ~/texmf.
3. make font files recognized by TeX.
$mkdir -p ~/texmf/fonts/TTF && cd ~/texmf/fonts/TTF && ln -s /usr/share/fonts/TTF
(assuming the font files such as verdana.ttf are under /usr/share/fonts/TTF)
3. $mktexlsr
4. $updmap --enable Map winfonts.map
5. To use them:
dark \textsf{star} \texttt{13}
It turns out that it's not that hard to install the fonts. Then, if you want to apply them only to certain text and not to the whole document, you can select them with \fontfamily{times-ttf}\selectfont{} And that's it.
I don't quite understand how I could need this information to start with, but since I obviously need to do stunts like this, this information is certainly very helpful.
Another Latex-related helpful link is: http://franz.kollmann.in/latex/latex.html
And also, the wiki for the page dimensions: http://en.wikibooks.org/wiki/LaTeX/Page_Layout#Page_dimensions

понеделник, 9 април 2012 г.

Pulse mixing sound from headphones and internal speakers

After the last update, I have a problem with the sound of my laptop - I have sound from the internal speakers, but if I plug in speakers or headphones, I get sound from both internal and external speakers. Which sucks since I can't listen to too loud music.

I still have to find the solution of this problem, but while searching, I found some useful commands I'd like to share.

First, how to gather information on your sound card and so on:
$lspci -v  
this will give you the sound card you're using (along with other useful stuff)
$aplay -l
this will give you the device of your sound card
$ cat /proc/asound/card0/codec* | grep Codec
this will give you the codec you're using.
For example, running those commands I get:
Audio device: Intel Corporation 82801H (ICH8 Family) HD Audio Controller (rev 03)
HDA Intel, ALC268 Analog
Default Audio Device
HDA Intel, ALC268 Analog

Codec: ALC268
Now that we have this info, we can use it to make our alsa.conf more usable, and eventually working better.
With the codec name, you can look in the file /usr/share/doc/alsa-base/river/HD-Audio-Models.txt.gz to find the models which work with it. Using this model name, you can then edit your: /etc/modprobe.d/alsa-base.conf (in my case the file is named alsa.conf) to add the following lines:
options snd-hda-intel model=$(MODEL)
alias snd-card-0 snd-hda-intel
options snd-hda-intel index=0 model=$model position_fix=1
and this should fix the problem with the headphones (source).
It should, but whether it would, I have no way of knowing since I'm still looking for the file HD-Audio-Models.txt.gz. It is ridiculous, but it seems to be missing from all the directories where it usually resides.
(Note that after you change alsa.conf, you need to restart alsa with
$/etc/init.d/alsa restart
and also, to reload the module snd-hda-intel with
$modprobe -r  snd-hda-intel&& modprobe  snd-hda-intel)

Another option is to change the following settings:
[Element Front]
switch = mute
volume = merge
override-map.1 = all-front
override-map.2 = front-left,front-right


[Element Front]
switch = ignore
volume = ignore
in /usr/share/pulseaudio/alsa-mixer/paths/analog-output-speaker.conf
(source) I still have to try this, but it seems reasonable to me.

One more suggestions I found is the following:
For example my card is card 0: H71 [Hoontech STA DSP24 Media 7.1], device 0: ICE1712 multi [ICE1712 multi] but according to this bug other cards such as M-Audio type cards are affected too.
In my example you will need to replace the "H71" with whatever the device says when you run asoundconf list
By editing this file,
gksudo gedit /etc/pulse/default.pa
and adding the following lines at the end, I now have a working pulseaudio in 8.10 64 bit.

# Added comment rod40cool - Run command "asoundconf list" to determine what to add after "device=hw:????"
# Added comment rod40cool - Make sure after pasting that there are only 2 lines below starting each with "load-module module..."
load-module module-alsa-sink sink_name=H71_out device=hw:H71 format=s32le channels=10 channel_map=left,right,aux0,aux1,aux2,aux3,aux4,au x5,aux6,aux7
load-module module-alsa-source source_name=H71_in device=hw:H71 format=s32le channels=12 channel_map=left,right,aux0,aux1,aux2,aux3,aux4,au x5,aux6,aux7,aux8,aux9

I yet have to try it out, since I'm not sure if I know my device name.

So, my problem has yet to be solved. However, I found one more interesting link I'd like to share and its about .asoundrc and how to make it play sound from two or more source in the same time. Well, it turns out it's easy. I used the code from this wiki (replacing "card 1 device 7" with "card 0 device 0" in my case) and it worked! Well, at least it didn't crash. Before I had some problems playing Amarok and something else, not anymore. Cool.

Finally, I found this Sabayon Wiki dedicated to sound which I have to try out. It offers an easier way to check whether certain model works or not which will be useful considering the fact my codec is not in the table. Oh well.  In any case, tomorrow is going to be a big day.
Have fun!

Update: As ridiculous as it might sound, I found a very simply solution of my problem. It turned out that I can mute the speakers of my laptop trough kmix. Ha ha ha. Well, this is not a perfect solution since when I start amarok for example, the Speakers are again maxed, but I think I solved this by fixing the value for the speakers in /usr/share/pulseaudio/alsa-mixer/paths/analog-output-speaker.conf and restarting alsa. Finally my speakers are saved!