端末アプリのマウスカーソルの変更

w3mでマウスを使う*1俺はmltermのマウスカーソルがIになっててとてもストレスがたまる。top_left_arrowがお好み。アスキーアートで表現するならこんなの。

11............11
1111............
.11111..........
.1111111........
..11111111......
..1111111111....
...11111........
...11111........
....11..1.......
....11...1......
.....1....1.....
.....1.....1....
............1...
.............1..

ちなみにEmacsでは以下のように設定すればいい。

(setq x-pointer-shape x-pointer-top-left-arrow)

http://sho.tdiary.net/20021206.html#p04 を参考にやってみる。
まず、cursor.bdfを見付けないといけない。ftp.x.orgにはなかったので、http://webcvs.freedesktop.org/xorg/font/cursor-misc/cursor.bdf?revision=1.1&pathrev=CYGWIN から拾った。~/fonts以下に保存した。

そして、

bdf2bit.rb cursor.bdf

でマウスカーソルのビットマップイメージを見る。すると、Iなマウスカーソルはxtermであることがわかった。STARTCHAR xtermとSTARTCHAR xterm_maskの部分をこんな感じに修正すればいい。BBXからENDCHARまで変更する。

http://www.rubyist.net/~rubikitch/archive/cursor.patch

--- /tmp/cursor.bdf	2007-10-24 09:23:21.567120955 +0900
+++ /m/home/rubikitch/fonts/cursor.bdf	2007-10-24 09:09:18.000000000 +0900
@@ -3246,44 +3246,44 @@
 ENCODING -1 152
 SWIDTH 322 0
 DWIDTH 10 0
-BBX 7 14 -3 -7
+BBX 14 14 0 -14
 BITMAP
-ef
-39
-10
-10
-10
-10
-10
-10
-10
-10
-10
-10
-38
-ee
+c003
+f000
+7c00
+7f00
+3fc0
+3ff0
+1f00
+1f00
+0c80
+0c40
+0420
+0410
+0008
+0004
 ENDCHAR
 STARTCHAR xterm_mask
 ENCODING -1 153
 SWIDTH 322 0
 DWIDTH 10 0
-BBX 9 16 -4 -8
+BBX 16 16 -1 -15
 BITMAP
-f782
-ff80
-ff80
-3e00
-1c00
-1c00
-1c00
-1c00
-1c00
-1c00
-1c00
-1c00
-3e00
-ff80
-ff80
-f780
+e000
+f800
+fe00
+7f80
+7fe0
+3ffc
+3ffc
+1ffc
+1fc0
+0fe0
+0f70
+0738
+071c
+070e
+0007
+0003
 ENDCHAR
 ENDFONT


bdf2bit.rbで抜粋するとこんな感じ。

STARTCHAR xterm
ENCODING -1 152
SWIDTH 322 0
DWIDTH 10 0
BBX 14 14 0 -14
BITMAP
11............11
1111............
.11111..........
.1111111........
..11111111......
..1111111111....
...11111........
...11111........
....11..1.......
....11...1......
.....1....1.....
.....1.....1....
............1...
.............1..
ENDCHAR
STARTCHAR xterm_mask
ENCODING -1 153
SWIDTH 322 0
DWIDTH 10 0
BBX 16 16 -1 -15
BITMAP
111.............
11111...........
1111111.........
.11111111.......
.1111111111.....
..111111111111..
..111111111111..
...11111111111..
...1111111......
....1111111.....
....1111.111....
.....111..111...
.....111...111..
.....111....111.
.............111
..............11
ENDCHAR


あとは修正を反映するだけ。

bdftopcf cursor.bdf > cursor.pcf
mkfontdir .
xset +fp ~/fonts
xsetroot -cursor_name X_cursor

mltermを再起動すればマウスカーソルが反映される^^
もし、気が変わってほかのがいいと思ったらまたcursor.bdfを変更し、適当なディレクトリを掘って上のコマンドを実行する。

xset +fp ~/fonts

は.xinitrcやら.xsessionに書いておこう。

好みのマウスカーソルの見付け方

マウスカーソルは

 xfd -fn cursor

で一覧できる。

/usr/X11R6/include/X11/cursorfont.h にマウスカーソルの定義が書かれているので、マウスカーソルをウィンドウの外(つまりルートウィンドウ)に置いて、以下のコマンドを順次実行すれば好みのマウスカーソルが見付けられるだろう。

xsetroot -cursor_name X_cursor
xsetroot -cursor_name arrow
xsetroot -cursor_name based_arrow_down
xsetroot -cursor_name based_arrow_up
xsetroot -cursor_name boat
xsetroot -cursor_name bogosity
xsetroot -cursor_name bottom_left_corner
xsetroot -cursor_name bottom_right_corner
xsetroot -cursor_name bottom_side
xsetroot -cursor_name bottom_tee
xsetroot -cursor_name box_spiral
xsetroot -cursor_name center_ptr
xsetroot -cursor_name circle
xsetroot -cursor_name clock
xsetroot -cursor_name coffee_mug
xsetroot -cursor_name cross
xsetroot -cursor_name cross_reverse
xsetroot -cursor_name crosshair
xsetroot -cursor_name diamond_cross
xsetroot -cursor_name dot
xsetroot -cursor_name dotbox
xsetroot -cursor_name double_arrow
xsetroot -cursor_name draft_large
xsetroot -cursor_name draft_small
xsetroot -cursor_name draped_box
xsetroot -cursor_name exchange
xsetroot -cursor_name fleur
xsetroot -cursor_name gobbler
xsetroot -cursor_name gumby
xsetroot -cursor_name hand1
xsetroot -cursor_name hand2
xsetroot -cursor_name heart
xsetroot -cursor_name icon
xsetroot -cursor_name iron_cross
xsetroot -cursor_name left_ptr
xsetroot -cursor_name left_side
xsetroot -cursor_name left_tee
xsetroot -cursor_name leftbutton
xsetroot -cursor_name ll_angle
xsetroot -cursor_name lr_angle
xsetroot -cursor_name man
xsetroot -cursor_name middlebutton
xsetroot -cursor_name mouse
xsetroot -cursor_name pencil
xsetroot -cursor_name pirate
xsetroot -cursor_name plus
xsetroot -cursor_name question_arrow
xsetroot -cursor_name right_ptr
xsetroot -cursor_name right_side
xsetroot -cursor_name right_tee
xsetroot -cursor_name rightbutton
xsetroot -cursor_name rtl_logo
xsetroot -cursor_name sailboat
xsetroot -cursor_name sb_down_arrow
xsetroot -cursor_name sb_h_double_arrow
xsetroot -cursor_name sb_left_arrow
xsetroot -cursor_name sb_right_arrow
xsetroot -cursor_name sb_up_arrow
xsetroot -cursor_name sb_v_double_arrow
xsetroot -cursor_name shuttle
xsetroot -cursor_name sizing
xsetroot -cursor_name spider
xsetroot -cursor_name spraycan
xsetroot -cursor_name star
xsetroot -cursor_name target
xsetroot -cursor_name tcross
xsetroot -cursor_name top_left_arrow
xsetroot -cursor_name top_left_corner
xsetroot -cursor_name top_right_corner
xsetroot -cursor_name top_side
xsetroot -cursor_name top_tee
xsetroot -cursor_name trek
xsetroot -cursor_name ul_angle
xsetroot -cursor_name umbrella
xsetroot -cursor_name ur_angle
xsetroot -cursor_name watch
xsetroot -cursor_name xterm

なお、xsetroot -cursor_nameはルートウィンドウのマウスカーソルのみ変更するので、mlterm/kterm/xtermなどの端末でも使いたければ、このエントリの方法でマウスカーソルを変更しないといけない。

おまけ

マウスカーソル」と「マウスポインタ」どっちのほうが多く言われてるのだろうか。

*1:ratpoison使いなので英語を読むときとFirefoxくらいしか使わないが。