mozcのデフォルトをひらがな入力モードにする
Ubuntu 16.04や18.04ではmozcが使える。なれてしまうとanthyには戻れない。 が、mozcはmozcで、ログイン後の入力モードがデフォルトでDirect Input(直接入力)になっていて、しかも私のキーボードではひらがな入力モードに変更できない。なので、毎度毎度マウスを操作してひらがな入力モードに変更しなくてはならない。これが嫌で一度anthyに戻そうとしたが、やはり変換精度の差はいかんともしがたい。mozcを使うときは日本語を使いたい時のはずなので、どのような経緯でこのような仕様になったのか、不思議なところであるがこの際、どうでもいい。
ということでこれを直すことにする。 なお、この手順はUbuntu 20.04でもそのまま使えるとする複数の報告がある。 当エントリに言及していただいていることに感謝したい。 また、この手順は依然としてUbuntu 22.04でも必要であり、そのまま使える。
前提として、これは設定でどうにかする方法はなく、結局ソースの変更が必要である。[1]
mozcのレポジトリをクローンしdockerを使ってソースからビルドする方法もあるが、その後のインストールでかったるいことになりそうだ。 ということでUbuntuのソースパッケージからビルドすることにする。
ソースパッケージを以下のようにして入手
sudo apt update sudo apt upgrade -y sudo apt install build-essential devscripts -y sudo apt build-dep ibus-mozc -y sudo apt install debhelper -y apt source ibus-mozc
[1]に示された修正を行う。
emacs -nw $(find . -name property_handler.cc)
// Some users expect that Mozc is turned off by default on IBus 1.5.0 and later. // https://code.google.com/p/mozc/issues/detail?id=201 // On IBus 1.4.x, IBus expects that an IME should always be turned on and // IME on/off keys are handled by IBus itself rather than each IME. #if IBUS_CHECK_VERSION(1, 5, 0) const bool kActivatedOnLaunch = true; //false; #else const bool kActivatedOnLaunch = true; #endif // IBus>=1.5.0
ビルドを行う。
cd mozc* dpkg-buildpackage -us -uc -b
インストール
sudo dpkg -i ../mozc*.deb ../ibus-mozc*.deb
再ログオン後、mozcのデフォルト入力モードがHiraganaになるはずである。
Misc
この記事は、「Ubuntu 16.04 aarch64環境でmozc pkgが無いのでsource pkgからbuild」[2]を参考にして執筆した。 平成30年(2018年)10月11日に試したところ、本手順はUbuntu 18.04でも問題なく利用できる。 また、令和3年(2021年)6月18日に、本手順はUbuntu 20.04でも問題なく利用できる旨の複数の報告があるようなので、その旨冒頭に記載した。
また、ここに記された手順は無保証であり、その結果について執筆者は責任を負わない。フィードバックや修正提案を採用する義務を執筆者は負わないが、それらは歓迎される。
一定の閲覧があるとちょっと嬉しい気持ちになってしまうのは事実なのだが、ibus-mozcが改良され或いは代替の手段が整備されることによって、このエントリが必要なくなることを願っている。
References
How to convert all my audios into mp4 at once
I'm using Qnap NAS and recently I came to want to play all the media in living room at home. What is the best appliance?
Actually, there is a long story.
Apple TV? No it plays media only in my iPhone. And Wi-fi at home isn't good when a microwave is working.
Chromecast? was not a good idea for similar reasons.
Purchase a new network media player? No. It doesn't play ALAC, in which most of my audio files are encoded. Ones play ALAC cost 1,000 - 2,000 dollars. And those expensive ones do not look playing videos.
Finally I chose Sony PlayStation 3, which I bought several years ago. And since it doesn't play ALAC/FLAC, I need to convert thousands of my files.
Is there good solution in Linux? I couldn't find it. 'SoundConverter' looked nice, but it didn't understand ALAC. And only writes MP3 not MP4 (PS3 plays both, but I liked the latter).
Anyway I wrote a command line below to perform conversion from my audios to mp4 format.
export destroot="/mnt/livius/Qmultimedia/PS3/Music" && \ export srcroot="/mnt/livius/Qmultimedia/iTunes/iTunes Media/Music" && \ find "$srcroot" \ -type f \ -exec \ sh -c '\ export fname="${1#/*Music/}" && \ export destdir="$destroot/$(dirname "${fname}")" && \ mkdir -p "$destdir" && \ /usr/bin/avconv -y -i \ "$srcroot/$fname" \ -vn -acodec libvo_aacenc -b:a 320k -ac 2 -ar 48000 -b:a 320k \ "$destroot/${fname%.*}.mp4" \ ' \ "Convert all my music into MP4" {} \;
Writing S-expression inside Java codes
I recently created a library that evaluates java.lang.Objects as S-expressions (my summer homework;)). In other words, you can embed a LISP program inside Java code, but unlike fun4j you don't need to write your LISP code as a String. You can write it as a real Java program. That is,
Basic.eval(
progn(
assign($("i"), 0),
loop(
lt($("i"), 10),
print(format("@@@@@@@@ %s @@@@@@@@\n", $("i"))),
assign($("i"), add($("i"), 1))
)
)
);
where progn, assign, loop, lt, print, and so on are names of Java methods that return evaluatable objects (java.lang.Object[]'s) and Basic.eval is a function that does the 'evaluate' on given java.lang.Object.
This program produces the output below
@@@@@@@@ 0 @@@@@@@@
@@@@@@@@ 1 @@@@@@@@
@@@@@@@@ 2 @@@@@@@@
@@@@@@@@ 3 @@@@@@@@
@@@@@@@@ 4 @@@@@@@@
@@@@@@@@ 5 @@@@@@@@
@@@@@@@@ 6 @@@@@@@@
@@@@@@@@ 7 @@@@@@@@
@@@@@@@@ 8 @@@@@@@@
@@@@@@@@ 9 @@@@@@@@
It's not yet published in Maven's Central Repository, but will become available soon.
The source code is found here: https://github.com/dakusui/petronia/