;;; kkk-exwm.el --- Exwm Config                      -*- lexical-binding: t; -*-

;; Copyright (C) 2023  Vinicius Teshima <vini.tes@pm.me>

;; Author: Vinicius Teshima <vini.tes@pm.me>

;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.

;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with this program.  If not, see <https://www.gnu.org/licenses/>.

;;; Commentary:

;; Exwm Configs

;;; Code:

(when (string-empty-p (shell-command-to-string "pgrep i3"))
  (defun kkk-exwm-run-shell-async (CMD)
    "Run CMD with `start-process-shell-command'."
    (interactive (list (read-shell-command "$ ")))
    (start-process-shell-command CMD nil CMD))

  (defun kkk-exwm-update-class ()
    "Change th buffer name to the name of app."
    (exwm-workspace-rename-buffer exwm-class-name))

  (use-package exwm
    :functions (exwm-enable exwm-workspace-rename-buffer)
    :defines (exwm-workspace-number exwm-input-prefix-keys exwm-mode-map
              exwm-class-name)
    :config
    (add-hook 'exwm-update-class-hook #'kkk-exwm-update-class)

    (setq exwm-workspace-number 10)

    ;; These keys should always pass through to Emacs
    (setq exwm-input-prefix-keys
          '(?\C-x
            ?\C-h
            ?\M-x
            ?\M-`
            ?\M-&
            ?\M-:
            ?\C-\M-j  ;; Buffer list
            ))

    (define-key exwm-mode-map [?\C-q] 'exwm-input-send-next-key)

    (exwm-enable))

  (use-package exwm-edit
    :after (exwm))
  )


(provide 'kkk-exwm)
;;; kkk-exwm.el ends here
