It's time to talk about my writerdeck
It’s time to talk about my writerdeck
是时候聊聊我的“写作甲板”(writerdeck)了
I have an attention problem. A couple of weeks ago, I decided to convert my old laptop into a writerdeck, a dedicated writing device free from the distractions of the modern internet. 我有注意力涣散的问题。几周前,我决定将我的旧笔记本电脑改造成一台“写作甲板”(writerdeck)——一个专门用于写作、不受现代互联网干扰的设备。
Lots of folks build really elaborate offline devices for this, and I’d love to do that… someday. Right now I have no shortage of projects and the point is to get writing, so I used what I had: a six-year-old laptop which still runs great, has plenty of power, but isn’t getting much use anymore. 很多人会为此打造非常精巧的离线设备,我也很想那样做……但那是以后。目前我手头项目很多,重点是开始写作,所以我利用了现有的东西:一台六年前的笔记本电脑。它运行良好,性能充足,只是现在已经很少使用了。
Crucially, this laptop has an excellent keyboard, and a matte screen, which makes it awesome to type on for long stretches, and functional enough in the daylight (I like to sit outside with my dog and write). It’s also a System76 Galago Pro (not sponsored), which means it’s already Linux friendly and has great support in the kernel. 关键在于,这台笔记本电脑有着出色的键盘和雾面屏,这让它非常适合长时间打字,而且在日光下也足够清晰(我喜欢带着狗坐在户外写作)。它还是一台 System76 Galago Pro(非赞助),这意味着它对 Linux 非常友好,内核支持也很棒。
Setting up a tty instead of a desktop
设置 tty 而非桌面环境
Now, you could certainly just use a regular desktop OS and keep it offline, although that’s easier said than done. I don’t think you can fully remove the browsers from a modern Mac or Windows PC. At least not in a supported way. 当然,你完全可以使用普通的桌面操作系统并保持离线状态,但这说起来容易做起来难。我不认为你能从现代 Mac 或 Windows PC 中彻底移除浏览器,至少在官方支持的方式下是做不到的。
Of course, I’m a Linux user, and I have any number of options. I could have gone with a simple desktop or window manager and just not installed a browser, but I wanted something that really broke the desktop OS muscle memory and forced me into thinking about my words with intention. 当然,我是一名 Linux 用户,我有无数种选择。我本可以选择一个简单的桌面环境或窗口管理器,然后不安装浏览器,但我想要的是一种能真正打破桌面操作系统肌肉记忆的东西,强迫我带着意图去思考每一个字。
I opted for a tty-based setup, using Debian (Trixie at the time of writing). Console only—no x11 or Wayland, no desktop getting in my way. 我选择了基于 tty 的设置,使用 Debian(撰写本文时为 Trixie 版本)。仅限控制台——没有 X11 或 Wayland,没有桌面环境来干扰我。
Installing Debian is easy enough. I use the text-based installer mode, and for this writerdeck, I opted to skip full-disk encryption (there’s nothing on this device that isn’t going to be public anyway). 安装 Debian 非常简单。我使用了基于文本的安装模式,对于这台写作设备,我选择跳过全盘加密(反正这台设备上没有任何东西是需要保密的)。
Folks always tell me they get hung up on things because they don’t set themselves up with sudo on Debian. If you’re coming from Mint or Ubuntu or virtually any other desktop-oriented distro, this could trip you up. If you want to use sudo for admin tasks, skip adding a root password. That’ll disable root and set you up as a sudo user. 人们总是告诉我,他们在 Debian 上因为没有设置 sudo 而遇到麻烦。如果你是从 Mint、Ubuntu 或几乎任何其他面向桌面的发行版转过来的,这可能会让你困惑。如果你想使用 sudo 进行管理任务,请跳过 root 密码的设置。这会禁用 root 账户并将你设置为 sudo 用户。
Leave this blank if you want to use a sudo user! A lot of folks don’t know about this quirk and get into trouble if they’re coming from other distros. 如果你想使用 sudo 用户,请将此项留空!很多人不知道这个特性,如果他们是从其他发行版转过来的,往往会因此遇到麻烦。
On the desktop setup screen, I chose to remove all desktop features, because again, I want this thing to be a minimal device. Just me and the words, no GUI getting in my way. 在桌面设置界面,我选择移除所有桌面功能,因为我还是那句话,我希望这台设备尽可能极简。只有我和文字,没有图形界面来干扰我。
I removed the selection for “Debian desktop environment” and “GNOME” here. This way it’s just a tty. 我取消了“Debian 桌面环境”和“GNOME”的勾选。这样它就只是一个 tty 了。
When things wrap up, you’ll be greeted with a bland console login. Perfect place to get started. It’s boring. Perfect. 安装完成后,迎接你的是一个朴素的控制台登录界面。这是开始工作的绝佳起点。它很枯燥。完美。
Installing network-manager
安装 network-manager
After signing in for the first time and making sure I was up-to-date with a quick sudo apt update and a sudo apt upgrade, I chose to replace the regular network stack with the network-manager package. Mainly to get access to the very good curses tool nm-tui for connecting to networks.
首次登录并确保系统通过 sudo apt update 和 sudo apt upgrade 更新到最新后,我选择用 network-manager 软件包替换常规的网络栈。主要是为了使用非常好用的 curses 工具 nm-tui 来连接网络。
nm-tui is a thousand times easier than editing config files for setting up network devices. And while I will be working mostly offline with this device when I’m away from home, I do appreciate the ability to connect it to the network to back up files should the need arise.
相比编辑配置文件来设置网络设备,nm-tui 要方便一千倍。虽然我离家时大部分时间都会离线使用这台设备,但我确实很看重在需要时连接网络备份文件的能力。
After installing network-manager with sudo apt install network-manager, you can use nm-tui to scan for available Wi-Fi networks and get hooked up. Depending on your hardware, you might also have WAN access here. Pretty cool.
安装 network-manager 后,你可以使用 nm-tui 扫描可用的 Wi-Fi 网络并进行连接。根据你的硬件情况,你甚至可能在这里获得 WAN 访问权限。非常酷。
Having a TUI for networking is a nice quality-of-life improvement. 拥有一个用于网络的 TUI(文本用户界面)是一个不错的体验提升。
Installing neovim and kmscon
安装 neovim 和 kmscon
I couldn’t wait any longer, I installed neovim as soon as I could with sudo apt install neovim. I didn’t want to edit with nano. Nothing personal, I’m just a vim user all the way now.
我迫不及待地通过 sudo apt install neovim 安装了 neovim。我不想用 nano 编辑器。没什么特别的原因,我只是现在彻底成了 vim 用户。
Normally I use traditional vim but I opted for neovim as I’m trying to get to know it a bit more. 通常我使用传统的 vim,但我选择了 neovim,因为我想多了解它一点。
Then, I installed kmscon, which for Debian Trixie needed to be added from backports.
接着,我安装了 kmscon,对于 Debian Trixie,需要从 backports 源中添加。
First, I updated my Debian source list by editing the file at /etc/apt/sources.list to add the following two lines:
首先,我通过编辑 /etc/apt/sources.list 文件更新了 Debian 源列表,添加了以下两行:
deb http://deb.debian.org/debian/ trixie-backports main contrib non-free non-free-firmware
deb-src http://deb.debian.org/debian/ trixie-backports main contrib non-free non-free-firmware
A quick sudo apt update and then I can simply run sudo apt install -t trixie-backports kmscon. This will install the kmscon package from backports, as well as its dependencies, and set it to automatically start on boot. Next reboot, you’ll see the familiar tty, but now it’s scalable with ctrl-plus and ctrl-minus, like most modern web browsers.
执行一次 sudo apt update,然后我就可以直接运行 sudo apt install -t trixie-backports kmscon。这将从 backports 安装 kmscon 软件包及其依赖项,并将其设置为开机自启。下次重启时,你依然会看到熟悉的 tty,但现在它可以通过 ctrl-plus 和 ctrl-minus 进行缩放,就像大多数现代网页浏览器一样。
From here, I have a totally functional writerdeck. I could be done here and be reasonably satisfied with an offline, pleasant writing experience. But I wanted a few more niceties which I’ve grown accustomed to. 至此,我已经拥有了一台功能完备的写作设备。我完全可以在这里收工,并对这种离线、舒适的写作体验感到满意。但我还想要一些我已经习惯了的小功能。
tmux for multiplexing and a pretty status bar
使用 tmux 进行多路复用和美化状态栏
Next, I installed tmux for basic terminal tiling and a pretty status bar. This is packaged for Debian (and virtually everyone else), and is installed with sudo apt install tmux.
接下来,我安装了 tmux 来实现基础的终端分屏和美观的状态栏。它在 Debian(以及几乎所有其他发行版)中都有打包,通过 sudo apt install tmux 即可安装。
I also installed acpi for battery details, and light to control the screen backlight. You can install these at the same time with sudo apt install acpi light. I set these up in my .tmux.conf file, which is kept in your home directory. Here’s how I used them.
我还安装了 acpi 来获取电池详情,以及 light 来控制屏幕背光。你可以通过 sudo apt install acpi light 同时安装它们。我在主目录下的 .tmux.conf 文件中进行了配置。以下是我的使用方法。
ACPI for battery readouts
使用 ACPI 读取电池信息
Once the acpi package is installed, you should be able to see your battery with acpi -b (assuming your laptop has a battery which is detected with acpi, which has worked so far on every laptop I’ve tried in my house).
安装 acpi 软件包后,你应该可以通过 acpi -b 查看电池状态(前提是你的笔记本电脑有电池且能被 acpi 检测到,目前我家里试过的每一台笔记本电脑都能正常工作)。
So, to get the specific percentage and nothing more, you can pipe acpi -b into grep like so:
因此,为了只获取具体的百分比数值,你可以通过管道将 acpi -b 的输出传给 grep,如下所示:
acpi -b | grep -m1 -o -P '.{0,2}%'
This grep is a bit hard to understand, so let’s break it down:
这个 grep 命令有点难懂,让我们拆解一下:
-m1says stop reading the file after one line. I did this because some laptops I’ve used have multiple batteries, and I only care about the primary battery. You can probably leave this out ifacpi -bonly returns a single line.-m1表示读取一行后停止。我这样做是因为我用过的一些笔记本电脑有多个电池,而我只关心主电池。如果acpi -b只返回一行,你可以省略这个参数。-oprints only the matched parts of the line. I don’t want a large printout with the remaining time. You might!-o只打印匹配到的部分。我不想要包含剩余时间的冗长输出。你可能想要!-Pinterprets the pattern as a Perl-compatible regex.-P将模式解释为 Perl 兼容的正则表达式。