summaryrefslogtreecommitdiffhomepage
path: root/lib/wm
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 /lib/wm
parent0695b0e393680a8f745cf21800bfad2d3ab99b6e (diff)
downloadelibs-9c5427785d4715e723246d782a10332986a3e80a.tar.gz
elibs-9c5427785d4715e723246d782a10332986a3e80a.tar.bz2
x11 refactorings
Diffstat (limited to 'lib/wm')
-rw-r--r--lib/wm/jao-x11.el75
1 files changed, 75 insertions, 0 deletions
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