Emacs 是我的新窗口管理器
Emacs is my new window manager (2015)

原始链接: https://www.howardism.org/Technical/Emacs/new-window-manager.html

为了避免携带多台笔记本电脑用于工作和个人用途,作者在其工作笔记本电脑上使用虚拟机(VM)。该虚拟机基于最小化的Ubuntu Server安装,并针对高效的个人使用进行了定制,令人惊讶的是,*没有*传统的窗口管理器。 相反,Emacs被用作唯一的桌面环境。一个简单的`.xinitrc`文件以全屏模式启动Emacs,利用其窗口管理能力和自定义选项。网页浏览主要在Emacs中使用基于文本的浏览器(如`w3m`)进行,在需要时可以通过`xdg-open`临时启动图形化浏览器。 作者还展示了一种快速启动和组织多个基于Emacs的应用程序(包括社交媒体和新闻源)的设置,并将其定制成一个工作区,可以通过键盘快捷键轻松恢复。这种方法在工作提供的环境中提供了一种轻量级、键盘驱动的个人计算体验。

## Emacs 作为窗口管理器:总结 最近的 Hacker News 讨论强调了将 Emacs 用作窗口管理器 (WM) 的趋势。用户利用 Emacs 强大的 Lisp 环境,对桌面环境获得前所未有的控制力,超越了传统的“编写、保存、重载”工作流程,实现了动态的即时配置。 这种方法允许快速原型设计和自定义窗口行为、键绑定,甚至像显示色温这样的系统设置——所有这些都直接在 Emacs 中完成。像 EXWM 这样的项目促进了 Emacs 中对 X11 窗口的完全管理,而其他项目则利用 IPC 通过 Lisp 控制外部 WM,例如 Hyprland。 尽管学习曲线陡峭,但支持者强调了获得的自由和效率。虽然仍然存在挑战,例如管理复杂的配置以及与 Wayland 潜在的兼容性问题,但社区仍在不断探索和完善这些设置。讨论还涉及 Ratpoison 等替代方案,以及使用 OpenBSD 等精简操作系统来支持这种工作流程的好处。最终,用户发现基于 Lisp 的 WM 的强大功能和灵活性超过了复杂性,从而实现了高度个性化和高效的计算体验。
相关文章

原文

Most companies that employ me, hand me a “work laptop” as I enter the building. Of course, I do not install personal software and keep a clear division between my “work like” and my “real life.”

However, I also don’t like to carry two computers just to jot down personal notes. My remedy is to install a virtualization system and create a “personal” virtual machine. (Building cloud software as my day job means I usually have a few VMs running all the time.)

Since I want this VM to have minimal impact on my work, I base it on a “Server” version of Ubuntu. however, I like some graphical features, so my most minimal after market installation approach is:

sudo apt-get install -y xinit

Since most of what I do is org-mode work, the next step is:

sudo apt-get install -y emacs

I have played with a lot of window managers, and while some claim to be unobtrusive and minimal, I really just want Emacs in full-screen mode (utilizing all screen estate possible).

To accomplish this, I create an .xinitrc file that contains only:

exec emacs

That’s right, folks, Emacs is my window manager. I add the following to my Emacs init.el script:

(set-frame-parameter nil 'fullscreen 'fullboth)

And now I can split the screen into windows, launch programs– even edit files– all without fondling the mouse, and since Emacs is in its graphical mode, I can use my favorite fonts, decorate the fringe, etc.

new-window-manager-1.png

If I need a program that doesn’t run well within Emacs, I can call xterm (or any other application) with M-! xterm.

Web Browsing

Unlike the previous century, this century has been defined by web applications. Most of my web efforts are looking up code documentation and other technical resources, and this is good using a text-oriented browser like w3m or eww embedded within Emacs.

Whenever a page doesn’t render well (can you say JavaScript), I can hit the & key to bring up a web browser.. You can kick off a graphical browser to a specific URL by binding a function that calls this:

(start-process "" nil "xdg-open" "http://mail.google.com")

Keep in mind, running X window applications without a real window manager will overlay Emacs, which is only an option if the window is temporary. When closed, you are back to Emacs:

new-window-manager-3.png

Update: Since I wrote this section, a number of people have mentioned some light-weight window managers. If you need to use a browser, but still want Emacs to utilize every possible pixel, the best seems to be Ratpoison (with DWM a close second).

Other Applications

I realize that running shells inside Emacs isn’t for everyone, but currently using Emacs as my entire Linux desktop works pretty well. Especially since I can split the frame into a series of windows running:

I use a function to start my favorite time-sinks…er, applications, at one time:

(defun setup-windows ()
  "Organize a series of windows for ultimate distraction."
  (interactive)
  (delete-other-windows)

  
  (sx-tab-frontpage t nil)

  
  (split-window-horizontally)
  (other-window 1)
  (circe-connect-all)

  
  (split-window-vertically)
  (elfeed)

  
  (other-window 2)
  (split-window-vertically)
  (twit)

  (window-configuration-to-register ?w))

The last line insert this “current” configuration in a register, so after stomping and stirring my windows, I return to this organization with C-x r j w.

Perhaps another screenshot of these results are in order:

new-window-manager-2.png
联系我们 contact @ memedata.com