433 lines
12 KiB
Markdown
433 lines
12 KiB
Markdown
---
|
||
layout: post
|
||
title: "Manjaro 初始配置"
|
||
subtitle: ""
|
||
description: "这是一篇关于 Manjaro 的初始配置指导,包括镜像源和中文输入法的配置等。"
|
||
excerpt: "本文描述了在安装 Manjaro 后需要进行的基本配置,并指导安装一些常用软件。"
|
||
date: 2020-01-15 16:42:00
|
||
author: "Rick Chan"
|
||
tags: ["System", "Manjaro"]
|
||
categories: ["Software"]
|
||
published: true
|
||
---
|
||
|
||
## 1.使用国内软件源
|
||
|
||
*注:该操作会修改 /etc/pacman.d/mirrorlist 文件,使用前请先备份。*
|
||
|
||
生成可用中国镜像站列表:
|
||
|
||
```bash
|
||
pacman-mirrors -i -c China -m rank
|
||
```
|
||
|
||
勾选任意软件源,如 <http://mirrors.ustc.edu.cn/manjaro/> ,然后按 OK 键两次。最后刷新缓存:
|
||
|
||
```bash
|
||
pacman -Syy
|
||
```
|
||
|
||
## 2.使用 AUR 镜像
|
||
|
||
修改 /etc/yaourtrc,去掉 # AURURL 的注释,修改为
|
||
|
||
```ini
|
||
AURURL="https://aur.tuna.tsinghua.edu.cn"
|
||
```
|
||
|
||
## 3.升级软件包
|
||
|
||
```bash
|
||
pacman -Syu
|
||
```
|
||
|
||
## 4.安装固件
|
||
|
||
```bash
|
||
pacman -S linux-firmware
|
||
```
|
||
|
||
## 5.安装和配置网络
|
||
|
||
### 5.1.Wifi
|
||
|
||
#### 5.1.1.Intel
|
||
|
||
iwlwifi 是 Intel 无线芯片的驱动集合,如:5100AGN、5300AGN 和 5350AGN 等。对应的 firmware 包含在 linux-firmware 包中。而 linux-firmware-iwlwifi-gitAUR 包含了一些最近的更新。
|
||
|
||
If you have problems connecting to networks in general or your link quality is very poor, try to disable 802.11n, and perhaps also enable software encryption:
|
||
|
||
```bash
|
||
# /etc/modprobe.d/iwlwifi.conf
|
||
options iwlwifi 11n_disable=1 swcrypto=1
|
||
```
|
||
|
||
If you have a problem with slow uplink speed in 802.11n mode, for example 20Mbps, try to enable antenna aggregation:
|
||
|
||
```bash
|
||
# /etc/modprobe.d/iwlwifi.conf
|
||
options iwlwifi 11n_disable=8
|
||
```
|
||
|
||
Do not be confused with the option name, when the value is set to 8 it does not disable anything but re-enables transmission antenna aggregation.[10] [11]
|
||
|
||
In case this does not work for you, you may try disabling power saving for your wireless adapter.
|
||
|
||
Some have never gotten this to work. Others found salvation by disabling N in their router settings after trying everything. This is known to have be the only solution on more than one occasion. The second link there mentions a 5ghz option that might be worth exploring.
|
||
|
||
If you have an 802.11ax (WiFi 6) access point and have problems detecting the beacons or an unreliable connection, review Intel Article 54799.
|
||
|
||
**Note: Using 11n_disable=0 will also prevent 802.11ac and only allow connection with slower protocols (802.11a in the 5GHz band or 802.11b/g in the 2.4 GHz band).**
|
||
|
||
### 5.2.网络工具和配置
|
||
|
||
首先要安装网络工具:
|
||
|
||
```bash
|
||
pacman -S net-tools
|
||
pacman -S networkmanager
|
||
```
|
||
|
||
之后可以通过:
|
||
|
||
```bash
|
||
ifconfig <ethX> up
|
||
```
|
||
|
||
开启网络,通过:
|
||
|
||
```bash
|
||
systemctl start NetworkManager
|
||
```
|
||
|
||
开启网络服务。之后才能正确获取 ip 地址。
|
||
|
||
## 6.安装和配置声音
|
||
|
||
首先要安装:
|
||
|
||
```bash
|
||
pacman -S alsa-utils alsa-plugins
|
||
pacman -S extra/alsa-firmware
|
||
```
|
||
|
||
之后使用 amixer 或 alsamixer 进行配置:
|
||
|
||
```bash
|
||
amixer sset Master unmute
|
||
amixer sset Speaker unmute
|
||
amixer sset Headphone unmute
|
||
alsamixer
|
||
```
|
||
|
||
最后使用:
|
||
|
||
```bash
|
||
speaker-test -c 2
|
||
```
|
||
|
||
对 2 通道声音进行测试。
|
||
|
||
## 7.安装和配置显卡
|
||
|
||
```bash
|
||
pacman -S intel-media-driver
|
||
```
|
||
|
||
具体可参考:<https://wiki.archlinux.org/index.php/Hardware_video_acceleration>
|
||
|
||
## 8.Locale 与中文环境
|
||
|
||
编辑 /etc/locale.gen 为(取消对应项前的注释符号「#」即可):
|
||
|
||
```ini
|
||
en_US.UTF-8 UTF-8
|
||
zh_CN.UTF-8 UTF-8
|
||
```
|
||
|
||
和 /etc/locale.conf 为:
|
||
|
||
```ini
|
||
LANG="en_US.UTF-8"
|
||
# 或
|
||
# LANG="zh_CN.UTF-8"
|
||
```
|
||
|
||
* 建议在 /etc/locale.conf 中保留 LANG="en_US.UTF-8",然后在 ~/.bashrc、~/.xinitrc 或 ~/.xprofile 等启动脚本中设置 LANG="zh_CN.UTF-8"。
|
||
|
||
最后:
|
||
|
||
```bash
|
||
locale-gen
|
||
```
|
||
|
||
可以在系统中使用这些 locale。可以通过 locale 命令来查看当前使用的 locale:
|
||
|
||
```bash
|
||
$ locale
|
||
LANG="zh_CN.UTF-8"
|
||
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=
|
||
```
|
||
|
||
亦可通过 locale -a 命令来查看目前可以使用的 locale。
|
||
|
||
注意:
|
||
|
||
1. LC_ALL:这个变量的值会覆盖掉 LANG 和所有 LC_* 变量的值,无论它们是否设置,不推荐全局 export LC_ALL 覆盖所有 locale 设置,LC_ALL 应该保留用于诊断调试用途,全局设置 LC_ALL 会为诊断语言设置问题带来不必要的困难;
|
||
2. LANG:默认的 Locale 这个变量的值会覆盖掉所有未设置的 LC_* 变量的值;
|
||
3. LANGUAGE:后备 Locale,使用 gettext 翻译的软件会按照 LANGUAGE 选择使用的语言;
|
||
4. LC_TIME:时间和日期格式,如果 LC_TIME 设置成 "en_US.UTF-8",日期的格式为 "MM/DD/YYYY"。要使用 ISO 8601 标准的日期格式( "YYYY-MM-DD" ),使用:LC_TIME=en_DK.UTF-8;
|
||
5. LC_COLLATE:排序格式,这个变量的值决定排序和正则表达式的格式顺序。例如将它设置为 C 可以让 ls 命令按顺序列出 dotfile,大写字母开头的文件和小写字母开头的文件;
|
||
6. 如果进行了以上修改,shell 仍然没有显示中文,.且 LC_ALL=C,则需检查 ~.bash_profile,~/.bashrc 等启动脚本中是否有“export LC_ALL=C”。
|
||
|
||
## 9.安装中文字体
|
||
|
||
```bash
|
||
pacman -S ttf-dejavu ttf-fireflysung opendesktop-fonts wqy-microhei wqy-microhei-lite wqy-zenhei wqy-bitmapfont
|
||
yaourt -S ttf-ms-win8-zh_cn ttf-ms-win10-zh_cn
|
||
```
|
||
|
||
## 10.切换主目录为英文
|
||
|
||
中文系统默认主目录下文件夹名为中文,在 shell 下访问太过费事,最好改为英文。方法是修改 ~/.config/user-dirs.dirs 文件内容如下,之后将各目录修改为对应的英文名,然后重新登陆该账户即可:
|
||
|
||
```ini
|
||
XDG_DESKTOP_DIR="$HOME/Desktop"
|
||
XDG_DOWNLOAD_DIR="$HOME/Downloads"
|
||
XDG_TEMPLATES_DIR="$HOME/Templates"
|
||
XDG_PUBLICSHARE_DIR="$HOME/Public"
|
||
XDG_DOCUMENTS_DIR="$HOME/Documents"
|
||
XDG_MUSIC_DIR="$HOME/Music"
|
||
XDG_PICTURES_DIR="$HOME/Pictures"
|
||
XDG_VIDEOS_DIR="$HOME/Videos"
|
||
```
|
||
|
||
之后:
|
||
|
||
```bash
|
||
gsettings set org.blueman.transfer shared-path '/home/<user name>/Downloads'
|
||
```
|
||
|
||
或通过:
|
||
|
||
```bash
|
||
blueman-services
|
||
```
|
||
|
||
重新配置,否则重启会提示:
|
||
|
||
```bash
|
||
Configured directory for incoming files does not exist
|
||
```
|
||
|
||
## 11.安装常用工具
|
||
|
||
```bash
|
||
pacman -S base-devel git gcc make cmake gdb python2 python3 go arm-none-eabi-gcc arm-none-eabi-gdb arm-none-eabi-newlib tmux openssh samba ntfs-3g vim bzip2 coreutils ncurses xz unrar unzip zip aria2 tree
|
||
```
|
||
|
||
另外需要安装 flex、bison、libncurses5-dev 等。
|
||
|
||
### 11.1.安装防火墙
|
||
|
||
```bash
|
||
pacman -S firewalld
|
||
```
|
||
|
||
### 11.2.安装 OpenCV
|
||
|
||
```bash
|
||
pacman -Ss opencv vtk glew hdf5
|
||
```
|
||
|
||
## 12.安装 Gnome
|
||
|
||
使用下列命令安装 Gnome 并安装 Gnome 配置工具(gnome-tweaks):
|
||
|
||
```bash
|
||
pacman -S gnome gnome-extra gnome-tweaks chrome-gnome-shell gnome-shell-extensions
|
||
# 支持半透明效果的 gnome-terminal
|
||
yaourt -S gnome-terminal-transparency
|
||
```
|
||
|
||
使用下列命令安装 Flatix 和 Papirus 主题:
|
||
|
||
```bash
|
||
pacman -S flatix-theme flatix-theme-dark papirus-icon-theme papirus-maia-icon-theme breeze-gtk breeze-icons papirus-maia-icon-theme matcha-gtk-theme
|
||
yaourt -S flat-remix-gnome flat-remix flat-remix-gtk
|
||
```
|
||
|
||
之后可在 gnome-tweaks 中更换主题。
|
||
|
||
访问 <https://extensions.gnome.org> 搜索 AlternateTab 扩展,在网页上安装浏览器插件后可在扩展的首页右上角看到开关按钮,点击打开就会自动安装,之后在 gnome-tweaks 可以找到该扩展,使能该扩展实现“仅在当前工作区中切换窗口”的功能。
|
||
|
||
## 13.VMTools
|
||
|
||
如果 Manjaro 作为 VirtualBox 的 Guest 来运行,则需要安装 VMTools,命令如下:
|
||
|
||
```bash
|
||
pacman -S virtualbox-guest-utils
|
||
```
|
||
|
||
一定不要使用 VM 的菜单来安装工具。
|
||
|
||
## 14.提升权限
|
||
|
||
普通用户可能无法访问某些设备,需要提升权限:
|
||
|
||
```bash
|
||
# 通过下列命令获得设备节点所在的组.
|
||
ls -l /dev |grep <device node>
|
||
# 以下命令中的 group name 为上述 ls 得到设备节点所在组名.
|
||
gpasswd --add <user name> <group name>
|
||
# 通过以下命令确认是否已将用户添加到该组.
|
||
groups <user name>
|
||
```
|
||
|
||
## 15.配置 Bash
|
||
|
||
在 ~/.bash_profile 中增加
|
||
|
||
```ini
|
||
alias ls='ls --color=auto'
|
||
alias dir='dir --color=auto'
|
||
alias vidr='vdir --color=auto'
|
||
alias grep='grep --color=auto'
|
||
alias fgrep='fgrep --color=auto'
|
||
alias egrep='egrep --color=auto'
|
||
# some more ls aliases
|
||
alias ll='ls -alF'
|
||
alias la='ls -A'
|
||
alias l='ls -CF'
|
||
```
|
||
|
||
## 16.安装应用
|
||
|
||
### 16.1.安装输入法
|
||
|
||
#### 16.1.1.安装 fcitx 输入法
|
||
|
||
输入以下命令安装 fcitx-im 默认安装全部软件,并安装 google 拼音输入法:
|
||
|
||
```bash
|
||
pacman -S fcitx-im fcitx-configtool fcitx-googlepinyin
|
||
```
|
||
|
||
默认会自动运行 fictx 程序,如果该程序没有自动启动,则运行下列命令:
|
||
|
||
```bash
|
||
cp /etc/xdg/autostart/fcitx-autostart.desktop ~/.config/autostart/
|
||
```
|
||
|
||
添加如下代码到 ~/.xprofile,如果该文件不存在则创建一份。
|
||
|
||
```ini
|
||
export GTK_IM_MODULE=fcitx
|
||
export QT_IM_MODULE=fcitx
|
||
export XMODIFIERS=@im=fcitx
|
||
```
|
||
|
||
之后运行 fictx 诊断程序,如果诊断错误则按提示进行修正,如果诊断没有发现问题则重启即可。
|
||
|
||
```bash
|
||
fcitx-diagnose
|
||
```
|
||
|
||
通过 fcitx-configtool 添加输入法。通过 ctrl+space 来切换输入法。
|
||
|
||
#### 16.1.2.安装 IBus 输入法
|
||
|
||
输入以下命令安装 ibus。
|
||
|
||
```bash
|
||
pacman -S ibus ibus-libpinyin
|
||
yaourt ibus-qt
|
||
```
|
||
|
||
添加如下代码到 ~/.xprofile,如果该文件不存在则创建一份。
|
||
|
||
```ini
|
||
export GTK_IM_MODULE=ibus
|
||
export QT_IM_MODULE=ibus
|
||
export XMODIFIERS=@im=ibus
|
||
```
|
||
|
||
如果是 Gnome 桌面,进入 Gnome 设置,选择区域和语言,将输入源配置为“汉语(Intelligent Pinyin)”,并提升为第一个(这个输入法与 Gnome 兼容最好)。点击 Intelligent Pinyin 的设置:
|
||
|
||
1. 将“General“中”语言初始状态“设置为”英文“,Horizontal 显示,使能 Dynmic adjust the candidates order、Remember erery input as a phrase、Show suggestions,选择 Short candidates by Frequency;
|
||
2. 在“Pinyin mode”中选择”[,][.]flip page“
|
||
3. 在 Dictionary 中选中所有;
|
||
4. 将”Shortcuts“中“切换中文/英文模式”快捷键设置为“Shift”。
|
||
|
||
在桌面任务栏输入法图标上单击右键,选择“汉语(Intelligent Pinyin)”,再次单击该图标,选择“Preferences”,然后按同样方式进行设置。
|
||
|
||
*注:如果有多个输入法,可以使用 im-config 工具进行切换。*
|
||
|
||
### 16.2.安装 Qt
|
||
|
||
```bash
|
||
pacman -S qtcreator qt5-base qt5-doc
|
||
# QT 程序使用 gtk 主题,否则非常丑.
|
||
echo "export QT_QPA_PLATFORMTHEME=gtk2" >> ~/.profile
|
||
```
|
||
|
||
### 16.3.音乐播放
|
||
|
||
```bash
|
||
pacman -S rhythmbox
|
||
```
|
||
|
||
### 16.4.安装 WPS Office
|
||
|
||
```bash
|
||
yaourt -S wps-office-cn
|
||
```
|
||
|
||
如果校验失败,则到“/tmp/yaourt-tmp-\<user name\>/aur-wps-office-cn/“目录下对 deb 包重新校验:
|
||
|
||
```bash
|
||
sha1sum <wps-office>.deb
|
||
```
|
||
|
||
然后重新安装 wps-office-cn 并修改 PKGBUILD 文件中的 sha1sums 值为以上实际得到的校验值。
|
||
|
||
```bash
|
||
==> 编辑 PKGBUILD ? [Y/n] ("A" 忽略)
|
||
==> ----------------------------
|
||
==> Y
|
||
```
|
||
|
||
保存 PKGBUILD 退出并继续安装。
|
||
|
||
安装 Symbol fonts 否则启动 WPS 时会有警告提示:
|
||
|
||
```bash
|
||
yaourt -S ttf-wps-fonts
|
||
```
|
||
|
||
可选择安装以下字体:
|
||
|
||
```bash
|
||
yaourt -S wps-office-fonts
|
||
```
|
||
|
||
### 16.5.安装 Ocenaudio
|
||
|
||
Ocenaudio 是一款 Linux 下的音频编辑软件,提供音频转码、滤波等功能,安装方法如下:
|
||
|
||
```bash
|
||
yaourt -S ocenaudio
|
||
```
|