fbpad

提供: ArchWiki
2018年2月24日 (土) 23:26時点におけるKusakata (トーク | 投稿記録)による版 (ページの作成:「{{Lowercase title}} Category:ターミナルエミュレータ en:Fbpad [http://repo.or.cz/w/fbpad.git fbpad] は一文字のタグを使って多数のターミ...」)
(差分) ← 古い版 | 最新版 (差分) | 新しい版 → (差分)
ナビゲーションに移動 検索に移動

fbpad は一文字のタグを使って多数のターミナルを管理できる小型のフレームバッファターミナルです。C で書かれており固有のフォントフォーマット tinyfont を使って Xorg でフォントを使うために必要なパッケージが要らないために非常に軽量です。fbpad は任意で256色や太字フォント、フレームバッファのコンテンツのメモリ保存をサポートしており、様々な用途で X サーバーを置き換えることができます。

インストール

fbpad-gitAUR パッケージをインストールしてください。デフォルトでは fbpad の "bold" と "scrsnap" ブランチがインポートされ、256色と太字フォント、そしてフレームバッファの中身の保存機能が追加されます。fbpad は config.h ファイルでカスタマイズすることができ、config.h ファイルを編集したら makepkg --skipinteg -i を使って fbpad を再コンパイルしてください。

設定

config.h でフォント (詳しくは下述), SHELL, MAIL, EDITOR の定義を編集することができます。

dwm ユーザーは fbpad にすぐに慣れるでしょう。fbpad のキーバインドは修飾キーで始まり、dwm と同じように Alt キーにハードコードされています。Alt+jAlt+k で開いているタグのターミナルが切り替わり、Alt+o で最後に開いたタグに切り替わり、Alt+p で開いているタグのリストが表示されます。ソースコードの手動パッチに抵抗がなければ fbpad.c ファイルを編集してキーバインドを編集・追加できます。

fbpad を頻繁に再コンパイルする場合、手動で再起動しなくても fbpad をリロードできるようにすると便利でしょう。以下のコードは tty1 でログインした後に fbpad を起動し、Ctrl+Alt+q で fbpad を終了したときにリロードします。

if [[ $(tty) = /dev/tty1 ]]; then
  while true; do
    fbpad >/dev/null 2>&1
  done
fi

上記をコマンドラインシェルの設定ファイルの末尾に追加してください。

タグの色

タグリストのデフォルトの背景色は白にハードコードされていて、同じく空のタグの前景色は黒に、完全に埋まったタグの前景色は緑に (タグにはそれぞれ2つまでターミナルを格納できます)、完全には埋まっていないタグの前景色は青になっています。以下のパッチを使うことでカラースキームを変更することができます:

--- a/fbpad.c	2011-11-11 13:02:22.834825518 -0500
+++ b/fbpad.c	2011-11-11 13:04:07.016043271 -0500
@@ -110,7 +110,7 @@
 
 static void showtags(void)
 {
-	int colors[] = {15, 4, 2};
+	int colors[] = {8, 2, 9};
 	int c = 0;
 	int r = pad_rows() - 1;
 	int i;
@@ -128,7 +128,7 @@
 			nt++;
 		pad_put(i == ctag ? '(' : ' ', r, c++, FGCOLOR, BGCOLOR);
 		if (TERMSNAP(i))
-			pad_put(tags[i], r, c++, !nt ? BGCOLOR : colors[nt], 15);
+			pad_put(tags[i], r, c++, !nt ? 8 : colors[nt], BGCOLOR);
 		else
 			pad_put(tags[i], r, c++, colors[nt], BGCOLOR);
 		pad_put(i == ctag ? ')' : ' ', r, c++, FGCOLOR, BGCOLOR);

To use, replace "8" with the desired color for empty tags (in both instances), "2" with the desired color for not fully occupied tags, and "9" with the desired color for fully occupied tags, where the colors 0-15 are defined in the config.h file. This patch also makes the default background color the background color of your terminal, which the writer finds to be a more natural choice.

Note that the second "8" is the color for tags for which fbpad saves the framebuffer contents. If you choose to define TAGS_SAVED as TAGS, then you will want your default foreground color and the color for saved tags to be the same, i.e. "8" in both instances. Otherwise, you may define TAGS_SAVED as a concatenated string of the tags to be saved, and change the second "8" to the color you wish to indicate saved tags by. The writer herself saves all tags for convenience.

Save the patch as fbpad-tagcolor.diff, add 'fbpad-tagcolor.diff' to your source array, and the following line to the PKGBUILD after the line that copies the config.h file:

patch -p1 -i "${srcdir}/${_gitname}-tagcolor.diff" || return 1

フォント

fbpad のフォントフォーマットは "tinyfont" であり、TTF ファイルを tinyfont フォーマットに変換するユーティリティとして ft2tfAUR が存在します。ft2tf のビルドディレクトリの config.h ファイルを編集して使用したいフォントの TTF ファイルを指定してください。例えばフォントファイル MonteCarloFixed.ttf$HOME/.fonts ディレクトリに存在する場合、config.h の10行目を以下のように編集 (ユーザー名の "archie" と作成するフォントサイズの 6 は適当に置き換えてください):

{"/home/archie/.fonts/MonteCarloFixed12.ttf", 6},

他のフォントの行は削除してください。他のフォントの文字でフォントを補間したい場合、上記と同じように他のフォントの TTF ファイルの行を追加してください。

それから makepkg -skipinteg -i を実行してカスタマイズした設定でパッケージをビルド・インストールしてください。

ft2tf をインストールしたら、以下のコマンドで tinyfont ファイルが作成されます:

$ ft2tf > MyFont.tf

"MyFont" は適当な名前に置き換えることができます。

Remember to edit your config.h to point to the directory where you save your MyFont.tf. If your font also has a bold face, repeat the process of editing the ft2tf config.h file, this time specifying the location of the boldface TTF file in the ft2tf config.h, rebuilding with makepkg, and adding the final boldface tinyfont location to your fbpad config.h.

Also note that some fonts might require modification of the WIDTHDIFF and HEIGHTDIFF to have the proper width and height, respectively.

カラーのサポート

By default, the AUR package installs the custom terminfo for fbpad, but you will need to add

export TERM=fbpad-256

to your shellrc to take advantage of the 256 color support. Clearly, commands not spawned in your default shell (for instance, those for EDITOR and MAIL) will not read your shellrc file, so you will need to edit their definitions in your config.h file to have the commands for EDITOR and MAIL run in a parent shell. For instance, the author of this article, who uses zsh, changed the default command for MAIL from:

#define MAIL		"mailx"

to

#define MAIL		"zsh -i -c mailx"

Additionally, to have colors with the ls command, "fbpad-256" needs to be added to the list of terms that ls knows can handle color. Per the README, run the following command in your shell:

$ dircolors --print-database | sed '/^TERM linux$/aTERM fbpad-256' >$HOME/.dircolors

and add eval `dircolors ~/.dircolors` to your shellrc file so that the custom dircolors file, with the fbpad-256 term added, may be loaded.

ヒントとテクニック

テキストのコピー

As everything is done mouselessly in fbpad, to copy text, users can make a "screenshot" of all the text on the screen with the Alt+s command. This will save all viewable text to the file /tmp/scr. Then, if your shell supports editing the commandline with vim (for instance, the edit-command-line ZLE function in zsh), you can open the /tmp/scr file as a new buffer in vim and use its copy keybindings to paste the needed text into your original buffer. Emacs users probably can adopt a similar scheme to copy text.

YouTube の試聴

If one is using MPlayer with the video output driver set to fbdev2, youtube-viewer can be used for searching YouTube and watching with MPlayer from the commandline in fbpad. Alternatively, one can add the following script as an external browser in the commandline web browser w3m, and launch playback of videos from YouTube websites with one's media player of choice. The script below employs fbff-gitAUR, a lightweight media player also written by the author of fbpad, and yturlAUR, a simple program, that, rather UNIX-like, functions solely to convert YouTube URLs into directly watchable URLs.

#!/bin/sh
video=$(yturl $1)
fbff -f $video > /dev/null 2>&1

Save the file in your PATH as youtube.sh, and add it as an external browser to w3m by opening w3m, hitting the o key to edit options, and edit the "External Browser" field under "External Program Settings" by entering in the field "youtube.sh". Hit "OK", and you are done. Now, when wishing to watch a video, with YouTube open, hit the M key, and the video will begin streaming instantly in fbff.

推奨プログラム

以下はフレームバッファベースのデスクトップの利便性を高めるプログラムです:

  • dvtm - 動的な仮想ターミナルマネージャ (dwm のコンソール版)
  • fbcatAUR - フレームバッファのスクリーンショット取得ツール
  • fbff-gitAUR - ffmpeg ベースのメディアプレイヤー
  • fbpdf-gitAUR - MuPDF ベースの PDF ビューア、DjVu のサポートや poppler によるレンダリングを任意でサポート
  • fbvAUR - 画像ビューア
  • screen - ターミナルマルチプレクサ
  • w3m - コマンドラインウェブブラウザ

参照