summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2026-10-18 13:54:13 +0100
committerjao <jao@gnu.org>2026-10-18 13:54:13 +0100
commit9c5427785d4715e723246d782a10332986a3e80a (patch)
tree1967dddcf056754a2baf68661c63bdd2255f6493
parent0695b0e393680a8f745cf21800bfad2d3ab99b6e (diff)
downloadelibs-9c5427785d4715e723246d782a10332986a3e80a.tar.gz
elibs-9c5427785d4715e723246d782a10332986a3e80a.tar.bz2
x11 refactorings
-rw-r--r--init.el76
-rw-r--r--lib/wm/jao-x11.el75
2 files changed, 81 insertions, 70 deletions
diff --git a/init.el b/init.el
index b8ab4b5..57e6075 100644
--- a/init.el
+++ b/init.el
@@ -186,69 +186,6 @@
(use-package app-launcher
:bind (("s-R" . app-launcher-run-app))))
-;;;; brightness control
-(jao-when-linux
- (jao-shell-def-exec jao-bright-set-up "brightnessctl" "-q" "s" "5%+")
- (jao-shell-def-exec jao-bright-set-down "brightnessctl" "-q" "s" "5%-")
-
- (defun jao-brightness ()
- (string-trim (or (cadr (jao-shell-cmd-lines "brightnessctl")) "(Unknown)")))
-
- (defun jao-bright-show ()
- (interactive)
- (message "%s" (jao-brightness)))
-
- (defun jao-bright-up ()
- (interactive)
- (jao-shell-exec "brightnessctl -q s 5%%+" t)
- (jao-bright-show))
-
- (defun jao-bright-down ()
- (interactive)
- (jao-shell-exec "brightnessctl -q s 5%%-" t)
- (jao-bright-show)))
-
-;;;; keyboard
-(jao-when-darwin
- (setq mac-command-modifier 'meta)
- (setq mac-option-modifier 'super)
- (global-set-key (kbd "£") [?#]))
-
-(use-package repeat
- :demand t
- :config
- (setq repeat-echo-function 'repeat-echo-mode-line
- repeat-exit-key "SHIFT"
- repeat-exit-timeout 2)
- (repeat-mode))
-
-(jao-when-linux
- (defun jao-kb-toggle (&optional lyt)
- (interactive)
- (shell-command-to-string (or lyt
- (if (jao-kb-toggled-p)
- "setxkbmap us"
- "setxkbmap us -variant intl"))))
-
- (defun jao-set-uk-kb (&optional lyt)
- (interactive)
- (jao-kb-toggle "setxkbmap gb"))
-
- (defun jao-kb-disable-laptop ()
- (interactive)
- (jao-shell-exec "xinput float 13"))
-
- (defun jao-kb-toggled-p ()
- (not (string-empty-p
- (shell-command-to-string "setxkbmap -query|grep variant")))))
-
-(customize-set-variable 'default-input-method "catalan-prefix")
-;; http://mbork.pl/2022-03-07_Transient_input_method
-(customize-set-variable 'default-transient-input-method "TeX")
-
-(setq echo-keystrokes 1
- suggest-key-bindings nil)
-
;;;; transient
(use-package transient
:init (setq transient-show-popup t)
@@ -357,11 +294,10 @@
`(jao-call-with-auth ,host (lambda (,usr ,pwd) ,@body)))
;;;; pass
-(when (> emacs-major-version 28)
- (use-package password-store-menu
- :ensure t
- :config (password-store-menu-enable)
- :custom (password-store-menu-key "C-c p")))
+(use-package password-store-menu
+ :ensure t
+ :config (password-store-menu-enable)
+ :custom (password-store-menu-key "C-c p"))
;;; Fonts and color themes
;;;; widgets
@@ -2170,8 +2106,8 @@
("r" "translate" reverso)
("f" "copy buffer file name" copy-buffer-file-name-as-kill)
("F" "kill ff url" jao-exwm-kill-firefox-url :if jao-exwm-enabled-p)
- ("k" (lambda () (concat "keyboard" (when (jao-kb-toggled-p) "*")))
- jao-kb-toggle :if jao-x11-p)]]))
+ ("k" (lambda () (concat "keyboard" (when (jao-x11-kb-toggled-p) "*")))
+ jao-x11-kb-toggle :if jao-x11-p)]]))
(global-set-key (kbd "s-w") #'jao-transient-utils)
diff --git a/lib/wm/jao-x11.el b/lib/wm/jao-x11.el
new file mode 100644
index 0000000..16566d8
--- /dev/null
+++ b/lib/wm/jao-x11.el
@@ -0,0 +1,75 @@
+;;; jao-x11.el --- keyboard settings -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2026 jao
+
+;; Author: jao <mail@jao.io>
+
+;; 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/>.
+
+(require 'jao-shell)
+
+;;; Brightness
+(jao-shell-def-exec jao-bright-set-up "brightnessctl" "-q" "s" "5%+")
+(jao-shell-def-exec jao-bright-set-down "brightnessctl" "-q" "s" "5%-")
+
+(defun jao-brightness ()
+ (string-trim (or (cadr (jao-shell-cmd-lines "brightnessctl")) "(Unknown)")))
+
+;;;###autoload
+(defun jao-bright-show ()
+ (interactive)
+ (message "%s" (jao-brightness)))
+
+;;;###autoload
+(defun jao-bright-up ()
+ (interactive)
+ (jao-shell-exec "brightnessctl -q s 5%%+" t)
+ (jao-bright-show))
+
+;;;###autoload
+(defun jao-bright-down ()
+ (interactive)
+ (jao-shell-exec "brightnessctl -q s 5%%-" t)
+ (jao-bright-show))
+
+;;; Keyboard
+;;;###autoload
+(defun jao-kb-layout ()
+ (string-trim
+ (shell-command-to-string
+ "setxkbmap -query | grep 'layout:' | awk '{print $2}'")))
+
+;;;###autoload
+(defun jao-kb-set (lyt &optional intl)
+ (interactive "sLayout: ")
+ (let ((intl (if intl " -variant intl" "")))
+ (shell-command-to-string (format "setxkbmap %s%s" lyt intl))))
+
+;;;###autoload
+(defun jao-kb-toggled-p ()
+ (not (string-empty-p
+ (shell-command-to-string "setxkbmap -query|grep variant"))))
+
+;;;###autoload
+(defun jao-kb-toggle ()
+ (interactive)
+ (jao-kb-set (jao-kb-layout) (not (jao-kb-toggled-p))))
+
+;;;###autoload
+(defun jao-kb-disable-laptop ()
+ (interactive)
+ (jao-shell-exec "xinput float 13"))
+
+(provide 'jao-x11-kbd)
+;;; jao-x11.el ends here