blob: 788bfe61f5fdf7e6699e3bfac823fba01d3d61af (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
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-x11-brightness ()
(string-trim (or (cadr (jao-shell-cmd-lines "brightnessctl")) "(Unknown)")))
;;;###autoload
(defun jao-x11-bright-show ()
(interactive)
(message "%s" (jao-x11-brightness)))
;;;###autoload
(defun jao-x11-bright-up ()
(interactive)
(jao-shell-exec "brightnessctl -q s 5%%+" t)
(jao-x11-bright-show))
;;;###autoload
(defun jao-x11-bright-down ()
(interactive)
(jao-shell-exec "brightnessctl -q s 5%%-" t)
(jao-x11-bright-show))
;;; Keyboard
;;;###autoload
(defun jao-x11-kb-layout ()
(string-trim
(shell-command-to-string
"setxkbmap -query | grep 'layout:' | awk '{print $2}'")))
;;;###autoload
(defun jao-x11-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-x11-kb-toggled-p ()
(not (string-empty-p
(shell-command-to-string "setxkbmap -query|grep variant"))))
;;;###autoload
(defun jao-x11-kb-toggle ()
(interactive)
(jao-x11-kb-set (jao-x11-kb-layout) (not (jao-x11-kb-toggled-p))))
;;;###autoload
(defun jao-x11-kb-disable-laptop ()
(interactive)
(jao-shell-exec "xinput float 13"))
(provide 'jao-x11)
;;; jao-x11.el ends here
|