;;; package --- Summary
;; KOE - Basic setup or bare bone Emacs config
;; This code is Free Software you can redistribute it and/or modify it
;; under the terms of the GNU GPL version 3, or (at your option) any
;; later version, 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
;; for the complete license text.
;; Author: Kim ALLAMANDOLA
;; Package: KOE
;; Created: 07 Mar 2020
;; Updated: 07 Mar 2020
;; Version: 0.1
;;; Commentary:
;; My settings to make Emacs usable as I like, things like text edit
;; stuff, buffera and windows management stuff, a set of small pkgs
;; for few generic major modes, various useful minor modes etc.
;; Non-strictly-EXWM things are in koe-winbuf-manip.el
;;; Code:
(require 'use-package)
(require 'koe-utils)
;; The very first thing, since this is "an operating environment"
;; is to go fullscreen quickly and drop the "single-GUI" elements
(set-frame-parameter nil 'fullscreen 'fullboth)
;; a simple system try implementation for EXWM
(use-package exwm-systemtray
:ensure nil
:commands exwm-systemtray-enable
:config
(exwm-systemtray-enable)
:custom
(exwm-systemtray-height 16)
(exwm-systemtray-icon-gap 5))
;; Workspace in EXWM lingo are "virtual desktops" but with some extras.
;; I do not use the "virtual desktops" part but some other aspects.
(use-package exwm-workspace
:ensure nil
:config
(koe-global-bind-key "M-w" 'exwm-workspace-switch-to-buffer)
:custom
(exwm-workspace-number 1)
(exwm-workspace-show-all-buffers 't))
;; an EXWM module to lay out X windows inside Emacs, the sole
;; things I set is allowing switching windows/buffer from any
;; virtual desktop to any other
(use-package exwm-layout
:ensure nil
:custom (exwm-layout-show-all-buffers 't))
;; floating windows module for EXWM (dialogs etc)
(use-package exwm-floating
:ensure nil
:custom
(exwm-floating-border-width 3)
(exwm-floating-border-color "orange"))
(use-package exwm
:commands exwm-enable
:init
;; small hack from:
;; https://awesomeopensource.com/project/daedreth/UncleDavesEmacs
;; to make multimedia keys working in both X apps and Emacs buffers.
(dolist (k '(XF86AudioLowerVolume
XF86AudioRaiseVolume
XF86PowerOff
XF86AudioMute
XF86AudioPlay
XF86AudioStop
XF86AudioPrev
XF86AudioNext
XF86ScreenSaver
XF86Cut
XF86Copy
XF86Paste
XF68Back
XF86Forward
Scroll_Lock
print))
(cl-pushnew k exwm-input-prefix-keys))
;; make class name the buffer name, with special case for certain
;; X-apps with "strange" XWindows naming...
(with-no-warnings
(defun koe-exwm-update-instance-class ()
(unless
(or (string-prefix-p "sun-awt-X11-" exwm-instance-name)
(string= "gimp" exwm-instance-name))
(exwm-workspace-rename-buffer exwm-class-name)))
(defun koe-exwm-update-instance-title ()
(when
(or (not exwm-instance-name)
(string-prefix-p "sun-awt-X11-" exwm-instance-name)
(string= "gimp" exwm-instance-name))
(exwm-workspace-rename-buffer exwm-title))))
(exwm-enable)
:hook
;; few X applications badly set window title and class...
(('exwm-update-class-hook . koe-exwm-update-instance-class)
('exwm-update-title-hook . koe-exwm-update-instance-title)))
;; small utilities around EXWM (EXWM "extensions"/"tools")
(use-package exwm-x)
;; a small jumpapp-like utils, run or jump to an already opened X apps
;; WARNING: to get good results you need per saved X apps run
;; exwmx-appconfig that save X Windows proprieties for future use
;; i.e. to determine if the app is already running or not to choose
;; between launch a new instance or switch
(use-package exwmx-quickrun
:ensure nil
:commands exwmx-quickrun
:config
(defun koe-exwmx-run-or-jump-firefox ()
"Run or focus Firefox window."
(interactive)
(exwmx-quickrun "~/env/script/ff"))
(koe-global-bind-key "S-" 'koe-exwmx-run-or-jump-firefox)
(defun koe-exwmx-run-or-jump-chromium ()
"Run or focus Chromium-browser window."
(interactive)
(exwmx-quickrun "chromium-browser"))
(koe-global-bind-key "S-" 'koe-exwmx-run-or-jump-chromium)
(defun koe-exwmx-run-or-jump-homebank ()
"Run or focus HomeBank window."
(interactive)
(exwmx-quickrun "homebank"))
(koe-global-bind-key "" 'koe-exwmx-run-or-jump-homebank)
(defun koe-exwmx-run-or-jump-terminator ()
"Run or bring up Terminator terminal emulator."
(interactive)
(exwmx-quickrun "terminator.wrapper"))
(koe-global-bind-key "S-s-" 'koe-exwmx-run-or-jump-terminator))
;; Few functions by EXWM, not by me
(defun exwm-input-line-mode ()
"Set exwm window to line-mode and show mode line."
(declare-function exwm-input-grab-keyboard "exwm-input" (&optional ID))
(declare-function exwm-layout-show-mode-line "exwm-layout" ())
(call-interactively #'exwm-input-grab-keyboard)
(exwm-layout-show-mode-line))
(defun exwm-input-char-mode ()
"Set exwm window to char-mode and hide mode line."
(declare-function exwm-input-release-keyboard
"exwm-input" (&optional ID))
(declare-function exwm-layout-hide-mode-line "exwm-layout" ())
(call-interactively #'exwm-input-release-keyboard)
(exwm-layout-hide-mode-line))
(defun exwm-input-toggle-mode ()
"Toggle between line- and char-mode."
(declare-function second "cl" (X))
(with-current-buffer (window-buffer)
(when (eq major-mode 'exwm-mode)
(if (equal (second (second mode-line-process)) "line")
(exwm-input-char-mode)
(exwm-input-line-mode)))))
(provide 'koe-EXWM)
;;; koe-EXWM.el ends here