add all files back. i broke this repo whoops

This commit is contained in:
MitchMarq42 2024-01-20 08:26:34 -09:00
commit 0be884003f
2 changed files with 120 additions and 0 deletions

48
README.org Normal file
View File

@ -0,0 +1,48 @@
* Pitch:
In essence, this Emacs mode simply loads the data from dconf into ini files,
then applies them after each write to disk. It further provides the variable
=dconf--default-path= to allow more general or specific configuration, as
needed.
The main benefit of using something like this is that your GNOME (or whatever
else) settings are no longer a nebulous binary hive; they are declarative
human-readable text files. They can be version-controlled and distributed
alongside your other dotfiles. They can be viewed in other editors and
environments. They can be =grep='d through.
* Installlation:
With straight.el and use-package:
#+begin_src elisp
(use-package dconf-mode
:straight
(:type git
:repo "https://git.mitchmarq42.xyz/mitch/dconf-mode.el"))
#+end_src
* Usage:
I personally use this to manage my GNOME configuration like so:
#+begin_example
~/.config/gnome-custom-configs
├── desktop.gsets
├── settings-daemon.gsets
├── shell.gsets
└── terminal.gsets
#+end_example
Thus, editing `desktop.gsets' modifies the hive =/org/gnome/desktop/=.
* TODO
** have an option to use a temp buffer
** test
- working with nonexistent files
- older/newer emacs versions
- lexical binding?
* In other editors
To achieve something similar in vim/nvim:
#+begin_src vimscript
autocmd BufReadPre *.gsets silent !dconf dump /org/gnome/%:t:r/ > %
autocmd BufReadPost *.gsets set ft=dosini
autocmd BufWritePost *.gsets silent !cat % | dconf load /org/gnome/%:t:r/
#+end_src

72
dconf-mode.el Normal file
View File

@ -0,0 +1,72 @@
;;; dconf-mode.el --- Edit dconf settings in an emacs buffer
;; Author: Mitchell Marquez <dr.m.perseos@gmail.com>
;; URL: https://git.mitchmarq42.xyz/mitch/dconf-mode.el
;; Version: 0.1
;; Keywords: convenience
;;; Copyright © 2022 Mitchell Marquez <dr.m.perseos@gmail.com>
;;;
;;;
;;; This file is NOT part of GNU Emacs.
;;;
;;; 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:
;; dconf-mode is a lightweight major mode for editing dconf databases such as
;; the settings of the GNOME desktop environment from the comfort of Emacs, and
;; saving its configuration in simple text files.
;;; Code:
(defcustom dconf--default-path "/org/gnome/"
"The default path for dconf-mode to read and write from."
:group 'dconf-mode
:type 'string)
(defun dconf-load-current-file ()
"Load the current file into dconf's live registry."
(interactive)
(shell-command
(concat "cat " buffer-file-name
" | dconf load " dconf--default-path (file-name-base buffer-file-name) "/")))
(defun dconf-dump-current-file ()
"Load dconf's live registry into the current file."
(interactive)
(erase-buffer)
(shell-command
(concat "dconf dump " dconf--default-path (file-name-base buffer-file-name) "/")
(current-buffer)))
(defun dconf-edit (path)
"Open a dconf buffer to edit PATH."
(interactive "M")
(pop-to-buffer (get-buffer-create (format "*dconf %s*" path)))
(setq-local dconf-current-path path)
(dconf-mode))
;;;###autoload
(define-derived-mode dconf-mode conf-mode "Dconf"
"Major mode for interacting with the dconf database."
:group 'dconf-mode
;; :after-hook (dconf-dump-current-file)
(add-hook 'after-save-hook 'dconf-load-current-file 0 t))
;;;###autoload
(add-to-list 'auto-mode-alist '("\\.gsets" . dconf-mode))
(provide 'dconf-mode)
;;; dconf-mode.el ends here