Disable to insert '\n' mark on each quote with po-mode.el

The po-mode.el included 'gettext-el' package is useful for editing po files with emacs.
However, po-mode.el are always added '\n' on each msgstr quotes. This behavior is very annoyance in editing po files generated po4a.I memorize here how to disable this feature.
(NOTICE: This method is tested under gettext-el_0.18.1.1-5_all on debian sid. If applying on another version of gettext,it might cause unpredicable side effect.)

The solution is very simple, simply put following lisp codes into your .emacs file

;; customization for editing po files of po4a.
;; override converting form function to
;; avoid insertion of \n on the end of each lines of msgstr directive.
(add-hook 'po-mode-hook
          '(lambda ()
             (defun po-eval-requoted (form prefix obsolete)
               "Eval FORM, which inserts a string, and return the string fully requoted.
If PREFIX, precede the result with its contents.  If OBSOLETE, comment all
generated lines in the returned string.  Evaluating FORM should insert the
wanted string in the buffer which is current at the time of evaluation.
If FORM is itself a string, then this string is used for insertion."
               (po-with-temp-buffer
                (if (stringp form)
                    (insert form)
                  (push-mark)
                  (eval form))
                (goto-char (point-min))
                (let ((multi-line (re-search-forward "[^\n]\n+[^\n]" nil t)))
                  (goto-char (point-min))
                  (while (re-search-forward "[\"\a\b\f\n\r\t\\]" nil t)
                    (cond ((eq (preceding-char) ?\") (replace-match "\\\"" t t))
                        ((eq (preceding-char) ?\a) (replace-match "\\a" t t))
                        ((eq (preceding-char) ?\b) (replace-match "\\b" t t))
                        ((eq (preceding-char) ?\f) (replace-match "\\f" t t))
                        ((eq (preceding-char) ?\n)
                         (replace-match (if (or (not multi-line) (eobp))
                                            ""
                                          "\"\n\"")
                                        t t))
                        ((eq (preceding-char) ?\r) (replace-match "\\r" t t))
                        ((eq (preceding-char) ?\t) (replace-match "\\t" t t))
                        ((eq (preceding-char) ?\\) (replace-match "\\\\" t t))))
                  (goto-char (point-min))
                  (if prefix (insert prefix " "))
                  (insert (if multi-line "\"\"\n\"" "\""))
                  (goto-char (point-max))
                  (insert "\"")
                  (if prefix (insert "\n"))
                  (if obsolete
                      (progn
                        (goto-char (point-min))
                        (while (not (eobp))
                          (or (eq (following-char) ?\n) (insert "#~ "))
                          (search-forward "\n"))))
                  (buffer-string))))))

Easy way to watch the demo of libvisual plugin.

When I checked the source code of libvisual on debian sid,I feel like to watching the demo of libvisual plugin.
I'm looking around for the easiest way of this, I seems to find out. I memorize here.

Notice: I'm currently using alsa interface. I don't know how-to in other audio interface(ex. palseaudio,esound,jack,etc...)

1) Enable alsa mixier as capture device,according to this wiki: Alsa Opensrc Org - Independent ALSA and linux audio support site.
2) Play some music via alsa.(ex. aplayer,totem,rhythmbox,etc...)
3) Invoke visualizer like this,

gst-launch alsasrc ! audioconvert ! queue ! libvisual_lv_analyzer ! ffmpegcolorspace ! xvimagesink

(This command show the demo of lv_analyzer visual plugin. If you want to demonstrate another plugins in this form 'libvisual_'.)

Then, the visualization of currently playing music begins like this,

Write totem plugin.

I recently prefer totem-2.30 on debian sid to listen music.However totem seems lack of an ability which notifies the music title to GNOME notification area.

Then ,I decided to write the plugin to notify the meta-data (included title,artist,etc...) of music. I found using python make it very easy task! So I memorize here.

1) mkdir ~/.local/share/totem/plugins/metadata_notifier
2) cd ~/.local/share/totem/plugins/metadata_notifier
3) put the following source, named as "metadata_notifier.py"

## Metadata  notify plugin
## Author nozzy123nozzy <nozzy123nozzy_at_gmail_dot_com>
## Copyright: nozzy123nozzy
## License: GPL
 
import totem
import pynotify

class metadata_notifier(totem.Plugin):
	def __init__(self):
		totem.Plugin.__init__(self)
		self.notifier_ident="Totem Metadata notification"
		pynotify.init(self.notifier_ident)
		self.old_notify_string=""

	def activate(self,totem):
		totem.connect("metadata-updated", self.do_metadata)

	def deactivate(self,totem):
		pynotify.uninit();

	def do_metadata(self, totem, artist, title, album, num):
		notify_string=""
		if artist:
			notify_string+=artist+"\n"
		if title:
			notify_string+=title+"\n"
		if album:
			notify_string+=album+"\n"
		if len(notify_string) != 0:
			if totem.is_playing() and \
				(notify_string != self.old_notify_string):
				self.do_notify(notify_string)
				self.old_notify_string=notify_string

	def do_notify(self, notify_string):
		notify=pynotify.Notification("Totem",notify_string,"/usr/share/pixmaps/totem.xpm")
		notify.set_timeout(10000)
		notify.show()

4) put the plugin definition named as "metadata_notifier.totem-plugin",

[Totem Plugin]
Loader=python
Module=metadata_notifier
IAge=1
Name=Metadata Notifier
Description=Plugin for sending notification of currently playing music to gnome nitifier daemon.
Author=nozzy123nozzy <nozzy123nozzy_at_gmail_dot_com>
Copyright=nozzy123nozzy
Website=http://d.hatena.ne.jp/nozzy123nozzy/

5) aptitude install python-notify
6) invoke totem.
7) select menu of plugins.
8) 'Metadata Notifier' is shown. Then, put check-mark on it.
9) start play music.

If music data has meta-data, it is shown on notification area on GNOME desktop,
like below,

Tips:
[1] If meta-data has some cp932(or shift-jis) code, putting 'GST_TAG_ENCODING=CP932' to your environmental variable is covenient.It can help show the correct Japanese titles,artists.

Have fun!

How to migrate the system to larger size hdd in debian sid(wheezy/sid).

I'm using HP Proliant ML115, it originally has only 160GB HDD. Recently I stored many larger pdfs and videos into this hdd, the size of hdd was almost full.
Then I bought a cheap 2TB HDD (Western Digital WD20EARS-00MVWB0. it costed approximately 7,300yen(just $91!)) and I migrated whole my debian box to this HDD.

(I'm not using LVM as root file system. My debian sid box is installing simply to one ext3 filesystem.)

I memorize how to migrate my system to a larger HDD as below,

Step 1. Power off ML115, open the case of ML115, connect the SATA cable between new HDD and 2nd SATA I/F, and also connect power cable to new HDD.
Step 2. Power on ML115 and boot debian sid using old HDD.
Step 3. After root login, make necesally partitions to a new HDD.
(In this time , I made the swap partition on partition #1,and the root partition on partithon #2.)
Step 4. mkswap /dev/sdb1 (<- sdb1 is the swap partition described in Step 3.)
Step 5. mkfs -t ext3 /dev/sdb2 (<- sdb2 is the root partition described in Step 3.)
Step 6. mount -t ext3 /mnt /dev/sdb2
Step 7. aptitutde install dump.
Step 8. cd /
Step 9. dump -0 -f - / |(cd /mnt && restore -rf - )
Step 10. chroot /mnt
Step 11. grub-install /dev/sdb
Step 12. update-grub
Step 13. exit
Step 14. shutdown -h now
Step 15. After power off ML115,open it, removed old HDD, and connected the cables to a new HDD as SATA 1st disk.
Step 16. Power on ML115.
Step 17. When grub boot menu is appeared, type 'e' key on the first boot entry. And simply edit 'set root=(/dev/sdb,msdos2)' line to 'set root=(/dev/sda,msdos2)'.
Step 18. Type CTRL-x, then boot sequence begins.
Step 19. After root login, do grub-install /dev/sda and update-grub.
Step 20. shutdown -h now, and power on again ML115.
Step 21. Just wait , checking the debian sid is booting automatically and completely not required any manual operations.

How to install nvidia-glx in more better way on wheezy/sid

I mentioned before I install experimental package of nvidia-glx into debian wheezy/sid in straight forward way(See. id:nozzy123nozzy:20110227:1298813726). However,unfortunately, I found this method COMPLETELY CORRUPT THE DEPENDENCIES OF ALL INSTALLED PACKAGE!! I was really down to find this. So I write recovering method and also install nvidia-glx package in better way. (I also referrenced a bug report Bug#612956: nvidia-glx requires xorg-video-abi-8.0 but new xserver-xorg-core provides xorg-video-abi-8 )

!! Caution: I don't care any troubles when you apply this method. ANY USE IS COMPLETELY AT YOUR OWN RISKS!!

Step 1. Remove nvidia packages from debian box.

 aptitude purge libcuda1 libgl1-nvidia-alternatives libgl1-nvidia-glx \
      libglx-nvidia-alternatives libnvcuvid1 libnvidia-compiler nvidia-glx \
      nvidia-kernel-dkms nvidia-kernel-source nvidia-libopencl1 \
      nvidia-opencl-common nvidia-opencl-icd nvidia-smi nvidia-vdpau-driver 

Step 2. Get the experimental package source of nvidia driver
(/etc/apt/sources.list for retriving experimental package is shown as id:nozzy123nozzy:20110227:1298813726 )

 mkdir nvidia-source
 cd nvidia-source
 apt-get -t experimental source nvidia-glx
 cd nvidia-graphics-drivers-260.19.21

Step 3. Modify control file to give the accurate package name.

cd debian
...edit 'control' file like this ....
diff -u control.orig control 
--- control.orig	2011-03-10 02:33:35.000000000 +0900
+++ control	2011-03-09 02:09:33.000000000 +0900
@@ -26,7 +26,7 @@
  libgl1-nvidia${nvidia:Legacy}-glx (= ${binary:Version}),
  libglx-nvidia-alternatives,
  nvidia-kernel-${nvidia:Version}${nvidia:Perfkit},
- xorg-video-abi-8.0 | xorg-video-abi-6.0 | xserver-xorg-core (<< 2:1.7.7),
+ xorg-video-abi-8 | xorg-video-abi-6 | xserver-xorg-core (<< 2:1.7.7),
  ${shlibs:Depends}, ${misc:Depends}
 Recommends: nvidia-vdpau-driver (>= ${nvidia:Version})
 Suggests: nvidia-settings,

('xorg-video-abi-8.0' and 'xorg-video-abi-6.0' change to 'xorg-video-abi-8' and 'xorg-video-abi-6'.This keeps dependencies correct after installation.)
Step 4. Build packages

cd ..
dpkg-buildpackage -rfakeroot

Step 5. Install nvidia-kernel source, build and install the kernel driver.

cd ..
dpkg -i nvidia-kernel-source_260.19.21-1_i386.deb
m-a clean;m-a update;m-a prepare;m-a a-i nvidia

Step 6. Install packages as you needs

Example:
dpkg -i libgl1-nvidia-alternatives_260.19.21-1_i386.deb \
    libgl1-nvidia-glx_260.19.21-1_i386.deb \
    libglx-nvidia-alternatives_260.19.21-1_i386.deb \
    nvidia-glx_260.19.21-1_i386.deb nvidia-kernel-dkms_260.19.21-1_i386.deb \
    nvidia-vdpau-driver_260.19.21-1_i386.deb

Step 7. Check the following ,
(1) 'blacklist nouveau' line is included in /etc/modprobe.d/blacklist.conf.
(2) nvidia-kernel-common package is already installed.
(3) 'Driver "nvidia"' line is included in /etc/X11/xorg.conf
Step 8. Reboot and invoke X.

How to fsck root file system without recovery CDs.

I met corruption of root file system with debian wheezy/sid.
Unfortunately,I didn't have any recovery CDs. Then I searched around a method of doing fsck root file system and I found a easy method. So I memorize here,

Step 1. Add 'forcefsck' to the boot entry in GRUB after system reboots.

linux   /boot/vmlinuz-2.6.37-2-686 root=UUID=XXXXX-XXX-XXXX-XXX-XXXXX ro  quiet forcefsck

Step 2. Type Ctrl+x and boot.

For a while , fsck of the root file system begins.

How to use nvidia-glx on debian wheezy/sid

Recently I did full upgrade of debian sid. Then the kernel was upgraded to 2.6.37-1-686 and xserver-xorg-core also was upgraded to 2:1.9.4-3.My debian box became a happily wheezy/sid.

However, nvidia-glx package of wheezy/sid still needs old xserver <2:1.7.7 at this time, it cannot be installed in straightforward way.

After some try and error, I succeeded to installing nvidia-glx into debian wheezy/sid. I will show the how-to below.

!! Caution: I don't care any troubles when you apply this method. ANY USE IS COMPLETELY AT YOUR OWN RISKS!!

Step 1. Append a following line into /etc/apt/sources.list.

deb http://ftp.debian.org/debian experimental main contrib non-free

Step 2. aptitude update
Step 3. aptitude -t experimental install nvidia-kernel-source libgl1-nvidia-glx
Step 4. m-a clean;m-a update;m-a prepare;m-a a-i nvidia
Step 5. aptitude -t experimental download nvidia-glx
Step 6. dpkg --ignore-depends=xorg-video-abi-8.0 -i nvidia-glx_260.19.21-1_i386.deb
Step 7. aptitude hold nvidia-glx
Step 8. Check the following ,
(1) 'blacklist nouveau' line is included in /etc/modprobe.d/blacklist.conf.
(2) nvidia-kernel-common package is already installed.
(3) 'Driver "nvidia"' line is included in /etc/X11/xorg.conf
Step 9. After reboot, the X will start with nvidia driver.

That's all. It is easy,isn't it?