fbterm使用

fbterm使用

时间: 2015-02-28 21:37
作者: lsgxeva
分类:  工作学习>>linux>>terminal
摘要:  fbterm的安装和使用
标签:  fbterm Linux terminal tty
提示: 文章均来自网络,版权为原作者所有,如有侵犯权益,请联络我们.


一:fbterm的介绍
     Fbterm ( F rame  b uffer  term inal)是内核终端的直接替代:一个没有 Xorg 也能使用的终端模拟器。
     摘自   http://code.google.com/p/fbterm/ :
FbTerm 是一个使用 frame buffer 设备或 VESA 显卡的终端模拟器,功能包括:
  • 若加速滚动开启的话,速度可和linux核心的终端媲美
  • 使用fontconfig选择字体,和Qt/GTK+上用的应用一样,使用freetype2来绘制字体
  • 动态创建和销毁最多10个原生运行默认shell的窗口
  • 记录任何窗口的回滚历史
  • 自动检测目前本地化环境下的文本内码,支持双字节脚本,比如中文、日文等
  • 在线热键切换配置的额外文本内码
  • 当gpm服务器运行时,可使用鼠标在窗口间复制和粘贴选择的文本
  • 可改屏幕显示方式,比如:屏幕翻转
  • C/S结构(客户端/服务器)的轻量级输入法框架
  • 背景图片

    Fbterm 基于 Framebuffer,目标是为 Linux 提供一个可以支持国际化字符显示、并且支持字体配置的纯终端环境,类似于大家熟悉的 zhcon 和 cce,不过安装和配置上要简单不少。
要想运行 Fbterm,首先你的 Linux 内核必须已经配置并且启用了 Framebuffer 的支持,如果正确配置,应该会有 /dev/fb 这个文件,如果没有,Fbterm 会报错。

二:fbterm的安装

lsgx@UbuntuServer:~$  sudo aptitude install openssh-server
lsgx@UbuntuServer:~$  sudo aptitude install vim
lsgx@UbuntuServer:~$  sudo aptitude install exuberant-ctags 
lsgx@UbuntuServer:~$   sudo aptitude install emacs
lsgx@UbuntuServer:~$  sudo aptitude install bash
lsgx@UbuntuServer:~$   sudo aptitude install tree
lsgx@UbuntuServer:~$  sudo aptitude install build-essential
lsgx@UbuntuServer:~$   sudo aptitude install gdb gdb-doc cgdb 
lsgx@UbuntuServer:~$  sudo aptitude install  autoconf   
lsgx@UbuntuServer:~$  sudo aptitude install dpkg-dev
lsgx@UbuntuServer:~$  sudo aptitude install p7zip-full
lsgx@UbuntuServer:~$  sudo aptitude install libncurses5-dev 
lsgx@UbuntuServer:~$  sudo aptitude install libiconv-hook-dev 
lsgx@UbuntuServer:~$  sudo aptitude install  kernel-package
lsgx@UbuntuServer:~$  sudo aptitude install linux-headers-`uname -r`
lsgx@UbuntuServer:~$  sudo aptitude install  fakeroot  
lsgx@UbuntuServer:~$  sudo aptitude install exfat-utils 
lsgx@UbuntuServer:~$  sudo aptitude install perl perl-doc
lsgx@UbuntuServer:~$  sudo aptitude install racket racket-common racket-common 
lsgx@UbuntuServer:~$  sudo aptitude install cmake cmake-curses-gui cmake-doc 
lsgx@UbuntuServer:~$  sudo aptitude install vsftpd
lsgx@UbuntuServer:~$  sudo aptitude install valgrind valgrind-dbg
lsgx@UbuntuServer:~$  sudo aptitude install psmisc 
lsgx@UbuntuServer:~$  sudo aptitude install v86d
lsgx@UbuntuServer:~$  sudo aptitude install lshw
lsgx@UbuntuServer:~$  sudo aptitude install smartmontools 
lsgx@UbuntuServer:~$  sudo aptitude install dmidecode 


添加一个启动进入命令行的启动选项

// 更新grub引导
lsgx@UbuntuServer:~$  sudo update-grub
[sudo] password for lsgx: 
Sorry, try again.
[sudo] password for lsgx: 
Sorry, try again.
[sudo] password for lsgx: 
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-3.16.0-34-generic
Found initrd image: /boot/initrd.img-3.16.0-34-generic
Found linux image: /boot/vmlinuz-3.16.0-30-generic
Found initrd image: /boot/initrd.img-3.16.0-30-generic
Found memtest86+ image: /memtest86+.elf
Found memtest86+ image: /memtest86+.bin
done

//  参考 /boot/grub/grub.cfg 文件, 复制一个menuentry 到40_custom文件中
lsgx@UbuntuServer:~$  sudo cat /boot/grub/grub.cfg 
lsgx@UbuntuServer:~$  sudo vi /etc/default/grub    
--------------------------------------------------------
# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
# For full documentation of the options in this file, see:
#   info -f grub -n 'Simple configuration'

GRUB_DEFAULT=0
#GRUB_HIDDEN_TIMEOUT=0
#GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT=""
#GRUB_CMDLINE_LINUX_DE FAULT="quiet splash nomodeset video =uvesafb:mode_option=1366x768-24,mtrr=3,scroll=ywrap "
GRUB_CMDLINE_LINUX=""

# Uncomment to enable BadRAM filtering, modify to suit your needs
# This works with Linux (no patch required) and with any kernel that obtains
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"

# Uncomment to disable graphical terminal (grub-pc only)
#GRUB_TERMINAL=console

# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
#GRUB_GFXMODE=640x480
GRUB_GFXMODE=1366x768
GRUB_GFXPAYLOAD_LINUX=keep

# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
#GRUB_DISABLE_LINUX_UUID=true

# Uncomment to disable generation of recovery mode menu entries
#GRUB_DISABLE_RECOVERY="true"

# Uncomment to get a beep at grub start
#GRUB_INIT_TUNE="480 440 1"
--------------------------------------------------------

lsgx@UbuntuServer:~$  sudo vi /etc/grub.d/40_custom 
--------------------------------------------------------------
#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.

# Beginning of the block added by the lsgx - DO NOT EDIT
# Add command mode at 2015-04-09 15:41 by lsgx 
function gfxmode {
set gfxpayload="${1}"
if [ "${1}" = "keep" ]; then
set vt_handoff=vt.handoff=7
else
set vt_handoff=
fi
}
if [ "${recordfail}" != 1 ]; then
  if [ -e ${prefix}/gfxblacklist.txt ]; then
    if hwmatch ${prefix}/gfxblacklist.txt 3; then
      if [ ${match} = 0 ]; then
        set linux_gfx_mode=keep
      else
        set linux_gfx_mode=text
      fi
    else
      set linux_gfx_mode=text
    fi
  else
    set linux_gfx_mode=keep
  fi
else
  set linux_gfx_mode=text
fi
export linux_gfx_mode
menuentry ' Ubuntu (command mode) ' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-384217b2-a319-47c1-9d60-4f7042e89996' {
recordfail
load_video
gfxmode $linux_gfx_mode
insmod gzio
insmod part_msdos
insmod ext2
set root='hd0,msdos1'
if [ x$feature_platform_search_hint = xy ]; then
  search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1  ae42c5a3-eef2-4bac-8cff-f1fbab602378
else
  search --no-floppy --fs-uuid --set=root ae42c5a3-eef2-4bac-8cff-f1fbab602378
fi
linux /vmlinuz-3.16.0-34-generic root=/dev/mapper/UbuntuServer--vg-root ro   text
initrd /initrd.img-3.16.0-34-generic
}

# End of the block added by the lsgx

------------------------------------------------------


// 更新 initramfs
lsgx@lsgx-ubuntu:~$  sudo update-initramfs -u
lsgx@lsgx-ubuntu:~$  sudo reboot



lsgx@UbuntuServer:~$  sudo grub-mkconfig 
lsgx@UbuntuServer:~$  sudo update-grub

lsgx@UbuntuServer:~$  sudo vi /etc/initramfs-tools/modules
--------------------------------------------------
# Beginning of the block added by the lsgx - DO NOT EDIT
#uvesafb mode_option=1366x768-24 mtrr=3 scroll=ywrap

# End of the block added by the lsgx
-------------------------------------------------

lsgx@UbuntuServer:~$  sudo vi /etc/modprobe.d/blacklist-framebuffer.conf 
-------------------------------------------------------------------------------
#blacklist vesafb
-------------------------------------------------------------------------------

lsgx@UbuntuServer:~$  sudo vi /etc/modules
--------------------------------------------------
# Beginning of the block added by the lsgx - DO NOT EDIT
#vesafb

# End of the block added by the lsgx
-------------------------------------------------


// 更新 initramfs
lsgx@UbuntuServer:~$  sudo update-initramfs -u

lsgx@UbuntuServer:~$  sudo reboot


中文支持设置

lsgx@UbuntuServer:~$  locale
LANG=en_US.UTF-8
LANGUAGE=en_US:en
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=

lsgx@UbuntuServer:~$  sudo aptitude install locales
lsgx@UbuntuServer:~$  sudo aptitude install language-pack-zh-hans language-pack-zh-hans-base language-selector-common 
lsgx@UbuntuServer:~$   sudo aptitude install language-pack-gnome-zh-hans-base language-pack-gnome-zh-hans
lsgx@UbuntuServer:~$  sudo cp /var/lib/locales/supported.d/local /var/lib/locales/supported.d/local.bak
lsgx@UbuntuServer:~$  sudo vi /var/lib/locales/supported.d/local
------------------------------
en_US.UTF-8 UTF-8
zh_CN.UTF-8 UTF-8
zh_CN.GBK GBK
zh_CN GB2312
------------------------------
lsgx@UbuntuServer:~$  sudo cp /etc/default/locale /etc/default/locale.bak
lsgx@UbuntuServer:~$  sudo vi /etc/default/locale 
----------------------------------
LANG="zh_CN.UTF-8"
LANGUAGE="zh_CN:zh:en_US:en"
LC_NUMERIC="zh_CN.UTF-8"
LC_TIME="zh_CN.UTF-8"
LC_MONETARY="zh_CN.UTF-8"
LC_PAPER="zh_CN.UTF-8"
LC_NAME="zh_CN.UTF-8"
LC_ADDRESS="zh_CN.UTF-8"
LC_TELEPHONE="zh_CN.UTF-8"
LC_MEASUREMENT="zh_CN.UTF-8"
LC_IDENTIFICATION="zh_CN.UTF-8"

---------------------------------
lsgx@UbuntuServer:~$  sudo locale-gen 
lsgx@UbuntuServer:~$  sudo reboot
lsgx@UbuntuServer:~$  locale
LANG=zh_CN.UTF-8
LANGUAGE=zh_CN:zh:en_US:en
LC_CTYPE="zh_CN.UTF-8"
LC_NUMERIC="zh_CN.UTF-8"
LC_TIME="zh_CN.UTF-8"
LC_COLLATE="zh_CN.UTF-8"
LC_MONETARY="zh_CN.UTF-8"
LC_MESSAGES="zh_CN.UTF-8"
LC_PAPER="zh_CN.UTF-8"
LC_NAME="zh_CN.UTF-8"
LC_ADDRESS="zh_CN.UTF-8"
LC_TELEPHONE="zh_CN.UTF-8"
LC_MEASUREMENT="zh_CN.UTF-8"
LC_IDENTIFICATION="zh_CN.UTF-8"
LC_ALL=

tmux和fbterm

lsgx@UbuntuServer:~$  sudo aptitude install sysv-rc
lsgx@UbuntuServer:~$  sudo aptitude install sysv-rc-conf
lsgx@UbuntuServer:~$  sudo aptitude install fonts-arphic-uming 
lsgx@UbuntuServer:~$  sudo aptitude install fonts-arphic-ukai
lsgx@UbuntuServer:~$   sudo aptitude install ttf-wqy-microhei ttf-wqy-zenhei
lsgx@UbuntuServer:~$  sudo aptitude install xfonts-wqy
lsgx@UbuntuServer:~$  sudo aptitude install xfonts-intl-chinese
lsgx@UbuntuServer:~$  sudo aptitude install xterm
lsgx@UbuntuServer:~$  sudo aptitude install fbterm
lsgx@UbuntuServer:~$  sudo aptitude install tmux
lsgx@UbuntuServer:~$  sudo aptitude install xserver-xorg-core-lts-trusty xfonts-base x11-xserver-utils-lts-trusty
lsgx@UbuntuServer:~$ sudo aptitude install dbus dbus-x11 
lsgx@UbuntuServer:~$  sudo aptitude install fcitx fcitx-googlepinyin fcitx-frontend-all fcitx-frontend-fbterm
lsgx@UbuntuServer:~$  sudo aptitude install moc moc-ffmpeg-plugin
lsgx@UbuntuServer:~$   sudo  aptitude  install gpm


将用户添加到 video组为主用户组(初始群组)
lsgx@UbuntuServer:~$  sudo usermod -a -G  video  root
lsgx@UbuntuServer:~$  sudo usermod -a -G  video  lsgx

将用户添加到 video组为有效群组(次要群组)
lsgx@UbuntuServer:~$  sudo gpasswd -a root vide o  
Adding user root to group video
lsgx@UbuntuServer:~$  sudo gpasswd -a lsgx video 
Adding user lsgx to group video

lsgx@UbuntuServer:~$  sudo chmod u+s  `which fbterm`


lsgx@UbuntuServer:~$  sudo vi ~/.bashrc 
-----------------------------------------------------------------------
# Beginning of the block added by the lsgx - DO NOT EDIT

# Add setting fbterm at 2015-04-08 13:16:26
[[ $(tty) == \/dev\/tty[0-9]* ]] && fbterm -- tmux

#xrdb loading xterm color
alias xterm='xrdb ~/.Xresources && xterm -e tmux'

# End of the block added by the lsgx

-----------------------------------------------------------------------

lsgx@UbuntuServer:~$   sudo vi /home/lsgx/.fbtermrc 
-------------------------------------------------------------
# font family names/pixelsize used by fbterm, multiple font family names must be seperated by ','
# and using a fixed width font as the first is strongly recommended
font-names= DejaVu Sans Mono
font-size=12

# max scroll-back history lines of every window, value must be [0 - 65535], 0 means disable it
history-lines=10240

# specify the favorite input method program to run
input-method=fcitx-fbterm

# default terminal screen 256 color
export TERM=fbterm

# restore white color
echo -ne "\e]P7ffffff"
---------------------------------------------------------


lsgx@UbuntuServer:~$   vi ~/.tmux.conf
-------------------------------------------------------------
#
# author   : lsgx <[email protected]>
# modified : 2014-11-12
#

#-- base settings --#
set -g default-terminal "screen-256color"  # 设置终端缺省的支持颜色为256色
set -g display-time 3000     # 提示信息的持续时间;设置足够的时间以避免看不清提示,单位为毫秒
set -g escape-time 0    # 等待时间的持续时间;设置越小越好
set -g history-limit 65535    # 历史记录条数的最大限制值
#set -g base-index 1    # 窗口的初始序号;默认为0,这里设置为1
#set -g pane-base-index 1    # 面板的初始序号;默认为0,这里设置为1
#set -sg repeat-time 600    # 控制台激活后的持续时间;设置合适的时间以避免每次操作都要先激活控制台,单位为毫秒
#set -s quiet on
#setw -g xterm-keys on

#-- bindkeys --#

# prefix key (Ctrl+a)    # 将激活控制台的快捷键由Ctrl+b修改为Ctrl+a
set -g prefix ^a
unbind ^b
bind a send-prefix

# split window    # 窗口分割
unbind '"'
bind - splitw -v # vertical split (prefix -)    # 上下分割窗口
unbind %
bind | splitw -h # horizontal split (prefix |)    # 左右分割窗口

# select pane    # 选择面板
bind k selectp -U # above (prefix k)    # 选择上面板
bind j selectp -D # below (prefix j)    # 选择下面板
bind h selectp -L # left (prefix h)    # 选择左面板
bind l selectp -R # right (prefix l)    # 选择右面板

# resize pane
bind -r ^k resizep -U 2 # upward (prefix Ctrl+k)    # 当前面板上移2
bind -r ^j resizep -D 2 # downward (prefix Ctrl+j)    # 当前面板下移2
bind -r ^h resizep -L 2 # to the left (prefix Ctrl+h)    # 当前面板左移2
bind -r ^l resizep -R 2 # to the right (prefix Ctrl+l)    # 当前面板右移2

# swap pane
bind ^u swapp -U # swap with the previous pane (prefix Ctrl+u)    # 与上面板交换
bind ^d swapp -D # swap with the next pane (prefix Ctrl+d)    # 与下面板交换

# create new session
bind C-c new-session    # 创建一个新的会话

# control sessions
bind z kill-session    # 结束当前会话

# find session
bind C-f command-prompt -p find-session 'switch-client -t %%'    # 查找会话
 
# clear both screen and history
#bind -n C-l send-keys C-l \; run 'tmux clear-history'    # 清空屏幕内容和历史记录

# reload config (prefix r)
bind r source ~/.tmux.conf \; display "Configuration reloaded!"    # 重新加载配置文件

# misc
bind e lastp  # select the last pane (prefix e)    # 选择最后一个面板
bind ^e last  # select the last window (prefix Ctrl+e)    # 选择最后一个窗口
bind q killp  # kill pane (prefix q)    # 关闭当前面板
bind ^q killw # kill window (prefix Ctrl+q)    # 关闭当前窗口


# app
bind ! splitw htop                                     # htop (prefix !)
bind m command-prompt "splitw 'exec man %%'"           # man (prefix m)
bind @ command-prompt "splitw 'exec perldoc -t -f %%'" # perl func (prefix @)
bind * command-prompt "splitw 'exec perldoc -t -v %%'" # perl var (prefix *)
bind % command-prompt "splitw 'exec perldoc -t %%'"    # perl doc (prefix %)
bind / command-prompt "splitw 'exec ri %%'"            # ruby doc (prefix /)


#-- statusbar --#
set -g status-utf8 on    # 开启状态栏的UTF-8支持
set -g status-interval 1    # 状态栏的分辨时间间隔
set -g status-keys vi    # 操作状态栏时的默认键盘布局;可以设置为vi或emacs
set -g visual-activity on    # 开启窗口操作的可视
set -g set-clipboard on    # 开启剪切板
set -g display-panes-time 800 # slightly longer pane indicators display time    # 稍长的窗格中显示的时间指标
set -g display-time 1000      # slightly longer status messages display time    # 稍长的状态消息的显示时间
set -g renumber-windows on    # renumber windows when a window is closed    # 关闭窗口后重新编号

setw -g automatic-rename on    # rename window to reflect current program    # 重命名窗口,以反映当前的程序
setw -g utf8 on    # 开启窗口的UTF-8支持
setw -g monitor-activity on    # 开启窗口活动监视
setw -g mode-keys vi    # 复制模式中的默认键盘布局;可以设置为vi或emacs
setw -g clock-mode-style 24 # 24 hour clock    # 24小时显示方式
#setw -g mode-mouse on    # 开启鼠标模式

# copy mode
bind Enter copy-mode # enter copy mode    # 按Enter进入复制模式
bind b list-buffers  # list paster buffers    # 复制缓冲区列表
bind p paste-buffer  # paste from the top pate buffer    # 粘贴最后复制的缓冲区内容
bind P choose-buffer # choose which buffer to paste from    # 选择粘贴缓冲区

# the following vi-copy bindings match my vim settings
# see https://github.com/gpakosz/.vim.git
bind -t vi-copy v begin-selection    # 复制模式下开始选取
bind -t vi-copy C-v rectangle-toggle    # 复制模式下矩形选取
bind -t vi-copy y copy-selection    # 复制模式下复制选取的内容
bind -t vi-copy Escape cancel    # 复制模式下退出复制模式
bind -t vi-copy H start-of-line    # 复制模式下开始行选取
bind -t vi-copy L end-of-line    # 复制模式下结束行选取

# mouse resize selcet
#setw -g mouse-resize-pane on    # 鼠标调整面板大小
#setw -g mouse-select-pane on    # 鼠标选择面板
#setw -g mouse-select-window on    # 鼠标选择窗口

# move x clipboard into tmux paste buffer
bind C-p run "tmux set-buffer \"$(xclip -o -sel clipbaord)\"; tmux paste-buffer" 
# move tmux copy buffer into x clipboard
bind C-y run "tmux show-buffer | xclip -i -sel clipbaord"


#-- colorscheme --#
# see also: https://github.com/daethorian/conf-tmux/blob/master/colors/zenburn.conf

# modes
setw -g clock-mode-colour colour223
setw -g mode-attr bold
setw -g mode-fg colour223
setw -g mode-bg colour235

# panes
set -g pane-border-bg colour234
set -g pane-border-fg colour234
set -g pane-active-border-bg colour232
set -g pane-active-border-fg colour232


# statusbar
set -g status-justify centre
set -g status-bg colour235
set -g status-fg colour248
set -g status-attr dim

set -g status-left "#[fg=green,bright]Session: #S #[fg=yellow,bright]Window: #I #[fg=cyan,bright]Pane: #P"
set -g status-left-attr bright
set -g status-left-length 30
set -g status-right "#[fg=yellow,bright][ #[fg=cyan,bright]#W #[fg=yellow,bright]]#[default] #[fg=yellow,bright]- %Y.%m.%d #[fg=green,bright]%H:%M #[default]"
set -g status-right-attr bright
set-option -g status-right-length 30

setw -g window-status-current-fg colour223
setw -g window-status-current-bg colour237
setw -g window-status-current-attr bold
#setw -g window-status-current-format "#I:#W#F"

#setw -g window-status-alert-attr bold
#setw -g window-status-alert-fg colour255
#setw -g window-status-alert-bg colour160

# messages
set -g message-attr bold
set -g message-fg colour223
set -g message-bg colour235

--------------------------------------------------------------------



lsgx@debian7:~$ vi ~/.Xresources
-----------------------------------------------
! % xrdb -load ~/.Xresources
! % xrdb -query
! % xrdb -symbol
! % xrdb -merge ~/.Xresources

! XTerm config

!look and feel
xterm.termName: xterm-256color
xterm.geometry: 80x36
xterm*scrollBar: false
xterm*rightScrollBar: true
XTerm*jumpScroll:  true
XTerm*SaveLines: 1000
xterm*loginshell: true
xterm*cursorBlink: true
xterm*background:  #1c5572
xterm*foreground:  white
xterm.borderLess: true
xterm.cursorBlink: true
xterm*colorUL: yellow
xterm*colorBD: white

!font and locale
xterm*locale: true
xterm.utf8: true
xterm*utf8Title: true

xterm*fontMenu*fontdefault*Label: Default
XTerm*font: -misc-fixed-medium-r-normal-*-18-120-100-100-c-90-iso10646-1
XTerm*wideFont: -misc-fixed-medium-r-normal-*-18-120-100-100-c-180-iso10646-1

xterm*faceName: DejaVu Sans Mono:antialias=True:pixelsize=12
xterm*faceNameDoublesize: Droid Sans Fallback:antialias=True:pixelsize=14
xterm*xftAntialias: true
xterm*cjkWidth: false

XTerm*font1.Label: efont 12 pixel
XTerm*font1: -efont-fixed-medium-r-normal-*-12-120-75-75-c-60-iso10646-1
XTerm*wideFont1: -efont-fixed-medium-r-normal-*-12-120-75-75-c-120-iso10646-1

XTerm*font2.Label: misc 13 pixel
XTerm*font2: -misc-fixed-medium-r-semicondensed-*-13-120-75-75-c-60-iso10646-1
XTerm*wideFont2: -misc-fixed-medium-r-normal-*-13-120-75-75-c-120-iso10646-1

XTerm*font3.Label: efont 14 pixel
XTerm*font3: -efont-fixed-medium-r-normal-*-14-140-75-75-c-70-iso10646-1
XTerm*wideFont3: -efont-fixed-medium-r-normal-*-14-140-75-75-c-140-iso10646-1

XTerm*font4.Label: efont 16 pixel
XTerm*font4: -efont-fixed-medium-r-normal-*-16-160-75-75-c-80-iso10646-1
XTerm*wideFont4: -efont-fixed-medium-r-normal-*-16-160-75-75-c-160-iso10646-1

XTerm*font5.Label: misc 18 pixel
XTerm*font5: -misc-fixed-medium-r-normal-*-18-120-100-100-c-90-iso10646-1
XTerm*wideFont5: -misc-fixed-medium-r-normal-*-18-120-100-100-c-180-iso10646-1

XTerm*font6.Label: efont 24 pixel
XTerm*font6: -efont-fixed-medium-r-normal-*-24-240-75-75-c-120-iso10646-1
XTerm*wideFont6: -efont-fixed-medium-r-normal-*-24-240-75-75-c-240-iso10646-1

!fix alt key input 
xterm*eightBitInput: false
xterm*altSendsEscape: true

!print color and bold/underline attributes
xterm*printAttributes: 2
xterm*printerCommand: cat > ~/xtermdump

!mouse selecting to copy, ctrl-v to paste
!Ctrl p to print screen content to file
XTerm*VT100.Translations: #override \
    Ctrl <KeyPress> V: insert-selection(CLIPBOARD,PRIMARY,CUT_BUFFER0) \n\
    <BtnUp>: select-end(CLIPBOARD,PRIMARY,CUT_BUFFER0) \n\
    Ctrl <KeyPress> P: print() \n

!-- Tango color scheme
*xterm*color0: #2e3436
*xterm*color1: #cc0000
*xterm*color2: #4e9a06
*xterm*color3: #c4a000
*xterm*color4: #3465a4
*xterm*color5: #75507b
*xterm*color6: #0b939b
*xterm*color7: #d3d7cf
*xterm*color8: #555753
*xterm*color9: #ef2929
*xterm*color10: #8ae234
*xterm*color11: #fce94f
*xterm*color12: #729fcf
*xterm*color13: #ad7fa8
*xterm*color14: #00f5e9
*xterm*color15: #eeeeec
----------------------------------------------------------
lsgx@UbuntuServer:~$   xrdb -load ~/.Xresources


lsgx@UbuntuServer:~$  sudo vi /etc/X11/Xsession.d/95xinput
---------------------------------------------------
export XMODIFIERS="@im=fcitx" 
export XIM=fcitx
export XIM_PROGRAM=/usr/bin/fcitx
export XIM_ARGS=""
export GTK_IM_MODULE=XIM
export QT_IM_MODULE=XIM
export DEPENDS="fcitx"
/usr/bin/fcitx &
----------------------------------------------------
lsgx@UbuntuServer:~$  sudo chmod a+x /etc/X11/Xsession.d/95xinput 

lsgx@UbuntuServer:~$  vi ~/. profile 
lsgx@UbuntuServer:~$  cat ~/.profile 
-----------------------------------------------------------------------
# Beginning of the block added by the lsgx - DO NOT EDIT

# Add setting fcitx at 2015-04-08 13:16:26
export XMODIFIERS="@im=fcitx" 
export XIM=fcitx
export XIM_PROGRAM=/usr/bin/fcitx
export XIM_ARGS=""
export GTK_IM_MODULE=XIM
export QT_IM_MODULE=XIM
export DEPENDS="fcitx"
/usr/bin/fcitx &

# End of the block added by the lsgx
---------------------------------------------------------

lsgx@UbuntuServer:~$  im-config
lsgx@UbuntuServer:~$  sudo im-config
lsgx@UbuntuServer:~$  sudo reboot
lsgx@UbuntuServer:~$  dbus-launch 
lsgx@UbuntuServer:~$  fcitx-autostart
lsgx@UbuntuServer:~$  fcitx-configtool
lsgx@UbuntuServer:~$  sudo reboot


安装时主要步骤说明:
1.安装 fbterm
$ sudo apt-get install fbterm

2. 问题 "cann't open frame buffer device!"
$ sudo usermod -aG video USERNAME

3.问题"[input] can't change kernel keymap table, all shortcuts will NOT work,  see SECURITY NOTES section of man page for solution."
$ sudo chmod u+s /usr/bin/fbterm

4. 安装、添加中文输入法
$ sudo apt-get install fcitx fcitx-googlepinyin fcitx-frontend-fbterm
    添加输入法:
$ vi .fbtermrc
    修改输入法:   
      input-method=fcitx-fbterm

5.关于修改字体、大小
$ vi .fbtermrc
    修改字体大小:
      font-size=16
    修改字体类型:
      font-names=Ubuntu Mono
    下面的命令可以查看安装的字体:
$ fc-list


三:fbterm的使用
显示效果:
fbterm使用_第1张图片

man fbterm 的说明:
FbTerm(1)                                   FbTerm User Manual                                   FbTerm(1)



NAME
       FbTerm - a fast Frame Buffer based TERMinal emulator for linux

SYNOPSIS
       fbterm [options] [--] [command [arguments]]

DESCRIPTION
       FbTerm  is a fast terminal emulator for linux with frame buffer device or VESA video card. Features
       include:

         * mostly as fast as terminal of linux kernel while accelerated scrolling is enabled
         * select font with fontconfig and draw text with freetype2, same as Qt/Gtk+ based GUI apps
         * dynamically create/destroy up to 10 windows initially running default shell
         * record scroll-back history for every window
         * auto-detect current locale and convert text encoding, support double width  scripts  like  Chi‐
       nese, Japanese etc
         * switch between configurable additional text encodings with hot keys on the fly
         * copy/past selected text between windows with mouse when gpm server is running
         * change the orientation of screen display, a.k.a. screen rotation
         * lightweight input method framework with client-server architecture
         * background image for eye candy

OPTIONS
       command  [arguments] may be given to override the built-in choice of shell program. Normally FbTerm
       checks the SHELL variable. If that is not set, it tries to use the user's login shell program spec‐
       ified  in  the password file. If that is not set, /bin/sh will be used. You should use the -- argu‐
       ment to separate FbTerm's options from the arguments supplied to the command.

       FbTerm first uses option value specified in command line arguments,  then  in  the  configure  file
       $HOME/.fbtermrc.   If  that  file  doesn't  exist,  FbTerm  will  create it with default options on
       startup.

       -h, --help
              display the help and exit

       -V, --version
              display FbTerm version and exit

       -v, --verbose(显示其他的详细信息)
              display extra FbTerm's information

       -n, --font-names=text(指定字体名称)
              specify font family names

       -s, --font-size=num(指定字体大小)
              specify font pixel size

       --font-width=num(调整字体宽度)
              force font width

       --font-height=num(调整字体高度)
              force font height

       -f, --color-foreground=num(指定前景色)
              specify foreground color

       -b, --color-background=num(指定背景色)
              specify background color

       -e, --text-encodings=text(指定文字编码)
              specify additional text encodings

       -a, --ambiguous-wide(字符模糊宽度)
              treat ambiguous width characters as wide

       -r, --screen-rotate=num(指定屏幕显示方向)
              specify the orientation of screen display

       -i, --input-method=text(指定输入法程序)
              specify input method program

       --cursor-shape=num(指定默认的光标形状)
              specify default cursor shape

       --cursor-interval=num(指定光标闪烁间隔)
              specify cursor flash interval

       --vesa-mode=num(指定视频模式)
              specify VESA video mode

       --vesa-mode=list(显示可用的视频模式)
              display available VESA video modes


       see comments in $HOME/.fbtermrc for details of these options.

SHORTCUT SUMMARY
       keyboard:
         CTRL_ALT_E:    exit from FbTerm
         CTRL_ALT_C:    create a new window
         CTRL_ALT_D:    destroy current window
         CTRL_ALT_1:    switch to window 1
         CTRL_ALT_2:    switch to window 2
         CTRL_ALT_3:    switch to window 3
         CTRL_ALT_4:    switch to window 4
         CTRL_ALT_5:    switch to window 5
         CTRL_ALT_6:    switch to window 6
         CTRL_ALT_7:    switch to window 7
         CTRL_ALT_8:    switch to window 8
         CTRL_ALT_9:    switch to window 9
         CTRL_ALT_0:    switch to window 10
         SHIFT_LEFT:    switch to previous window
         SHIFT_RIGHT:   switch to next window
         SHIFT_PAGEUP:    history scroll up
         SHIFT_PAGEDOWN:  history scroll down
         CTRL_ALT_F1:                 switch to encoding of current locale
         CTRL_ALT_F2 to CTRL_ALT_F6:  switch to additional encodings
         CTRL_SPACE:    toggle input method
         CTRL_ALT_K:    kill input method server

快捷方式的总结
    键盘:
ctrl_alt_e:退出fbterm
ctrl_alt_c:创建一个新的窗口
ctrl_alt_d:破坏当前窗口
ctrl_alt_1:切换到窗口1
ctrl_alt_2:切换到窗口2
ctrl_alt_3:切换到窗口3
ctrl_alt_4:切换到窗口4
ctrl_alt_5:切换到窗口5
ctrl_alt_6:切换到窗口6
ctrl_alt_7:切换到窗口7
ctrl_alt_8:切换到窗口8
ctrl_alt_9:切换到窗口9
ctrl_alt_0:切换到窗口10
shift_left:切换到前一个窗口
shift_right:切换到下一个窗口
shift_pageup:历史上滚动
shift_pagedown:历史向下滚动
ctrl_alt_f1:切换到当前区域编码
ctrl_alt_f2到ctrl_alt_f6:切换到其他编码
ctrl_space:切换输入法
ctrl_alt_k:杀了输入法服务器

       mouse:
         move when left button down:      select text
         double click with left button:   auto select text
         click with right button:         paste selected text

    鼠标:
移动时,左键:选择文本
左键双击:自动选择文本
用右键单击: 粘贴选定的文字

       Sometimes above actions will not work, please try to redo them with shift key holding down.

FRAME BUFFER DEVICE
       Before executing FbTerm, make sure there is a frame buffer device in  your  system,  and  you  have
       read/write  access right with it. Normally FbTerm tries to open /dev/fb0 and /dev/fb/0, environment
       variable "FRAMEBUFFER" may be used to override this built-in behavior.

VESA VIDEO DEVICE
       From version 1.6, FbTerm adds VESA video card support. By default, FbTerm tries frame buffer device
       first,  if  failure,  then tries to use VESA device with highest resolution and color depth. option
       "vesa-mode" may be given to force only open VESA device with  the  specified  video  mode.  To  see
       available video modes for your VESA card, execute " fbterm --vesa-mode=list".

       Attention:  1)  VESA support requires root privilege to work; 2) do not force to use VESA device on
       the system with frame buffer device enabled, they maybe conflict with each other.

FONT
       FbTerm invokes fontconfig to get a font list, if the first font doesn't contain the glyph  for  the
       rendering  character,  it  will  try  second font, then the third, ... and so on, user can see this
       ordered font list with " fbterm -v".

       If you don't like the fonts selected by FbTerm, execute " fc-list" to get  available  fonts,  choose
       favorites  as  the value of option " font-names". You may also modify the configure file of fontcon‐
       fig, which will change the behavior of all programs based on fontconfig!

TEXT ENCODING
       By using iconv, FbTerm converts other encodings to internal  encoding  UTF-8.  On  startup,  FbTerm
       checks  variable  LC_CTYPE  to  determine  the  default  text encoding, which is binded to shortcut
       CTRL_ALT_F1.  User can specify up to 5 additional encodings with option "text-encodings", for exam‐
       ple,  as  a Chinese user, you set "text-encodings=gbk,big5", shortcut CTRL_ALT_F2 will bind to gbk,
       and CTRL_ALT_F3 bind to big5.

       In a number of CJK encodings there are ambiguous width characters which have a width of either nar‐
       row  or  wide depending on the context of their use. By default, FbTerm treats them as narrow width
       characters, option "ambiguous-wide" may be used to change the behavior.

BACKGROUND IMAGE
       FbTerm doesn't load and parse any image file with various formats  directly,  instead  it  takes  a
       screen  shot of frame buffer device on startup if variable FBTERM_BACKGROUND_IMAGE is defined, then
       uses this screen shot as the background for text rendering. In order  to  enable  background  image
       support, user should first put a image to frame buffer device with a image viewer. A wrapper script
       using fbv is listed below:

           #!/bin/bash

           # fbterm-bi: a wrapper script to enable background image with fbterm
           # usage: fbterm-bi /path/to/image fbterm-options

           echo -ne "\e[?25l" # hide cursor

           fbv -ciuker "$1" << EOF
           q
           EOF

           shift
           export FBTERM_BACKGROUND_IMAGE=1
           exec fbterm "$@"

       Attention: 1) do not enable background image on frame buffer device with 8bpp depth, because FbTerm
       changes  color  map  table  for correct text rendering; 2) if the screen shot is different from the
       original image, try to use a fast scrolling disabled frame buffer device.

256 COLOR EXTENSION
       FbTerm supports xterm's 256 color mode extension. The first 16 colors are the default terminal col‐
       ors. Additionally, there's a 6x6x6 color cube, and 24 grayscale tones. But xterm's 256 color escape
       sequences conflict with the linux sequences implemented by FbTerm, so private escape sequences were
       introduced to support this feature:

           ESC [ 1 ; n }                   set foreground color to n (0 - 255)
           ESC [ 2 ; n }                   set background color to n (0 - 255)
           ESC [ 3 ; n ; r ; g ; b }       set color n to (r, g, b) ,  n, r, g, b all in (0 - 255)

       A  new terminfo database entry named "fbterm" was added to use these private sequences, all program
       based on terminfo should work with it.  By default, FbTerm  sets  environment  variable  "TERM"  to
       value "linux", user need run "TERM=fbterm /path/to/program" to enable 256 color mode.

INPUT METHOD
       Instead  of adding input method directly in FbTerm, a client-server based input method framework is
       designed to do this work. FbTerm acts as a client, standalone IM program as a server, and they  run
       in separated processes.

       As  a  normal  IM  user,  you should install a IM program written for FbTerm, and specify it as the
       value of option "input-method".  CTRL_SPACE is the shortcut to  activate/deactivate  input  method.
       And CTRL_ALT_K may be used to kill the IM program when it has freezed.


SECURITY NOTES
       FbTerm tries to change linux kernel key map table to setup shortcuts, which requires SYS_TTY_CONFIG
       capability since kernel version 2.6.15. It means FbTerm should be a setuid 0 program to allow  non-
       root  users  to use shortcuts. FbTerm only switches to root privilege temporarily when changing key
       map table, we believe it's pretty much free from security problems.  If you really don't like  this
       and  have a linux kernel with file system capabilities enabled, which allow user to give binaries a
       subset of root's powers without using setuid 0 (official kernel 2.6.27 includes it),  you  can  run
       command "sudo setcap 'cap_sys_tty_config+ep' /path/to/fbterm".

       FbTerm  redirects  /dev/tty0  output  to the pseudo terminal of current sub-window. In linux before
       version 2.6.10, anybody can do this as long as the output was not  redirected  yet;  since  version
       2.6.10,  only root or a process with the CAP_SYS_ADMIN capability may do this.  You should do simi‐
       lar work with above ones for FbTerm to enable this feature for non-root users.


PERFORMANCE
       According test result, FbTerm spends more than 95% time on painting screen. Speedup  painting  will
       significantly increase performance. Here are some suggestions for frame buffer device:

         *  Enable  fast scrolling on frame buffer device. The visible screen will be just a window of the
       video memory, when scrolling, FbTerm only change the start of window, no need to repaint the  whole
       screen.

         *  On  Intel  P6 family processors the Memory Type Range Registers (MTRRs) may be used to control
       processor access to memory ranges. If you have video card on a PCI or AGP bus, enabling  write-com‐
       bining  allows  bus  write transfers to be combined into a larger transfer before bursting over the
       PCI/AGP bus. This can increase performance of FbTerm's paint operations.

       Maybe you need to enable them manually for your video card. For example, by default fast  scrolling
       and  write-combining are all disabled on general VESA frame buffer device, GRUB/LILO configure file
       should be modified to enable them.  A GRUB example is showed below:

       title Ubuntu
           root (hd0,0)
           kernel /boot/vmlinuz ro root=LABEL=UBUNTU splash vga=0x317 video=vesafb:ywrap,mtrr:3
           initrd /boot/initrd.img

       You may check fast scrolling status with "fbterm -v", a message with "scrolling: redraw" means fast
       scrolling is disabled, otherwise enabled.

AUTHOR
       Written by dragchan.

REPORTING BUGS
       Please submit bug reports to <http://code.google.com/p/fbterm/issues>.

COPYRIGHT
       Copyright    ©    2008-2010    dragchan.    License   GPLv2:   GNU   GPL   version   2   or   later
       <http://gnu.org/licenses/gpl.html>.
       This is free software: you are free to change and redistribute it.  There is NO  WARRANTY,  to  the
       extent permitted by law.



FbTerm 1.7                                     October 2010                                      FbTerm(1)


四:fbterm 的相关字符界面命令
1. 控制台中文显示与输入 fbterm + ucimf 
      除了输入法不如cce,其他的很强大,支持 X-window 字体,支持背景图片,快捷键创建、关闭窗口(有更高的需求,可以用screen)。 
      安装步骤:http://www.linuxsir.org/bbs/showthread.php?p=1968130 
      照着一步一步作就OK~ 
      设置背景图片参见man里的代码 
    fbterm分辨率只能到 1024 * 768。。 
  
      zhcon 装上运行crash,好像要把 bootsplash 相关包卸掉。。。直接gg 
      cce 输入法比较赞,ls 后提示符有时不会换行。编译时要在 src/term/term.c 中加一句 "#define __WINDOWS__" 
  
2. 鼠标 
      gpm: 应该都有打包 
      启动 ps2 鼠标: gpm -m /dev/input/mice -t exps2 
      停止运行:gpm -k  
      列出支持鼠标种类:gpm -t help 
  
3. 看图:
      fbida: 下载地址
  
4. 抓图: 
      fbgrab: http://hem.bredband.net/gmogmo/fbgrab/  
  
5. 看pdf ps 
      fbiad: http://linux.bytesex.org/fbida/ 
      里面提供了几个很好用的工具: 
        fbi: 看图 
        fbgs: 看pdf ps 
        exiftran:保留EXIF数据,转换到jpeg 
  
      poppler-tools: http://poppler.freedesktop.org  
      里面有一系列的 pdftoxx 工具。其中 pdftotex 比较有意思的,用它可以对 pdf 进行 grep~ 
       
    fbv fbi fbgs这些软件只能在纯console下使用,开fbterm后用不了…… 
  
6. 音乐: 
      mocp 2.4.4: http://moc.daper.net/ 
      mp3 wma ogg 等,更换皮肤,自定义操作键,对中文支持非常好~ q 键可以detach(省一个终端^^) 
      SuSE提供的包是 2.4.2,运行crash,于是源码编译安装(arch debian 提供的包看讨论ms也有些问题,可以先装上试试~) 
      不过……编译时依赖的库比较多,而且放wma有一个bug。。。折腾了将近两天… 
         ./configure 完后,提示信息应该跟下面类似: 
         ---------------------------------------------------------------- 
         MOC will be compiled with: 
         Decoder plugins:    mp3 vorbis flac ffmpeg speex 
         OSS:               yes 
         ALSA:              yes 
         JACK:              yes 
         DEBUG:             yes 
         RCC:               yes 
         Network streams:   yes  
         Resampling:        yes 
        推荐把README中提到的依赖库都装上……如果没看到上面加粗的两个 plugin ,看看依赖库和头文件有没有装 
  
        如 此make && make install可以顺利通过,不过播放wma时会crash。这个bug找了N久……最后侥幸从一个warning中发现问题。原因是新的 ffmpeg 没有提供 avcodec_decode_audio() 函数,而是用新的 avcodec_decode_audio2() 将其替代,修改后OK(后来发现这个bug已经有人提交了,囧)。 
        修改 decoder_plugins/ffmpeg/ffmpeg.c 
          将 int data_size; 删掉,在 char avbuf[AVCODEC_MAX_AUDIO_FRAME_SIZE * sizeof(int16_t)]; 后添加 int data_size = sizeof(avbuf); 
          将 avcodec_decode_audio 换成 avcodec_decode_audio2 
    太好了,mocp终于能正常工作了~ 
    不过中文显示很扭曲……修改配置文件轻松搞定。配置文件见附件…… 
  
      mocp 挑bug过程中,尝试了其他一些播放器: 
      mplay: http://mplay.sourceforge.net/mplayer  mplayer ncurse前端,用perl写的。有些功能做的很细致,安装简单,不过文档较少,中文显示没搞定,而且没有找到播放playlist的方法…… 
      mp3blaster: 界面在console下显示的一塌糊涂,直接gg…… 
      mpgxxx: 没印象了…… 
      cmus: http://onion.dynserv.net/~timo/index.php?page=Projects/cmus 一堆头文件的包含错误,gg 
      mpd: http://mpd.wikia.com/wiki/Music_Player_Daemon_Wiki 装上运行断错误,gg 
      mplayer: 除了界面……完美的播放器。。 
    
    更多播放器:http://moc.daper.net/links 
  
7. 视频: 
      mplayer:谁用谁知道…… 
  
8. 上网: 
      w3m: http://w3m.sourceforge.net/ 
      很早以前直接装的rpm,中文支持完美,可以显示图片~ 
      不支持CSS Javascript…… 
     
      elinks: 通过 setup-->character set -> windows$ 1252 可以显示中文,不过locale要设成gbk,而且有些还是会乱码。不能显示图片。 
      除了上面两点,其他方面比较强大,支持新建tab,部分支持CSS,支持Javascript,支持full color。 
  
      telnet: 上论坛(基本不会用 =。=) 
  
9. 邮件客户端: 
      alpin: http://en.wikipedia.org/wiki/Alpine_(e-mail_client) 
            gmail:  
            1. 登录gmail,设置-POP/IMAP 里勾上IMAP,保存。 
            2. 启动alpine,输入msla,nickname随便写,Server 出填写 imap.gmail.com/ssl/[email protected]/novalidate-cert 
            3. 输入msc。SMTP server: smtp.gmail.com/submit/[email protected]/novalidate-cert 
            4. 用whereis命令,找到Display Character Set 和 Posting Character Set,都设为UTF-8 
  
    其他客户端:http://en.wikipedia.org/wiki/Alpine_(e-mail_client) 


五:fbterm 的相关参考

中文的locale在tty下查看以及输入中文一直是个头疼问题。FbTerm 是一个使用 frame buffer 设备或 VESA 显卡的终端模拟器,在Ubuntu下可与ibus或fcitx配合使用,实现中文输出和输入。
附件:
文件注释: console截屏
 
screen.png [ 51.09 KiB | 被浏览 18845 次 ]


在Ubuntu下安装和使用fbterm虚拟控制台:

1 安装v86d实现控制台下vesa输出
代码:
$ sudo apt-get install v86d

为了方便你查看显卡可用的输出模式,可以安装hwinfo
代码:
$ sudo apt-get install hwinfo
$ sudo hwinfo --framebuffer

这两个包在下面的脚本中会自动安装,如果你已经安装了,可以无视。

2 配置framebuffer。修改/boot/default/grub,在内核启动选项中加入framebuffer输出和分辨率的设置,在intramfs的模块中加入vesa的framebuffer及其设置,在intramfs的开机splash配置中开启framebuffer(可选)。

以上两个步骤非常重要,是能正常使用fbterm的基础,并且可以解决Ubuntu安装Nvidia二进制驱动后grub、开机动画和控制台分辨率过低的问题。下面这个脚本可以自动完成上面这两个步骤的所有配置工作(感谢D0rkye):
[bash]
#!/bin/bash
# ----------------------------------
# Author: D0rkye
# Homepage:  http://d0rkye.zsenialis.com/
# Most code probably by kyleabaker:  http://kyleabaker.com/2010/07/11/how-to ... ot-screen/
#
# Fix for Ubuntu 11.04, for BURG, and some extra bloat by Paolo Bernardi ( http://paolobernardi.wordpress.com/)
# ----------------------------------

# Usage: install_if_not_installed package_name
function install_if_not_installed
{
PACKAGE="$1"
INSTALLED=$(dpkg -L "$PACKAGE" > /dev/null 2>&1 && echo OK || echo KO)
if [ "$INSTALLED" == "KO" ]
then
sudo apt-get install "$PACKAGE" -y
fi
}

# Usage: contains regexp file
function contains
{
REGEXP="$1"
FILE="$2"

grep "$REGEXP" "$FILE" > /dev/null && echo OK || echo KO
}

install_if_not_installed v86d
install_if_not_installed hwinfo

sudo hwinfo --framebuffer
echo "---------------------------------------------------------------"
echo "Please enter the best resolution from the list above"
echo "It usualy looks like this >>Mode 0x0323: 1024x768 (+4096), 24 bits<<"
echo "And you have to enter it like this >>1024x768-24<<"
echo "---------------------------------------------------------------"
read resolution

sed 's/GRUB\_CMDLINE\_LINUX\_DEFAULT\=\"quiet\ splash\"/GRUB\_CMDLINE\_LINUX\_DEFAULT\=\"quiet\ splash\ nomodeset\ video\=uvesafb\:mode\_option\='$resolution'\,mtrr\=3\,scroll\=ywrap\"/g' /etc/default/grub > ./newgrub
sudo cp -f ./newgrub /etc/default/grub
rm ./newgrub

sed 's/GRUB\_CMDLINE\_LINUX\_DEFAULT\=\"quiet\ splash\"/GRUB\_CMDLINE\_LINUX\_DEFAULT\=\"quiet\ splash\ nomodeset\ video\=uvesafb\:mode\_option\='$resolution'\,mtrr\=3\,scroll\=ywrap\"/g' /etc/default/burg > ./newburg
sudo cp -f ./newburg /etc/default/burg
rm ./newburg

sed 's/\#GRUB\_GFXMODE\=640x480/GRUB\_GFXMODE\='$resolution'/g' /etc/default/grub > ./newgrub
sudo cp -f ./newgrub /etc/default/grub
rm ./newgrub

if [ "$(contains uvesafb /etc/initramfs-tools/modules)" == 'KO' ]
then
sudo echo "uvesafb mode_option=$resolution mtrr=3 scroll=ywrap" | sudo tee -a /etc/initramfs-tools/modules
fi

if [ "$(contains FRAMEBUFFER=y /etc/initramfs-tools/conf.d/splash)" == 'KO' ]
then
echo FRAMEBUFFER=y | sudo tee /etc/initramfs-tools/conf.d/splash
fi

#sed 's/GRUB\_CMDLINE\_LINUX\_DEFAULT\=\"\(.*\)vt\.handoff\=7\(.*\)\"/GRUB\_CMDLINE\_LINUX\_DEFAULT\=\"\1\2\"/g' /etc/grub.d/10_linux > ./new10linux
sed 's/vt\_handoff\=\(.*\)vt\.handoff\=7\(.*\)/vt\_handoff\=\1\2/g' /etc/grub.d/10_linux > ./new10linux
sudo cp -f ./new10linux /etc/grub.d/10_linux
rm ./new10linux
sudo chmod +x /etc/grub.d/10_linux

sudo update-grub2
which update-burg > /dev/null 2>&1 && sudo update-burg
sudo update-initramfs -u
echo "The resolution should be fixed after a reboot"
[/bash]
如果你看到有关burg的输出字样而你并没有安装burg,可以无视。

3 安装fbterm
代码:
$ sudo apt-get install fbterm

4 安装输入法的fbterm模块。我使用的是fcitx,就以fcitx为例。fcitx为fbterm提供的输入模块叫fcitx-fbterm。
代码:
sudo apt-get install fcitx-frontend-fbterm

也可以到其github主页上下载源码包并编译安装。
代码:
$ git clone https://github.com/fcitx/fcitx-fbterm.git
$ cd fcitx-fbterm
$ mkdir build && cd build
$ cmake ..
$ make && sudo make install

编译所依赖的包主要是fcitx的开发库,fcitx-libs-dev。

5 把用户加入到可以使用framebuffer输出的组,这个组叫video
代码:
$ sudo adduser your_name video

6 配置fbterm,fbterm默认的配置文件在~/.fbtermrc,打开后你可以修改虚拟终端输出分辨率,字体,字号,背景色,前景色,甚至可以选用背景图片。

在这里强调的是fbterm的一个安全特性,这个特性会让普通用户在控制台下无法使用系统快捷键,因此无法调出中文输入法。解决办法是:
代码:
sudo setcap 'cap_sys_tty_config+ep' /usr/bin/fbterm

或者:
代码:
sudo chmod u+s /usr/bin/fbterm

7 到这里,所有工作基本都做完了,接下来你可以按下ctrl+alt+F1,登录后输入fbterm,就可以正常显示中文了。fcitx-fbterm提供了一个脚本,可以直接打开fbterm并调用fcitx,命令名是 fcitx-fbterm-helper
代码:
$ env DISPLAY=:0 fcitx-fbterm-helper

如果你使用纯shell,之前fcitx并没有启动,那么
代码:
$ env DISPLAY=:0 fcitx-fbterm-helper -l

一般情况下,也可以直接指定输入法并启动fbterm
代码:
env DISPLAY=:0 fbterm -i fcitx-fbterm

8 为了方便,可以在.bashrc加入一行,用来在登录tty的时候自动运行fbterm
代码:
echo "[[ $(tty) == \/dev\/tty[0-9]* ]] && fcitx-fbterm-helper" >> ~/.bashrc
,这样每次你从tty登录,会自动运行fbterm及fcitx-fbterm。

9 fbterm可以将要使用的输入法设置写入配置文件
,在~/.fbtermc中写入
代码:
input-method=fcitx-fbterm

启动fbterm后就会启用fcitx输入,当然你也可以使用ibus-fbterm。

10 fbterm支持256色显示,这样看起来要漂亮一些。默认情况下,fbterm的运行环境是echo $TERM=linux,此时使用16位色;当echo $TERM=fbterm,则使用256色。例如
代码:
 TERM=fbterm vim ~/.fbtermrc

则使用256色运行vim,这样你就可以使用vim的256色主题。一劳永逸的办法是在fbterm中运行
代码:
export TERM=fbterm

这样在本次fbterm会话中将一直使用256色。256色的背景/前景色定义与~/.fbtermrc中的16位色有所不同,具体参考man文档。

11 将灰白调回纯白。fbter默认将白色显示为灰色,看上去很别扭,在fbterm中运行
代码:
echo -ne "\e]P7ffffff"

12 鼠标支持。fbterm可以与gpm server配合用鼠标进行复制/粘贴。
代码:
sudo apt-get install gpm
sudo service gpm start

切换到fbterm,移动鼠标就可以了。

13 fbterm设置背景图片的方法,参考 man fbterm的150行,关于快捷键安全特性,参考207行


_________________
添加ppa后只更新此ppa:
update-ppa()
{ sudo apt-get update -o Dir::Etc::sourcelist="sources.list.d/$1.list" -o Dir::Etc::sourceparts="-" -o APT::Get::List-Cleanup="0"
}
写入~/.bashrc,source一下,就可以直接用,是不是很方便?觉得方便就按个赞。
 

最后由 funicorn 编辑于 2012-10-04 21:17,总共编辑了 16 次  

来源: <http://forum.ubuntu.org.cn/viewtopic.php?f=8&t=382065>
 

来自为知笔记(Wiz)


你可能感兴趣的:(fbterm使用)