петък, 21 декември 2012 г.

How to reset your root password

Couple of ways to reset your password, if you happen to mess it.
First, if you are in KDE (or whatever) and you know your sudo password, it is very easy to recover your pasword:
$sudo su -
$passwd
and type your new password.
(source)
And that's it.

If you happen to have lost your sudo password as well, you can do it the hardcore way.

First, you need to edit the kernel boot load in GRUB to reboot into single use mode by adding "init=/bin/sh". That's very useful if you screw your X and you cannot enter terminal the normal way.
Now, you have to remount the disk into read-write mode:
$mount -o rw,remount /dev/ROOT
in my case
$mount -o remount,rw /
Now do:
$nano /etc/shadow
and on the line root you need to remove everything between the first and second :
Then save and use
$password
to change your password. Then reboot. (source)
Third, there is the chroot way. I never done that, but I'll paste it here for completeness. And for desperate cases. Now, you need a LiveCD.
From it do:
$mount /dev/hda3 /mnt/gentoo
$mount /dev/hda1 /mnt/gentoo/boot
$mount -t proc none /mnt/gentoo/proc
where /dev/hda3 is your / , /dev/hda1 is your /boot, and /dev/hda2 is your swap.
Then do
$chroot /mnt/gentoo /bin/bash
which is supposed to change the environment from LiveCD to your PC. Sounds pretty creepy if you ask me.
Finally, do:
$passwd
and change your password. Then reboot and be happy.
(source)
P.S. If this way of chroot-ing doesn't help, then you can try:
# chroot /mnt/gentoo /bin/bash
# env-update
>> Regenerating /etc/ld.so.cache...
# source /etc/profile
# export PS1="(chroot) $PS1"
#passwd
(source)

понеделник, 17 декември 2012 г.

How to start samba on Gentoo (successfully)

I never managed to run samba successfully but today, we had a break trough.
So, here's how to run samba on Gentoo
0. To install samba:
$sudo equo install samba
1. If you don't have a smb.conf then do
$sudo cp /etc/samba/smb.conf.default /etc/samba/smb.conf
2. Add to smb.conf:
usershare allow guests = Yes
usershare max shares = 100
usershare owner only = False
3. Do (following http://ryan.rawswift.com/2009/03/04/how-to-share-folders-in-linux-using-samba/):
$ sudo mkdir /var/lib/samba/usershares
$ sudo chgrp users /var/lib/samba/usershares/
$ sudo chmod 1770 /var/lib/samba/usershares/
4. Then all you need to do is restart samba.
$sudo /etc/init.d/smb restart

If you happen to prefer gui for samba, there is a way. (see http://en.gentoo-wiki.com/wiki/Samba#GUI_administration or http://www.gentoo-wiki.info/HOWTO_Setup_Samba#SWAT)
0. If samba doesn't start on reboot:
$sudo rc-update add samba default
1. $sudo equo install xinetd
2. $rc-update add xinetd default (optional)
3. $echo "net-fs/samba swat" >> /etc/portage/package.use (optional)
4. $sudo nano /etc/xinetd.d/swat
In it, make sure that you have:
service swat
{
port = 901
socket_type = stream
wait = no
only_from = 0.0.0.0
user = root
server = /usr/sbin/swat
log_on_failure += USERID
disable = no
}
Check that: "disable=no"!
6. Now you need a root password for samba
$smbpasswd -a root (for samba <3.4.6)
or
$pdbedit -a -u root
7. /etc/init.d/xinetd restart
8. To enjoy the gui, type in Dolphin or Konqueror or Nautilus:
http://localhost:901/
If swat won't run, check your firewall settings.

After setting samba root password with "$smbpasswd -a root" we managed to mess the system root password (no idea how). To reset the root password, you can do:
$sudo su -
$passwd
(source)
Now, your root login should work and everything should be peachy. If when accessing your samba folder, it asks you for a password, then use "root" and the password you set with $pdbedit -a -u root

четвъртък, 13 декември 2012 г.

How to install a Gentoo ebuild on Sabayon

Maybe this one is pretty obvious, but I decided to paste it here just in case.
So you want to install some package, which is available in Gentoo's portage, but not in Sabayon's entropy. It turned out it's quite easy. Thanks to this site:

"Set PORTDIR_OVERLAY in /etc/make.conf to, say, /usr/portage/local then
mkdir -p /usr/portage/local/net-misc/wicd, copy the ebuild to that
directory then do
ebuild /usr/portage/local/net-misc/wicd/wicd-1.3.8-r1.ebuild manifest
and emerge it in the usual way."

In my case, I wanted to install BlueGriffon.
My PORTDIR_OVERLAY is  /usr/local/portage/myoverlay/"
I created: /usr/local/portage/myoverlay/dev-util/bluegriffon-bin
I copied the ebuilds I downloaded to this path.
and then I did:
$sudo ebuild bluegriffon-bin-1.5.2.ebuild manifest
$sudo emerge bluegriffon-bin-1.5.2.ebuild
On my first try, I got an error with eutils.eclass . You can find this file on this link and it should reside in /usr/portage/eclass/eutils.eclass .
I didn't need to download it manually from there, since doing
$sudo emerge --sync solved the problem.
And that was it! Blue Griffon is happily installed. 

понеделник, 10 декември 2012 г.

Youtube videos are blue

Oddly enough, I didn't have this problem on my laptop, but we had it on the other computer. After the most recent update, youtube videos got a blue tint. It looked quite nice, actually, but anyway. So a little googling led me to this site.
It turned out this problem is very easily solvable: you just have to turn off Hardware Acceleration from Settings (right click on any flash video).

To do this without clicking on the video (if for example nothing happens when you click on it) you can do
$sudo nano /etc/adobe/mms.cfg
where you should have:
EnableLinuxHWVideoDecode=1
OverrideGPUValidation=true


Interestingly enough, the computer which got this problem does not use NVIDIA video card, so I have no idea where the problem is. Turning off the Hardware Acceleration for Flash, however, solved the problem, without a noticeable increase in the CPU use. 

вторник, 4 декември 2012 г.

How (not) to rescue information from a broken memory stick

Ok, this wasn't a success story, or at least not for now, but I'm gonna paste here what I've done so far, just in case it might come handy one day.
The problem: my memory stick broke down. An 8GB Transcend. Needless to say how much I hate it. Anyway, from it, I need desperately to recover 1 file, but to no avail for the moment. There are my futile actions:
1. Use testdisk to recover the data. I have used testdisk to recover files from a messed up partition of my hard drive, so I know it works. The problem is that on the USB-stick it won't work - it lists only 10 or so files and among them is not the one I need. I used it, however to create an image of the drive. Well, it won't mount.
2. I had some doubts that maybe the geometry of the disk is wrong (after testdisk complained about it), so I wondered how to check it. Well, I used another Transcend stick, formatted similarly (fat 32, so that the car's stereo can read it) and I used the following commands:
$fdisk -l /dev/sdc
This displays the start and end blocks.
$sfdisk -g /dev/sdc
This shows the geometry of your device (cylinders, sector size and so on).
If you want to change the geometry without testdisk, you can use:
$sfdisk -C 21648 -H 19 -S 19 /dev/sdb
(source)
Just don't forget this is a dangerous operation so don't do it unless you're sure you need it.
3. Then I tried ddrescue. It's on entropy, so the installation is not a problem. The question was how to use it. I used this two site: site1, site2 to learn more.
In the end I did:
$ddrescue -r 3 /dev/sdc /some/folder/disk.img logfile
to copy the device.
(I didn't do "$fsck -y /dev/sda2/backup.img" to check if the image is healthy, but you could if you want)
Then I wanted to open the image:
$mount -o loop –t ntfs /some/folder/disk.img /mnt/folder2
It didn't work. Gave me an error in /dev/loop0 .
You could do
$dd if=/mnt/folder1/disk.img of=/dev/sdxn
to copy the image to another device, but I didn't have any at hand.
So this is my struggle for the moment. Any advice would be appreciated. 

неделя, 18 ноември 2012 г.

Finding out the rooters pppoe password

Ok, I'm not a fan of hacking or something, but it turned out that our new internet provider uses PPPOE password to identify the users and of course, they don't provide that password. The problem is that their router sucks and we want to use our own router which is much better. So the question was how to find the password. Well, it turned out there is a way.
In short, you have to make a backup file of your router configuration from its admin menu, and then to help comes this lovely program RouterPassView. It works with Wine, so you don't need Windows. To find the needed password, you just open the backup file with the program and Voila!
Searching for it, I also found this site for hacking your BSNL broadband router. Didn't try it, so I don't know if it works. Again, nothing illegal going on here, only me, getting the internet I paid for, without the assistance of the lousy router it comes with.

сряда, 14 ноември 2012 г.

pm-suspend not working after update of ati-drivers

For a long time, I kept my system using ati-drivers-12.5 to avoid the problems with the lack of support of my ATI Radeon video card (HD 2600). But after my latest update of the KDE (done with masked ati-drivers and ati-userspace) it turned out, I couldn't start X. So I decided to upgrade to the new 3.6 kernel and see what happens. A step before reverting to the ati open-source driver, I noticed that entropy features the 12.6 beta driver which I knew about, but could find when I needed it. So I decided to try it.
Well, it turned out it works fine. The official name is ati-drivers-12.6_beta_pre897. With it, you can use the latest kernel and KDE, the only thing you need to mask is ati-drivers>12.6 and ati-userspace>12.6 in /etc/entropy/packages/package.mask .  With it, everything works fine, including 3d acceleration and so on, so I am quite happy with it. The only problem I encountered was that suspend-to-RAM and suspend-to-disk didn't work, even though it worked fine before. After 3 days of digging, I found the root of the problem.
It turned out that in the lines of the kernel in GRU, one must include
radeon.modeset=0
"If a user installs Catalyst/FGLRX and kernel mode setting is not disabled for Radeon with radeon.modeset=0 on the kernel line in GRUB, then eventually the entire system will stop booting at the point where X should be loading, and the monitor will suspend itself since nothing is sending it a video signal. At this time, the system also stops responding to the keyboard so ctrl-alt-del or other key combinations to restart the system have no effect." (source)
Adding this line, and also the script below solved my problem completely:

=================
The original post of this script can be found here.
gksudo gedit /etc/pm/sleep.d/20_custom-ehci_hcd
or
sudo nano /etc/pm/sleep.d/20_custom-ehci_hcd

#!/bin/sh
#inspired by http://art.ubuntuforums.org/showpost.php?p=9744970&postcount=19
#...and http://thecodecentral.com/2011/01/18/fix-ubuntu-10-10-suspendhibernate-not-working-bug
# tidied by tqzzaa :)

VERSION=1.1
DEV_LIST=/tmp/usb-dev-list
DRIVERS_DIR=/sys/bus/pci/drivers
DRIVERS="ehci xhci" # ehci_hcd, xhci_hcd
HEX="[[:xdigit:]]"
MAX_BIND_ATTEMPTS=2
BIND_WAIT=0.1

unbindDev() {
echo -n > $DEV_LIST 2>/dev/null
for driver in $DRIVERS; do
DDIR=$DRIVERS_DIR/${driver}_hcd
for dev in `ls $DDIR 2>/dev/null | egrep "^$HEX+:$HEX+:$HEX"`; do
echo -n "$dev" > $DDIR/unbind
echo "$driver $dev" >> $DEV_LIST
done
done
}

bindDev() {
if [ -s $DEV_LIST ]; then
while read driver dev; do
DDIR=$DRIVERS_DIR/${driver}_hcd
while [ $((MAX_BIND_ATTEMPTS)) -gt 0 ]; do
echo -n "$dev" > $DDIR/bind
if [ ! -L "$DDIR/$dev" ]; then
sleep $BIND_WAIT
else
break
fi
MAX_BIND_ATTEMPTS=$((MAX_BIND_ATTEMPTS-1))
done
done < $DEV_LIST
fi
rm $DEV_LIST 2>/dev/null
}

case "$1" in
hibernate|suspend) unbindDev;;
resume|thaw) bindDev;;
esac

$sudo chmod 755 /etc/pm/sleep.d/20_custom-ehci_hcd
====================
I'm not sure if the script was needed or not, but the fact is that my system now suspends alright.
Other useful commands I discovered in the process:


To trace problems in pm-tools (remember, pm-tools fight with laptop-mode-tools, make sure to uninstall the second)
sudo sh -c "sync; echo 1 > /sys/power/pm_trace; pm-suspend"
(source)
Problems with DPMS   (Display Power Management)
You can manually invoke and control DPMS using the xset command line tool:

sleep 1; xset s activate

Or to turn the screensaver off:

sleep 1; xset dpms force off

You can also use commands standby, suspend, or on instead of off.

Another workaround is to disable DPMS in xorg.conf, by adding an option to your Monitor section:

Section "Monitor"
...
Option "DPMS" "Off"
EndSection
(source)
Other options of the kernel hich might work or not:
pcie_asm=off or nomodeset (source)


I also tried ("acpi_osi=Linux") , but it didn't help.

A German wiki for pm-utils (source).
Some cool stuff you could do with pm-utils (like setting up wake up alarms and so on) you can find here.
In case you would like to read more on laptop-mode-tools (which I used successfully with the previously kernel, along with pm-suspend), you can find here. With it, you can manipulate the default display brightness and so on.

неделя, 28 октомври 2012 г.

How to merge pdf files in Linux

Here are two very simple ways to merge pdf files:
pdftk *.pdf cat output onelargepdfile.pdf
Here, if you want the files to be merged in specific order, you can use:
pdftk name1.pdf name2.pdf name3.pdf cat output onelargepdfile.pdf
If you want to separate a large file on mane 1-page pdf files:
pdftk largepdfile.pdf burst
Another tool you can use to combine pdf-files is:
gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=combinedpdf.pdf -dBATCH 1.pdf 2.pdf 3.pdf
I used only the first method, but it worked great! Cheers!

сряда, 29 август 2012 г.

How to root your Xoom MZ601

Today, I just decided I need to root my Xoom. So here's how it went.
1. I updated to Android ICS 4.0.4 over the air. It was a pleasant surprise having this update, since it's the first update I get ever.
2. I search the net for a guide for rooting from 4.0.4 The files can be found on this one: http://www.xoomforums.com/forum/team-eos/16342-rom-ics-team-eos-ics-2-0-0-updated-2012-4-27-a.html and the tutorial in the second post of http://www.xoomforums.com/forum/motorola-xoom-development/15179-how-rookie-rooting-flashing-unrooting-under-one-roof.html .
I had some problem downloading the files since I couldn't find the file for my MZ601 so instead I downloaded one of the nightly releases i.e. EOS-umts_everest-20120826-109.zip
which along with gapps-ics-20120429-signed.zip were copied into my sdcard.
The file recovery-Tiamat-R4c-100611-1150-cwm.img went into two folders since I didn't know which one was the correct one: /opt/android-sdk-update-manager/platform-tools/ and /opt/android-sdk-update-manager/tools/
And then I just followed the instruction (note that I unlocked the device just after the Factory Reset using the way described in http://www.mokonamodoki.com/motorola-xoom-final-rescue : download the Motorola tools and run $./fastboot oem unlock ) 
3. Rooting was much easier that I expected. Generally, I followed the instructions to the word and it worked.
$./adb reboot bootloader
$./fastboot flash recovery recovery-Tiamat-R4c-100611-1150-cwm.img

Once you have verification on your device that this has been flashed:
Vol Up + Power.
Vol Down to enter the boot menue

After entering in "Android Recovery":
Hold Vol. Up to enter into recovery.

Then do:
 wipe cache,
 wipe factory data,
Advance->wipe dalvik cache

Then:
Iinstall zip from sdcard- > Choose zip from sdcard
Select the  EOS-umtsgapps-ics-20120429-signed.zipGapps and flash it and then reboot.
And that's it!
Everything was done in about 5 minutes. The system rebooted in about 3 - kind of slow, but I suspect it's because this is the first time it starts. Now, you have a glorious, customized, rooted Android 4.0.4.
YAAAAAY!
To unroot, you can use the third post in the same site.  There is an easier way to change curstom ROMs after the first root and it can be found on this site. It's done by using the goomanager.
Btw, I'm not sure if this ROM has a complete root or not, but one site suggests that you have to do (according to this site):
  • In the command window on your PC type; adb remount
  • Type; adb push su /system/bin
  • Type; adb shell
  • Type; ln -s /system/bin/su /system/xbin/su (this line starts with lower case “L”, like llama)
  • Type; chmod 4755 /system/bin/su
  • Type; exit
  • Type; adb push Superuser.apk /system/app
I have to try out my new Android first to see if those steps are needed, but it doesn't hurt having them posted here as well. 

неделя, 26 август 2012 г.

How to save data from a (soft) bricked Xoom

Well, even without trying to unlock or root my Xoom, I managed to brick it. I don't know how exactly it happened, I suspect it was the outcome of bad copying trough gMTP. Anyway, it got into this bootloader loop and it restarted over and over again. VERY ANNOYING!!! I was terrified, because I had some very important data on the tablet, since I use it for work. I asked and asked on the forums, but people obviously don't like answering such stupid questions. So, after tons of searching, here's what I did.

1. Install android-sdk-update-manager . If you happen to be on x64 system, install it twice - it should pull some Java emulation packages as well. Eventually, you have to run $env-update and $source /profile to sort out all the dependencies or whatever other problems.
2. Go in /opt/android-sdk-update-manager/tools and run $sudo ./android (you need to be root in order to install the stuff)
3. Install whatever you see fit, I installed Android 3.2 and the Tools
4. Afterwards, go into /opt/android-sdk-update-manager/platform-tools
5. There you'll find the ./adb and ./fastboot commands
6. Now, connect your Xoom trough the USB cable and just let it reboot and reboot and reboot - it doesn't matter
7. Run ./adb devices to see if your Xoom is listed. It should be, mine was listed.
8. To see your directory structure use ./adb -d shell and then you can use ls, cd and cd .. to look around (the -d option says to send the command to the only usb plugged in, so you shouldn't plug more than one device, otherwise you should use -s and the serial number)
9. After you find the directory that's important for you, just download it to your PC. I downloaded stuff from /sdcard doing:
$ ./adb -d pull /sdcard/folder /home/denijane/sdcard/folder
This way I pulled every directory in /sdcard one by one, because the Xoom kept on restarting and I didn't want to miss something, but maybe you can do it as a whole too, I don't know. Just make sure you have checked what you need has been copied to you PC.
10. After you download your stuff from the Xoom, you may Factory Reset it. To do so use: Power + Vol Up to reboot and while the screen displays Dual Core, press couple of times Vol Down to enter the boot menu and with Vol Down scroll until Android Recovery, then use Vol Up to select. After the weird screen shows up, you should press Power + Vol Up (I think) in order to get to the Recovery options. Then, choose Factory Reset and press Power to confirm. After it says Data Wiped, use Vol Up/Down to choose Reboot. That's it.

After you have reseted your Xoom, it's a good time to consider Unlocking it and eventually Rooting it. Unlocking would delete again all your data, so it makes sense to do it on a clean installation. Unlocking is easy, using the tools Motorola has published - you can find a description at http://www.mokonamodoki.com/motorola-xoom-final-rescue.
Yes, unlocking do void you of Warranty, but in some cases you can restore Stock OS and Relock, so I suspect you'll have your Warranty after all. Or maybe not, I don't know. But I was thinking, what's the point in having a cool device as Xoom, if you don't Unlock and Root it. It's just not fair. And it seems that complete Backups can be done only on a rooted device, so I think it's worthy the trouble.
Anyway, I'm so happy I could download my data from the Xoom. And the moral is good - always have important data stored at at least two places!
Have a good day!
Edit:
Here are some good wikis on ADB:
http://android-dls.com/wiki/index.php?title=ADB
http://developer.android.com/tools/help/adb.html
http://wiki.cyanogenmod.com/wiki/Howto:_Install_the_Android_SDK

петък, 17 август 2012 г.

How to install manually latex packages

Ok, TeX and LaTeX have wonderful wikis but still, I'd like to write down the steps I took today, so that I don't forget them.
So, to install those packages you need to:
1. Install TeX from wherever you like.
2. Download the packages from http://ctan.org/search/
3. Following this wiki, you need to unpack the zips to a folder.
4. Then you run latex filename.ins to unpack the styles (and you run it on every file in the folder)
5. If you want the div files with instructions, you can run latex filename.dtx, but I didn't bother with that.
6. Key part: where to put them. Thanks to this site, I found that you can check for the paths of your latex installation using:
kpsepath tex 
kpsepath bst
you can find the paths recognised by your tex installation, Then you need to put the folder with your packages into one of those paths. What I did was:
sudo cp -r ~/Latex/packages/ /usr/share/texmf/tex/latex/
sudo texhash
And that was it. I got all the packages working in no times. Yeah!

A nice way to check whether the installation is good is to run:
fmtutil-sys --all
After an update I had some problems, but it turned out that I had to remove two random files from my packages folder. 
 
Update, on my current installation, the tex files are in " /usr/share/texmf-dist/" so I had to do:
$sudo cp -r ~/Downloads/revtex.tds/* /usr/share/texmf-dist/
$ sudo mktexlsr
Note that Latex keeps the paths in  
$TEXMFCNF=/usr/share/texlive/texmf-dist/web2c:/usr/share/texmf/web2c:$HOME/texmf/web2c  
export TEXMFCNF
or $TEXMFHOME or elsewhere for Gentoo. 

петък, 10 август 2012 г.

How to mask ati-drivers

After the glorious update with ati-drivers-12.6 I turned up without a working video driver. I tried the open-source xf86-video-ati driver and surprisingly it worked quite well - I had 3d acceleration, flawless video and so on. I even managed to sort out the problem I had with kdm not logging in on start up (it was a rather stupid one - after removing ati-drivers and ati-space, the file /usr/lib64/xorg/modules/drivers/fglrx_drv.so didn't got removed and messed up the system - after removing it, kdm stopped complaining about drivers and everything worked fine).
Unfortunately, because of my work, I need to use the ati-driver (oh, well). So I was stuck with a non-working system, doomed to use an "old" driver, and I was kind of upset, because of the whole nonsense ATI put as trough.
Anyway, couple of re-installations later, here's the thing that made me happy:
1. I installed Sabayon 9, which has perfectly working ati-drivers-12.4 on a kernel-3.4.0
2. I masked the packages which could lead to the installation of ati-drivers-12.6 i.e. in the file /etc/entropy/packages/package.mask I added:
>x11-drivers/ati-drivers-12.5
>=media-libs/mesa-7.6
>=x11-base/xorg-server-1.12.1
>x11-drivers/ati-userspace-12.4
>=x11-base/xorg-drivers-1.11

Then I ran:
sudo equo update
sudo equo install kde-meta
And I got the newest KDE. Which was quite cool.
Now, if you want to update the kernel to for example >=sys-kernel/linux-sabayon-3.4-r5  I'd rather not. Maybe I did it in a wrong way, maybe not, but doing an sudo equo upgrade rendered my system completely useless, because of some mismatch between the mouse and keyboard drivers. I don't care. I'll just stay with the old kernel and enjoy my life with ati-drivers. Not that I love them so much, but right now, I just have no other option. So far I installed couple of packages (like amarok, smplayer and other stuff) and I didn't run into problems. So as long as you have those packages masked and you stay away from the kernel upgrade, things should be cool. You can even add a mask on the kernel, but when I did that, entropy complained everything gets masked so I removed it. But still, I'm very happy that after 3 days of pain, I finally got my system to work the way I want it to.

понеделник, 6 август 2012 г.

How to disable automatic fsck checks

First, to see the parameters of the checks, you can use:
tune2fs -l /dev/sda1
Then, if you would like to change them:
tune2fs -c 0 /dev/sda1
would disable the checks on maximum count number (for example, on my computer, fsck makes automatic check after 5 reboots).
You can increase the number to say 25 reboots:
tune2fs -c 25 /dev/sda1
Or you can alternatively, set a time limits for reboots using the -i option instead. For example, typing
tune2fs -c 0 -i 0 /dev/sda1
would turn off the checks completely.
For more info, check man tune2fs. 

сряда, 1 август 2012 г.

How to decrease brightness trough konsole

After the last update, it turned out that I cannot control the brightness of my laptop trough the keys. I was quite desperate, but after a day or two of searching, I found the problem. It turned out that in /sys/class/backlight/ I have two folders /sys/class/backlight/acpi_video0 and /sys/class/backlight/toshiba
Trying with echo 0 > /sys/class/backlight/toshiba/brightness turned out not to do the trick, while echo 0 > /sys/class/backlight/acpi_video0/brightness decreased the brightness on my screen. So obviously, my system looks for the screen controls in the toshiba folder.
I noticed this command in the kernel boot screen acpi_backlight=vendor, so I suppose I'll try it on the next restart. But at least, now I can control the brightness. YAY!
While digging the net, I found those two quite cool sites:
http://blog.fejes.ca/?p=510 It offers a script for controlling the brightness (And it works, I tested it).
https://bugs.archlinux.org/task/29543 This is actually a bug report, but you can see some useful kernel options.

събота, 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:

$mtp-detect

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: $

EAPI="2"

DESCRIPTION="MTPFS is a Fuse filesystem based on libmtp"
HOMEPAGE="http://adebenham.com/mtpfs"
SRC_URI="http://adebenham.com/debian/mtpfs_${PV}.orig.tar.gz"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~x86 ~amd64"
IUSE="debug"

DEPEND="sys-fs/fuse
      >=dev-libs/glib-2.18.4-r1
      media-libs/libmtp"
RDEPEND="${DEPEND}"

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'
   dodoc AUTHORS INSTALL NEWS README ChangeLog
}

pkg_postinst() {
   einfo "To mount your MTP device, issue:"
   einfo " /usr/bin/mtpfs <mountpoint>"
   einfo
   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.

EDIT:
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:
\fontsize{9pt}{11pt}\selectfont
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:
\documentclass[]{article}
\usepackage[T1
]{fontenc}
\usepackage{winfonts}
\renewcommand{\rmdefault}{georgia}
\renewcommand{\sfdefault}{verdana}
\renewcommand{\ttdefault}{courier-ttf
}
\begin{document}
dark \textsf{star} \texttt{13}
\end{document
}
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)
sysdefault:CARD=Intel
HDA Intel, ALC268 Analog
Default Audio Device
front:CARD=Intel,DEV=0
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)
(or
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

To:

[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

(source)
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!