2012. január 28., szombat

2012. január 18., szerda

Deadlock with KDE in Ubuntu Natty

I don't have too much problems with my Ubuntu, but sometimes a zomby process appeared in the process list:

...
24456 ? 00:00:00 setxkbmap <defunct>
...

It was impossible to kill this process with kill -9 and the whole plasma desktop etc became unresponsive, I had to reboot my laptop...not too nice. I found the solution in a blog post.

Enhanced listing of the dead process (checking the parent process):

ps -ef | grep defunct | more

24456 1835 0 14:53 ? 00:00:00 [setxkbmap]
<defunct>

And ps -e | grep 1835, voilá:

1835 ? 00:04:53 kded4

My good old friend, the KDE daemon. It made infinite loops in Lucid time to time, so it is again time to kill:

killall -9 kded4

...and my KDE desktop recovers again.

2012. január 2., hétfő

Very slow VMWare performance (host: Ubuntu Linux, guest: Windows 7)

Suddenly, I have just experienced very poor performance with VMWare (host: Ubuntu Linux, guest: Windows 7) under KDE. The virtual machine did not respond to mouse events only every 10 seconds or so. It turned out, the problem was the suspended Desktop Effects under System Settings/Desktop Effects. Reenabling the Desktop Effects solved the problem.

2011. december 16., péntek

Git bash prompt in Midnight Commander (mc) subshell

Since the Midnight Commander overrides the PROMPT_COMMAND variable when it starts a new subshell, it is impossible to make a git prompt work without recompiling the mc. It is also an issue that the program has really poor documentation. It was quite hard for me to figure out how I can make it work:
- The major problem is hard-coded in the mc sources, so the attachment of this bug report should be applied to the mc sources and recompiled: https://www.midnight-commander.org/ticket/2027 (If you check the comments, the guys make flames instead of fixing the problem).
- When the mc is recompiled with the patch and installed, a new file should be created: ~/.mc/bashrc . This file contains executed commands when the new subshell starts, the example content of my ~/.mc/bashrc:

source ~/bash_git.sh
source bash_completion


Happy gitting with bash & mc! :)

2011. november 14., hétfő

Git info in bash prompt

I modified an existing script to have coloured git info on bash prompt. The original version:

https://gist.github.com/738048

The result (I use black background in gnome-terminal):

kecsap@sakura:~/something/something[master ⚡]$

My script:

RED="\[\033[0;31m\]"
YELLOW="\[\033[0;33m\]"
GREEN="\[\033[0;32m\]"
BLUE="\[\033[0;34m\]"
LIGHT_BLUE="\[\033[1;34m\]"
LIGHT_RED="\[\033[1;31m\]"
LIGHT_GREEN="\[\033[1;32m\]"
WHITE="\[\033[1;37m\]"
LIGHT_WHITE="\[\033[1;37m\]"
LIGHT_GRAY="\[\033[0;37m\]"
COLOR_NONE="\[\e[0m\]"

function parse_git_branch {

git rev-parse --git-dir &> /dev/null
git_status="$(git status 2> /dev/null)"
branch_pattern="^# On branch ([^${IFS}]*)"
remote_pattern="# Your branch is (.*) of"
diverge_pattern="# Your branch and (.*) have diverged"
if [[ ! ${git_status}} =~ "working directory clean" ]]; then
state="${LIGHT_RED}⚡"
fi
# add an else if or two here if you want to get more specific
if [[ ${git_status} =~ ${remote_pattern} ]]; then
if [[ ${BASH_REMATCH[1]} == "ahead" ]]; then
remote="${YELLOW}↑"
else
remote="${YELLOW}↓"
fi
fi
if [[ ${git_status} =~ ${diverge_pattern} ]]; then
remote="${YELLOW}↕"
fi
if [[ ${git_status} =~ ${branch_pattern} ]]; then
branch=${BASH_REMATCH[1]}
echo "${LIGHT_WHITE}[${COLOR_NONE}${branch} ${remote}${state}${LIGHT_WHITE}]${COLOR_NONE}"
fi
}

function prompt_func() {
previous_return_value=$?;
prompt="${USER}@${HOSTNAME}:${TITLEBAR}${LIGHT_GRAY}\w${GREEN}$(parse_git_branch)${COLOR_NONE}"
if test $previous_return_value -eq 0
then
PS1="${prompt}\$ "
else
PS1="${prompt}${LIGHT_RED}\$${COLOR_NONE} "
fi
}

PROMPT_COMMAND=prompt_func

2011. november 13., vasárnap

Moving LVM/LUKS partitions into a new hard drive

I received a new hard drive with bigger capacity and I wanted to move my old Ubuntu installation to the new drive. I connected both disks to a computer and boot from a LiveCD. I tried to use a simple dd command to copy the whole disk:

dd if=/dev/sda of=/dev/sdb

...but it failed to copy the encrypted (LVM/LUKS) partitions. I could unlock the partitions, but the new copy of the encrypted ext4 file system was half-destroyed during the copy process. I changed strategy since the new drive is bigger than the old one, I booted from the LiveCD and installed a new encrypted system with the maximal available space. I booted with the LiveCD again, mounted both disks, deleted the content of the new system and copied the old content to the new, unlocked partitions. I changed the grub/fstab and other config files to use the new UUIDs of the partitions, but the new hard drive did not boot. After updating the grub+initramfs, a strange thing happened. The system did not ask for passphrase to unlock the LVM, but I was dropped to the initramfs debug shell. I could unlock the encrypted partition and leave the debug shell, but the system wanted to ask for the passphrase after that. I found the solution on this Mint Linux forum topic: http://forums.linuxmint.com/viewtopic.php?f=189&t=83763

The solution was pretty easy: Delete the /etc/crypttab and create a new file /etc/initramfs-tools/conf.d/cryptroot with the following content:

CRYPTOPTS=target=sda5_crypt,source=/dev/sda5,lvm=LogicalVolumesOnEncryptedPartition-Root


It rocks now.

2011. november 1., kedd

Changing the Dropbox folder to a normal directory on Ubuntu

EDIT: The newer releases of the Dropbox client (1.2.x and above) has changed the database format into encrypted. The process of the blog post does not work with this newer releases anymore. However, there is a workaround: download the latest available stable 1.1.x version (1.1.35) from here, extract to the empty .dropbox_dist folder and make the the folder read-only for your dropbox user by making root the owner (eg. "sudo chown root:root ~/.dropbox_dist"). This method prevents the dropbox to update itself for newer versions.

I do not like the feature in the Dropbox client: it is not possible to setup a plain directory as DropBox folder, only "../something/Dropbox".

Here the tweak comes. The Dropbox uses sqlite to store the settings:

(0. Install sqlite3 package.)
1. Close the Dropbox client.
2. Go to your Dropbox folder:
cd ~/.dropbox
3. Convert the config.db to plain text
echo '.dump' | sqlite3 config.db > dump.txt
4. Search in dump.txt and edit the dropbox_path field to your desired directory location.
5. Close the dump.txt, delete or rename the old config.db to something else.
6. Convert the database back:
sqlite3 config.db < dump.txt
7. Restart the client and voilá, works.