1 安装v86d实现控制台下vesa输出
代码: 全选
$ sudo apt-get install v86d
代码: 全选
$ 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
代码: 全选
sudo apt-get install fcitx-frontend-fbterm
代码: 全选
$ git clone https://github.com/fcitx/fcitx-fbterm.git
$ cd fcitx-fbterm
$ mkdir build && cd build
$ cmake ..
$ make && sudo make install
5 把用户加入到可以使用framebuffer输出的组,这个组叫video
代码: 全选
$ sudo adduser your_name video
在这里强调的是fbterm的一个安全特性,这个特性会让普通用户在控制台下无法使用系统快捷键,因此无法调出中文输入法。解决办法是:
代码: 全选
sudo setcap 'cap_sys_tty_config+ep' /usr/bin/fbterm
代码: 全选
sudo chmod u+s /usr/bin/fbterm
代码: 全选
$ env DISPLAY=:0 fcitx-fbterm-helper
代码: 全选
$ env DISPLAY=:0 fcitx-fbterm-helper -l
代码: 全选
env DISPLAY=:0 fbterm -i fcitx-fbterm
代码: 全选
echo "[[ $(tty) == \/dev\/tty[0-9]* ]] && fcitx-fbterm-helper" >> ~/.bashrc
9 fbterm可以将要使用的输入法设置写入配置文件,在~/.fbtermc中写入
代码: 全选
input-method=fcitx-fbterm
10 fbterm支持256色显示,这样看起来要漂亮一些。默认情况下,fbterm的运行环境是echo $TERM=linux,此时使用16位色;当echo $TERM=fbterm,则使用256色。例如
代码: 全选
TERM=fbterm vim ~/.fbtermrc
代码: 全选
export TERM=fbterm
11 将灰白调回纯白。fbter默认将白色显示为灰色,看上去很别扭,在fbterm中运行
代码: 全选
echo -ne "\e]P7ffffff"
代码: 全选
sudo apt-get install gpm
sudo service gpm start
13 fbterm设置背景图片的方法,参考 man fbterm的150行,关于快捷键安全特性,参考207行