Display Server
X和Xorg
X11是Linux下的桌面协议,而Xorg是X11协议的一个实现。
很长一段时间里X11一直是Linux下桌面的唯一标准。支持它的程序也最多。
作为一个C/S式架构的协议,X的效率不能恭维,但是也给了它远程渲染的特性。 X协议可以直接通过tcp传输,从而实现允许运行远程应用。
ssh -XY [remote host]
目前X仍被主流发行版。
startx # 启动X server
startx & vlock # 登入后锁定tty
Wayland
wayland是为了提高Linux桌面渲染的效率而开发的,它也是一个显示协议。 wayland使得图形合成直接和内核通信,减少了X server这一环节。高效不少。
同时作为一个过渡手段,Wayland也允许支持X协议。
Display Drivers
intel
因为使用的是笔记本,集显还是需要的。
我使用gentoo系统在profile/make.default
中配置显卡环境变量。
VIDEO_CARDS="intel"
内核中也需要编译intel驱动。现在配置Xorg.conf
使用intel驱动。
Section "Monitor"
Identifier "Monitor0"
EndSection
Section "Device"
Identifier "Intel Graphics"
Driver "intel"
EndSection
Section "Screen"
Identifier "Screen0"
Device "Intel Graphics"
Monitor "Monitor0"
EndSection
xbacklight # 修改亮度
/sys/class/backlight
内核屏幕亮度接口可以达到同样功能。
Nvidia
可选的驱动有开源的nouveau
和NVidia官方闭源驱动nvidia-drivers
。
开源驱动支持PRIME
显卡切换技术。但是性能堪忧。
闭源驱动有着完全体的性能。但是仍有不少bug。
这里同时安装两者,修改make.conf
。
VIDEO_CARDS="-* intel nvidia nouveau"
nvidia
需要修改内核,参考《Linux Kernel Userage》。
而nouveau
可以直接在内核中开启。
修改内核后更新系统。xorg将自动依赖nvidia-drivers
。
emerge -av -uND @world
当然,它们只能使用其一。
使用nvidia-drivers
在/etc/modprobe.d/nouveau-blacklist.conf
中修改。
blacklist nouveau
options nouveau modeset=0
修改/etc/X11/xorg.conf.d/10-monitor.conf
Section "ServerLayout"
Identifier "Layout"
Screen 0 "ScreenNVidia"
Inactive "intel"
EndSection
Section "Files"
EndSection
Section "Module"
EndSection
Section "Monitor"
Identifier "Monitor"
EndSection
Section "Device"
Identifier "intel"
Driver "modesetting"
EndSection
Section "Device"
Identifier "nvidia"
Driver "nvidia"
# Driver "nouveau"
BusID "01:00:0"
Option "RegistryDword" "EnbleBrightnessControl=1"
EndSection
Section "Screen"
Identifier "ScreenIntel"
Device "intel"
Monitor "Monitor"
EndSection
Section "Screen"
Identifier "ScreenNVidia"
Device "nvidia"
Option "AllowEmptyInitialConfiguration"
EndSection
同时,需要指定Xorg
输入源为Nvidia
,添加配置到~/.xinitrc
。
xrandr --setprovideroutputsource modesetting NVIDIA-0
xrandr --auto
nvidia
驱动提供了图形和控制台控制接口nvidia-setting
和nvidia-smi
。
使用nouveau
注释掉nouveau-blacklist.conf
、xorg.conf.d/10-monitor.conf
和~/.xinitrc
的内容即可。
注意注释掉/etc/X11/xinit/xinitrc.d/95-nvidia-setting
。
Desktop Environments
这里放弃了集成的桌面环境。之前用的Xfce和KDE都是很不错的桌面。
Windows Manager
Awesome
支持平铺、堆叠多种模式。使用lua脚本作为配置文件。 总的来说比较易用。
写入~/.xinitrc
作为默认桌面
exec ck-launch-session dbus-launch --sh-syntax --exit-with-session awesome
# 这里启动了consolekit支持
i3
平铺WM中的优秀者。配置简单,加载速度和插件都很不错。
sway
Wayland体系下的i3继承者。支持i3配置,尚在开发中。
Display Manager
SLIM
超简洁的显示管理。不过现在喜欢用startx
Input Drivers
profile/make.defaults
portage同样使用环境变量控制输入驱动。
同样需要开启内核驱动。
libinput list-devices
xinput list # 列出了所有输入设备
Keyboard
xmodmap # 按键映射配置
Mouse
xset mouse # 动态修改鼠标配置
Touchpad
INPUT_DEVICES="synaptics" # 推荐使用libinput
需要注意的是Elantech touchpad需要内核驱动开启支持。
Xorg.conf
修改默认配置。
Section "InputClass"
Identifier "touchpad"
Driver "synaptics"
MatchIsTouchpad "on"
Option "TapButton1" "1"
Option "TapButton2" "3"
Option "TapButton3" "2"
Option "VertEdgeScroll" "on"
Option "HorizEdgeScroll" "on"
EndSection
synclient -l # 实现动态配置
Sound
同样需要内核驱动。
ALSA (Advanced Linux Sound Architecture)
内核声音驱动使用ALSA
,这个系统繁杂低效,难以称上优秀。
aplay -L # 查看音频接口
修改默认输出接口~/.asoundrc
defaults.pcm.!card PCH
defaults.pcm.!device 0
或通过/sys/class/sourd/
内核接口控制声音驱动。
alsamixer
控制音量。
speaker-test
测试音频输出。
arecode
测试音频输入。
PulesAudio
在ALSA
的基础上,PulesAudio丰富了声音管理的功能,统一了应用层接口。
同样依赖dbus。
rc-update add dbus default
pactl set-sink-* # 控制音频输出
Freedesktop
常用的桌面工具和libhttps://www.freedesktop.org/wiki/Software/
常用的有
xdg-utils # 菜单、图标默认应用管理
xev # X事件监控
CJK Input
这里使用了fcitx作为输入框架。需要在.xinitrc
中加载环境变量启动
export XMODIFIERS="@im=fcitx"
export QT_IM_MODULE="fcitx"
export GTK_IM_MODULE="fcitx"
fcitx -d
同时需要dbus
支持。
rc-update add dbus default
Display Optimization
HiDPI
修正显示DPI设置,在高分屏上还是很有用的。
xdpyinfo # 查看当前显示设置
xrandr --dpi <dpi value> # 设置动态dpi值
持久化配置需要修改~/.Xresources
。
Xft.dpi: 180
Xft.autohint: 0
Xft.lcdfilter: lcddefault
Xft.hintstyle: hintfull
Xft.hinting: 1
Xft.antialias: 1
Xft.rgba: rgb
Fonts
对于 Gentoo 系统而言,eselete 提供了字体的选择功能。
也可用fontconfig
工具包进行配置。
fc-list #
## Media
---
### Mplayer
* -identify # 等同与-msglevel identitfy=4