EXWM

概要

EXWM(Emacs X Window Manager)は、ウィンドウマネージャの1つ。Emacs下でX Windowの管理ができる。つまり、Emacsでブラウザを開く…など、あらゆる操作が可能になり、各アプリケーションウィンドウを1つのbufferとして扱える。

Repository
ch11ng/exwm: Emacs X Window Manager
Wiki
Home · ch11ng/exwm Wiki

Memo

起動時微妙にフルスクリーンにならないことがある

たまにEmacsのモードラインの下に、微妙に黒いゾーンができる。 最初に (toggle-frame-fullscreen) してから (exwm-init) するとよい。

アプリケーション起動

S-& でウィンドウが立ち上がるコマンドを実行する。

blueman-manager
bluetooth管理
google-chrome
Chrome
nemo
Linux Mintのファイルマネージャ

X Windowとは

X を理解する

X は最初からネットワークを意識してデザインされており、“クライアント - サーバ”モデルを採用しています。 X では、“X サーバ”はキーボードやモニター、マウスが接続されたコンピュータ上で動きます。このサーバはディスプレイの表示を管理したり、キーボード、マウスなどからの入力を処理したりします。各 X アプリケーション (XTerm や Netscape など) は “クライアント”になります。クライアントは“この座標にウィンドウを描いてください”といったメッセージをサーバへ送り、サーバは“ユーザが OK ボタンを押しました”といったようなメッセージを送り返します。

Code

再起動のコード

  • 新しいEmacsを起動してから、現在のemacsをkill
  • 起動中のプロセスIDを取り、emacsclientだったときは親プロセスをkillする
  • 終了する前にhookを実行する
(defun exwm-restart ()
  "Restart EXWM."
  (interactive)
  (exwm--log)
  (when (exwm--confirm-kill-emacs "[EXWM] Restart? " 'no-check)
    (let* ((attr (process-attributes (emacs-pid)))
           (args (cdr (assq 'args attr)))
           (ppid (cdr (assq 'ppid attr)))
           (pargs (cdr (assq 'args (process-attributes ppid)))))
      (cond
       ((= ppid 1)
        ;; The parent is the init process.  This probably means this
        ;; instance is an emacsclient.  Anyway, start a control instance
        ;; to manage the subsequent ones.
        (call-process (car command-line-args))
        (kill-emacs))
       ((string= args pargs)
        ;; This is a subordinate instance.  Return a magic number to
        ;; inform the parent (control instance) to start another one.
        (kill-emacs ?R))
       (t
        ;; This is the control instance.  Keep starting subordinate
        ;; instances until told to exit.
        ;; Run `server-force-stop' if it exists.
        (run-hooks 'kill-emacs-hook)
        (with-temp-buffer
          (while (= ?R (shell-command-on-region (point) (point) args))))
        (kill-emacs))))))

Tasks

マルチディスプレイに対応する

設定が必要。

(require 'exwm-randr)
(setq exwm-randr-workspace-output-plist '(1 "eDP-1"))
(add-hook 'exwm-randr-screen-change-hook
          (lambda ()
            (start-process-shell-command
             "xrandr" nil "xrandr --output DP-1 --right-of HDMI-1 --auto")))
(exwm-randr-enable)
(exwm-enable)
  • 微妙に入りきってない
  • 左右分割しないと使い物にならない

など、かなり厳しそうな雰囲気。

TODO Chromeに切り替えたときフォーカスしない

qutebrowserやFirefoxでは起きないのでChromeの問題の可能性が高い。

Reference

Home · ch11ng/exwm Wiki

公式wiki。

Archives

DONE chromeバッファなどでpersp移動ができなくて不便

いちいちEmacsバッファに移ってからキーを打たないと反応しなかった。 define-keyでmodeに定義してやると共通のキーバインドで使用できるようになった。 こういうのちょっとめんどい。

(global-set-key (kbd "C-M-<right>") 'persp-next) ;; 従来
(global-set-key (kbd "C-M-<left>") 'persp-prev) ;; 従来
(define-key exwm-mode-map (kbd "C-M-<right>") 'persp-next) ;; 加える
(define-key exwm-mode-map (kbd "C-M-<left>") 'persp-prev) ;; 加える

DONE Setting EXWM

単に (start-process-shell-command) を使ってコマンドを実行すればいい。

(start-process-shell-command
   "compton" nil "compton -b --config $HOME/dotfiles/.config/compton/compton.conf")

CLOSED: [2021-09-19 日 00:25]

  • background
  • transparent background
  • polybar