i3 窗口管理器入门
i3 GNOME 窗口管理器

> 
> 本篇文章会介绍如何在 Fedora 系统中，安装、配置、使用 i3 瓦片式桌面管理器。
> 
> 
> 


![](/data/attachment/album/201809/17/172829oj2v3k3qjqx5czuv.png)


在我的文章 [i3 桌面让 Linux 更好的 5 个理由](https://opensource.com/article/18/8/i3-tiling-window-manager)，我分享了选择 [i3 桌面管理器](https://i3wm.org) 作为一种 Linux 桌面替代方案的最主要五个理由。


在本篇文章中，我将向大家展示，如何在 Fedora 28 上安装与简单配置 i3。


### 1、 安装


首先进入 Fedora 系统中，打开一个终端。使用 `dnf` 来安装需要的软件包，如下：



```
[ricardo@f28i3 ~]$ sudo dnf install -y i3 i3-ipc i3status i3lock dmenu terminator --exclude=rxvt-unicode
Last metadata expiration check: 1:36:15 ago on Wed 08 Aug 2018 12:04:31 PM EDT.
Dependencies resolved.
================================================================================================
 Package                     Arch         Version                           Repository     Size
================================================================================================
Installing:
 dmenu                       x86_64       4.8-1.fc28                        fedora         33 k
 i3                          x86_64       4.15-1.fc28                       fedora        323 k
 i3-ipc                      noarch       0.1.4-12.fc28                     fedora         14 k
 i3lock                      x86_64       2.9.1-2.fc28                      fedora         33 k
 i3status                    x86_64       2.12-1.fc28                       updates        62 k
 terminator                  noarch       1.91-4.fc28                       fedora        570 k
Installing dependencies:
 dzen2                       x86_64       0.8.5-21.20100104svn.fc28         fedora         60 k

... Skipping dependencies/install messages

Complete!
[ricardo@f28i3 ~]$
```

注意：在这个命令中，我排除了 `rxvt-unicode` 这个包，因为我更喜欢 `terminator` 作为我的终端模拟器。


据用户目前的系统状态，在命令执行过程中可能会安装很多依赖。等待所有的依赖安装完成，之后重启你的电脑。


### 2、 首次登录与初始化


在你的机器重启之后，你便可以第一次体验 i3 了。在 GNOME 显示管理器（GDM）屏幕，选择你的用户名，之后先别着急输密码，点击下方的密码输入框下方的小齿轮，之后选择 i3 而不是 GNOME，像下方这样：


![](/data/attachment/album/201809/17/172830wvnzm44jgm2k4dmd.png)


输入你的密码，并点击 “Sign In”。在你第一次登入之后，会先看到 i3 的配置界面：


![](/data/attachment/album/201809/17/172830r4mmeuhue9306gxp.png)


点击回车键就会在 `$HOME/.config/i3` 生成一个配置文件，之后你可以通过这个配置文件来定制化 i3 的一些行为。


在下一屏，你需要选择你的 `Mod` 键。这一步很关键，因为 `Mod` 键通常都会作为 i3 命令快捷键的发起键。按回车会选择 `Win` 键作为默认的 `Mod` 键。如果你的键盘没有 `Win` 键，用 `Alt` 键做替代，用方向键键选择后按回车键确认。


![](/data/attachment/album/201809/17/172831fse22srnxlj2slnl.png)


现在你就登录到了 i3 的系统中。由于 i3 是一个极简的窗口管理器，你会看到一个黑屏窗口，以及屏幕底端显示的状态栏：


![](/data/attachment/album/201809/17/172831vs0q4jlplbhj2szh.png)


接下来，让我们看看 i3 的如何实际使用。


### 3、 基本的快捷键


现在你已经登录到了 i3 会话中，你需要几个基本的快捷键来应对基本的操作。


大多数的 i3 快捷键都会用到之前配置的 `Mod` 键。在下面的例子中，当我提到 `Mod` 键，请根据情况使用你定义的做替换。通常使用 `Win` 键或者 `Alt` 键。


首先，要打开一个终端，可以使用 `Mod+ENTER`。重复打开几个终端，观察 i3 是如何自动将它们在桌面中排列。默认情况下， i3 会在水平的方向分割屏幕；使用 `Mod + v` 来垂直分割，再按 `Mod + h` 会恢复水平分割模式。


![](/data/attachment/album/201809/17/172832x0835at51paxyhaf.png)


当需要启动其他的应用，按 `Mod + d` 来打开 `dmenu`，一个简单的文字应用菜单。默认情况下，`dmenu` 会呈现出所有在你 `$PATH` 中设置的应用。使用方向键来选择你想启动的应用，同时你可以键入应用的名称，来缩小选择的范围，之后按回车键来启动选择的应用。


![](/data/attachment/album/201809/17/172832bzg63610gszxgdz0.png)


如果你的应用没有提供退出的方法，你可以使用 i3 来关闭对应的窗口，通过按 `Mod + Shift +q`。注意，你可能会丢失未保存的工作内容。


最后，当你想关闭会话并退出 i3，按 `Mod + Shift +e`。之后会在窗口的上方提示你是否退出。点击 “Yes, exit i3” 退出，或选择 “X” 来取消。


![](/data/attachment/album/201809/17/172832q7t3979wnt95btj7.png)


这些就是 i3 中最基本的快捷键，如果想了解更多，请查阅官方[文档](https://i3wm.org/docs/userguide.html#_default_keybindings)。


### 4、 替换 GDM


使用 i3 窗口管理器会降低你操作系统的内存占用；然而，Fedora 依然会使用 GDM 作为登录屏。GDM 会载入几个与 GNOME 相关的库从而占用内存。


如果你想进一步的降低你的内存占用，你可以使用一些更轻量级的显示管理器来替换 GDM，比如 lightdm ：



```
[ricardo@f28i3 ~]$ sudo dnf install -y lightdm
[ricardo@f28i3 ~]$ sudo systemctl disable gdm
Removed /etc/systemd/system/display-manager.service.
[ricardo@f28i3 ~]$ sudo systemctl enable lightdm
Created symlink /etc/systemd/system/display-manager.service -> /usr/lib/systemd/system/lightdm.service.
[ricardo@f28i3 ~]$
```

之后重启你的机器来使用 Lightdm 的登录界面。


现在你可以继续登录并使用 i3了。


![](/data/attachment/album/201809/17/172834eflulxtu1v4lass8.png)




---


via: <https://opensource.com/article/18/8/getting-started-i3-window-manager>


作者：[Ricardo Gerardi](https://opensource.com/users/rgerardi) 选题：[lujun9972](https://github.com/lujun9972) 译者：[sd886393](https://github.com/sd886393) 校对：[wxy](https://github.com/wxy)


本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译，[Linux中国](https://linux.cn/) 荣誉推出


OK
In my article [5 reasons the i3 window manager makes Linux better](https://opensource.com/article/18/8/i3-tiling-window-manager), I shared the top five reasons I use and recommend the [i3 window manager](https://i3wm.org) as an alternative Linux desktop experience.

In this post, I will walk through the installation and basic configuration of i3 on Fedora 28 Linux.

## 1. Installation

Log into a Fedora workstation and open up a terminal. Use `dnf`

to install the required package, like this:

```
[ricardo@f28i3 ~]$ sudo dnf install -y i3 i3-ipc i3status i3lock dmenu terminator --exclude=rxvt-unicode
Last metadata expiration check: 1:36:15 ago on Wed 08 Aug 2018 12:04:31 PM EDT.
Dependencies resolved.
================================================================================================
Package Arch Version Repository Size
================================================================================================
Installing:
dmenu x86_64 4.8-1.fc28 fedora 33 k
i3 x86_64 4.15-1.fc28 fedora 323 k
i3-ipc noarch 0.1.4-12.fc28 fedora 14 k
i3lock x86_64 2.9.1-2.fc28 fedora 33 k
i3status x86_64 2.12-1.fc28 updates 62 k
terminator noarch 1.91-4.fc28 fedora 570 k
Installing dependencies:
dzen2 x86_64 0.8.5-21.20100104svn.fc28 fedora 60 k
... Skipping dependencies/install messages
Complete!
[ricardo@f28i3 ~]$
```


**Note:** In this command, I'm explicitly excluding the package `rxvt-unicode`

because I prefer `terminator`

as my terminal emulator.

Depending on the status of your system, it may install many dependencies. Wait for the installation to complete successfully and then reboot your machine.

## 2. First login and initial setup

After your machine restarts, you're ready to log into i3 for the first time. In the GNOME Display Manager (GDM) screen, click on your username but—before typing the password to log in—click on the small gear icon and change the session to i3 instead of GNOME, like this:

![First login to i3 i3 initial login screen](https://opensource.com/sites/default/files/uploads/i3_first_login_small.png)

Type your password and click `Sign In`

. On your first login, you are presented with the i3 configuration screen:

![i3 initial configuration screen i3 initial configuration screen](https://opensource.com/sites/default/files/uploads/i3_first_configuration_small.png)

Press `ENTER`

to generate a config file in your `$HOME/.config/i3`

directory. Later you can use this config file to further customize i3's behavior.

On the next screen, you need to select your `Mod`

key. This is important, as the `Mod`

key is used to trigger most of i3's keyboard shortcuts. Press `ENTER`

to use the default `Win`

key as the `Mod`

key. If you don't have a `Win`

key on your keyboard or prefer to use `Alt`

instead, use the arrow key to select it and press `ENTER`

to confirm.

![Configuring the 'mod' key Configuring the 'mod' key](https://opensource.com/sites/default/files/uploads/i3_generate_config_small.png)

You're now logged into your i3 session. Because i3 is a minimalist window manager, you see a black screen with the status bar on the bottom:

![i3's minimalist start screen i3's minimalist start screen](https://opensource.com/sites/default/files/uploads/i3_start_small.png)

Next, let's look at navigating in i3.

## 3. Basic shortcuts


Now that you're logged into an i3 session, you'll need a few basic keyboard shortcuts to get around.

The majority of i3 shortcuts use the `Mod`

key you defined during the initial configuration. When I refer to `Mod`

in the following examples, press the key you defined. This will usually be the `Win`

key, but it can also be the `Alt`

key.

First, to open up a terminal, use `Mod+ENTER`

. Open more than one terminal and notice how i3 automatically tiles them to occupy all available space. By default, i3 splits the screen horizontally; use `Mod+v`

to split vertically and press `Mod+h`

to go back to the horizontal split.

![i3 screen with three tiled terminals i3 screen with three tiled terminals](https://opensource.com/sites/default/files/uploads/i3_3terminal_tiled_small.png)

To start other applications, press `Mod+d`

to open `dmenu`

, a simple text-based application menu. By default, `dmenu`

presents a list of all applications available on your `$PATH`

. Select the application you want to start by using the arrow keys or narrow down the search by typing parts of the application's name. Press `ENTER`

to start the selected application.

![Launching an application with dmenu in i3 Launching an application with dmenu in i3](https://opensource.com/sites/default/files/uploads/i3_dmenu.png)

If your application does not provide a way to close it, you can use i3 to kill a window by pressing `Mod+Shift+q`

. Be careful, as you may lose unsaved work—this behavior depends on each application.

Finally, to end your session and exit i3, press `Mod+Shift+e`

. You are presented with a confirmation message at the top of your screen. Click on `Yes, exit i3`

to exit or `X`

to cancel.

![Exiting an application in i3 Exiting an application in i3](https://opensource.com/sites/default/files/uploads/i3_exit_small.png)

This is just an initial list of shortcuts you can use to get around i3. For many more, consult i3's official [documentation](https://i3wm.org/docs/userguide.html#_default_keybindings).

## 4. Replacing GDM

Using i3 window manager reduces the memory utilization on your system; however, Fedora still uses the default GDM as its login screen. GDM loads several GNOME-related libraries and applications that consume memory.

If you want to further reduce your system's memory utilization, you can replace GDM with a more lightweight display manager, such as `lightdm`

, like this:

```
[ricardo@f28i3 ~]$ sudo dnf install -y lightdm
[ricardo@f28i3 ~]$ sudo systemctl disable gdm
Removed /etc/systemd/system/display-manager.service.
[ricardo@f28i3 ~]$ sudo systemctl enable lightdm
Created symlink /etc/systemd/system/display-manager.service -> /usr/lib/systemd/system/lightdm.service.
[ricardo@f28i3 ~]$
```


Restart your machine to see the Lightdm login screen.

![The Lightdm login screen The Lightdm login screen](https://opensource.com/sites/default/files/uploads/i3_lightdm_small.png)

Now you're ready to log in and use i3.

## 2 Comments