(Emacs)+Elisp archive, (Scripts/status)+bluetooth status

This commit is contained in:
2023-10-06 01:18:33 +01:00
parent d88430aa8a
commit 300e8cbabd
5 changed files with 340 additions and 1 deletions

5
.gitignore vendored
View File

@@ -14,4 +14,7 @@ TAGS
/Doom/.config/doom/bookmarks
/Emacs/.config/emacs/config.el
/Emacs/.config/emacs/eglot-eclipse-jdt-cache/
/Emacs/.config/emacs/eln-cache/
/Emacs/.config/emacs/eln-cache/
/Emacs/.config/emacs/core.el
/Emacs/.config/emacs/app.el
/Emacs/.config/emacs/archive/

View File

@@ -0,0 +1,61 @@
(deftheme monokai
"Created 2021-03-10.")
(custom-theme-set-faces
'monokai
'(cursor ((t (:background "white"))))
'(fixed-pitch ((t (:family "Monospace"))))
'(variable-pitch ((((type w32)) (:foundry "outline" :family "Arial")) (t (:family "Sans Serif"))))
'(escape-glyph ((((background dark)) (:foreground "cyan")) (((type pc)) (:foreground "magenta")) (t (:foreground "brown"))))
'(homoglyph ((((background dark)) (:foreground "cyan")) (((type pc)) (:foreground "magenta")) (t (:foreground "brown"))))
'(minibuffer-prompt ((t (:foreground "#fd971f"))))
'(highlight ((t (:background "firebrick4" :foreground "white"))))
'(region ((t (:extend t :background "#4e4e4e"))))
'(shadow ((t (:foreground "#555556"))))
'(secondary-selection ((t (:extend t :background "#525254"))))
'(trailing-whitespace ((t (:background "#e74c3c"))))
'(font-lock-builtin-face ((t (:foreground "#fd971f"))))
'(font-lock-comment-delimiter-face ((t (:inherit font-lock-comment-face))))
'(font-lock-comment-face ((t (:foreground "#555556" :slant italic))))
'(font-lock-constant-face ((t (:inherit font-lock-variable-name-face))))
'(font-lock-doc-face ((t (:foreground "#7f7f80" :inherit (font-lock-comment-face)))))
'(font-lock-function-name-face ((t (:foreground "#b6e63e"))))
'(font-lock-keyword-face ((t (:foreground "#fb2874" :height 0.95 :family "Fira Code"))))
'(font-lock-negation-char-face ((t (:foreground "#9c91e4" :inherit (bold)))))
'(font-lock-preprocessor-face ((t (:foreground "#9c91e4" :inherit (bold)))))
'(font-lock-regexp-grouping-backslash ((t (:foreground "#9c91e4" :inherit (bold)))))
'(font-lock-regexp-grouping-construct ((t (:foreground "#9c91e4" :inherit (bold)))))
'(font-lock-string-face ((t (:foreground "yellow green"))))
'(font-lock-type-face ((t (:foreground "#66d9ef"))))
'(font-lock-variable-name-face ((t (:foreground "#fd971f"))))
'(font-lock-warning-face ((t (:inherit (warning)))))
'(button ((t (:inherit (link)))))
'(link ((t (:weight bold :underline (:color foreground-color :style line) :foreground "#fd971f"))))
'(link-visited ((t (:foreground "violet" :inherit (link)))))
'(fringe ((t (:foreground "#4e4e4e" :inherit (default)))))
'(header-line ((t (:foreground "#d6d6d4" :background "#1c1e1f"))))
'(tooltip ((t (:foreground "#d6d6d4" :background "#2d2e2e"))))
'(mode-line ((t (:box nil :background "#2d2e2e"))))
'(mode-line-buffer-id ((t (:weight bold))))
'(mode-line-emphasis ((t (:foreground "#fd971f"))))
'(mode-line-highlight ((t (:inherit (highlight)))))
'(mode-line-inactive ((t (:box nil :foreground "#4e4e4e" :background "#171819"))))
'(isearch ((t (:foreground "#1B2229" :background "#b6e63e"))))
'(isearch-fail ((t (:weight bold :foreground "#1B2229" :background "#e74c3c"))))
'(lazy-highlight ((t (:weight bold :foreground "#1B2229" :background "#9c91e4"))))
'(match ((t (:weight bold :foreground "#b6e63e" :background "#1B2229"))))
'(next-error ((t (:inherit (region)))))
'(query-replace ((t (:inherit (isearch)))))
'(outline-1 ((t (:foreground "#fb2874"))))
'(org-block ((t (:background "gray8"))))
'(ido-subdir ((t (:foreground "deepskyblue"))))
'(eshell-prompt ((t (:foreground "deepskyblue" :weight bold))))
'(company-tooltip-common ((((background light)) (:foreground "darkred")) (((background dark)) (:foreground "red"))))
'(company-tooltip ((t (:background "gray10" :foreground "white"))))
'(company-tooltip-selection ((t (:background "firebrick4"))))
'(org-quote ((t (:inherit org-block :slant italic :family "Liberation Mono"))))
'(org-verse ((t (:inherit org-block :slant oblique :family "Liberation Mono"))))
'(hl-line ((t (:extend t :background "gray9"))))
'(default ((t (:inherit nil :extend nil :stipple nil :background "black" :foreground "#d6d6d4" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :foundry "ADBO" :family "ibm plex mono")))))
(provide-theme 'monokai)

View File

@@ -0,0 +1,64 @@
(deftheme personal
"Created 2021-10-20.")
(custom-theme-set-faces
'personal
'(line-number ((t (:foreground "aquamarine1" :background "gray1"))))
'(cursor ((((background light)) (:background "black")) (((background dark)) (:background "white"))))
'(fixed-pitch ((t (:family "Monospace"))))
'(variable-pitch ((((type w32)) (:foundry "outline" :family "Arial")) (t (:family "Sans Serif"))))
'(escape-glyph ((((background dark)) (:foreground "cyan")) (((type pc)) (:foreground "magenta")) (t (:foreground "brown"))))
'(homoglyph ((((background dark)) (:foreground "cyan")) (((type pc)) (:foreground "magenta")) (t (:foreground "brown"))))
'(minibuffer-prompt ((((background dark)) (:foreground "cyan")) (((type pc)) (:foreground "magenta")) (t (:foreground "medium blue"))))
'(highlight ((t (:background "gray14"))))
'(region ((t (:extend t :background "gray25"))))
'(shadow ((((class color grayscale) (min-colors 88) (background light)) (:foreground "grey50")) (((class color grayscale) (min-colors 88) (background dark)) (:foreground "grey70")) (((class color) (min-colors 8) (background light)) (:foreground "green")) (((class color) (min-colors 8) (background dark)) (:foreground "yellow"))))
'(secondary-selection ((((class color) (min-colors 88) (background light)) (:extend t :background "yellow1")) (((class color) (min-colors 88) (background dark)) (:extend t :background "SkyBlue4")) (((class color) (min-colors 16) (background light)) (:extend t :background "yellow")) (((class color) (min-colors 16) (background dark)) (:extend t :background "SkyBlue4")) (((class color) (min-colors 8)) (:extend t :foreground "black" :background "cyan")) (t (:inverse-video t))))
'(trailing-whitespace ((((class color) (background light)) (:background "red1")) (((class color) (background dark)) (:background "red1")) (t (:inverse-video t))))
'(font-lock-builtin-face ((((class grayscale) (background light)) (:weight bold :foreground "LightGray")) (((class grayscale) (background dark)) (:weight bold :foreground "DimGray")) (((class color) (min-colors 88) (background light)) (:foreground "dark slate blue")) (((class color) (min-colors 88) (background dark)) (:foreground "LightSteelBlue")) (((class color) (min-colors 16) (background light)) (:foreground "Orchid")) (((class color) (min-colors 16) (background dark)) (:foreground "LightSteelBlue")) (((class color) (min-colors 8)) (:weight bold :foreground "blue")) (t (:weight bold))))
'(font-lock-comment-delimiter-face ((t (:slant italic :foreground "gray24"))))
'(font-lock-comment-face ((t (:slant italic :foreground "#868686"))))
'(font-lock-constant-face ((t (:foreground "slate blue" :weight semi-bold :height 0.99 :family "Source Code Pro"))))
'(font-lock-doc-face ((t (:inherit (font-lock-string-face)))))
'(font-lock-function-name-face ((t (:weight semi-bold))))
'(font-lock-keyword-face ((t (:foreground "DeepSkyBlue2" :weight bold :height 0.95 :family "Fira Code"))))
'(font-lock-negation-char-face ((t nil)))
'(font-lock-preprocessor-face ((t (:family "Source Code Pro" :foreground "#868686"))))
'(font-lock-regexp-grouping-backslash ((t (:inherit (bold)))))
'(font-lock-regexp-grouping-construct ((t (:inherit (bold)))))
'(font-lock-string-face ((t (:family "Fira Code" :foreground "yellow4"))))
'(font-lock-type-face ((t (:foreground "chartreuse" :family "Liberation Mono"))))
'(font-lock-variable-name-face ((t (:family "Source Code Variable" :foreground "#e6e6e6"))))
'(font-lock-warning-face ((t (:inherit (error)))))
'(button ((t (:inherit (link)))))
'(link ((t (:underline (:color foreground-color :style line) :foreground "cyan1"))))
'(link-visited ((t (:foreground "violet" :inherit (link)))))
'(fringe ((t (:background "grey4"))))
'(header-line ((t (:box nil :foreground "grey90" :background "grey20" :inherit (mode-line)))))
'(tooltip ((t (:foreground "black" :background "lightyellow" :inherit (variable-pitch)))))
'(mode-line ((t (:box (:line-width -1 :color nil :style released-button) :foreground "white" :background "black"))))
'(mode-line-buffer-id ((t (:weight bold))))
'(mode-line-emphasis ((t (:weight bold))))
'(mode-line-highlight ((((class color) (min-colors 88)) (:box (:line-width 2 :color "grey40" :style released-button))) (t (:inherit (highlight)))))
'(mode-line-inactive ((t (:weight light :box (:line-width -1 :color "grey40" :style nil) :foreground "grey30" :background "grey7" :inherit (mode-line)))))
'(isearch ((t (:foreground "brown4" :background "white"))))
'(isearch-fail ((((class color) (min-colors 88) (background light)) (:background "RosyBrown1")) (((class color) (min-colors 88) (background dark)) (:background "red4")) (((class color) (min-colors 16)) (:background "red")) (((class color) (min-colors 8)) (:background "red")) (((class color grayscale)) (:foreground "grey")) (t (:inverse-video t))))
'(lazy-highlight ((((class color) (min-colors 88) (background light)) (:background "paleturquoise")) (((class color) (min-colors 88) (background dark)) (:background "paleturquoise4")) (((class color) (min-colors 16)) (:background "turquoise3")) (((class color) (min-colors 8)) (:background "turquoise3")) (t (:underline (:color foreground-color :style line)))))
'(match ((((class color) (min-colors 88) (background light)) (:background "yellow1")) (((class color) (min-colors 88) (background dark)) (:background "RoyalBlue3")) (((class color) (min-colors 8) (background light)) (:foreground "black" :background "yellow")) (((class color) (min-colors 8) (background dark)) (:foreground "white" :background "blue")) (((type tty) (class mono)) (:inverse-video t)) (t (:background "gray"))))
'(next-error ((t (:inherit (region)))))
'(query-replace ((t (:inherit (isearch)))))
'(company-tooltip ((t (:background "navy blue" :foreground "white"))))
'(company-tooltip-selection ((t (:background "gray31"))))
'(company-tooltip-annotation ((t (:foreground "grey" :slant italic))))
'(company-preview ((((background light)) (:inherit (company-tooltip-selection company-tooltip))) (((background dark)) (:foreground "wheat" :background "blue4"))))
'(company-preview-common ((t (:inherit company-preview :foreground "grey"))))
'(org-block ((t (:background "gray3" :inherit shadow))))
'(eshell-prompt ((t (:foreground "deep sky blue" :weight bold))))
'(whitespace-tab ((t (:background "gray5" :foreground "gray20"))))
'(whitespace-space ((t (:background "gray2" :foreground "darkgray"))))
'(haskell-interactive-face-prompt ((t (:foreground "green"))))
'(org-verbatim ((t (:foreground "red3"))))
'(org-code ((t (:foreground "green3"))))
'(default ((t (:family "Source Code Pro" :foundry "ADBO" :width normal :height 113 :weight normal :slant normal :underline nil :overline nil :extend nil :strike-through nil :box nil :inverse-video nil :foreground "#b6b6b6" :background "#000000" :stipple nil :inherit nil)))))
(provide-theme 'personal)

View File

@@ -0,0 +1,202 @@
;;; profile-dotemacs.el --- Profile your Emacs init file
;; Copyright (C) 2010, 2012 David Engster
;; Author: David Engster <dengste@eml.cc>
;; 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 2
;; 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 <http://www.gnu.org/licenses/>.
;;; Commentary:
;; This is to easily profile your Emacs init file (or any other
;; script-like Emacs Lisp file, for that matter).
;; It will go over all sexp's (balanced expressions) in the file and
;; run them through `benchmark-run'. It will then show the file with
;; overlays applied in a way that let you easily find out which sexp's
;; take the most time. Since time is relative, it's not the absolute
;; value that counts but the percentage of the total running time.
;;
;; * All other sexp's with a percentage greater than
;; `profile-dotemacs-low-percentage' will be preceded by a
;; highlighted line, showing the results from `benchmark-run'.
;; Also, the more 'reddish' the background of the sexp, the more
;; time it needs.
;; * All other sexp's will be grayed out to indicate that their
;; running time is miniscule. You can still see the benchmark
;; results in the minibuffer by hovering over the sexp with the
;; mouse.
;; You can only benchmark full sexp's, so if you wrapped large parts
;; of your init file in some conditional clause, you'll have to remove
;; that for getting finer granularity.
;;; Usage:
;; Start emacs as follows:
;;
;; emacs -Q -l <PATH>/profile-dotemacs.el -f profile-dotemacs
;;
;; with <PATH> being the path to where this file resides.
;;; Caveats (thanks to Raffaele Ricciardi for reporting those):
;; - The usual `--debug-init' for debugging your init file won't work
;; with profile-dotemacs, so you'll have to call
;; `toggle-debug-on-error', either on the commandline or at the
;; beginning of your init file.
;; - `load-file-name' is nil when the init file is being loaded
;; by the profiler. This might matter if you perform the
;; bulk of initializations in a different file.
;; - Starting external shells like IELM or eshell in your init file
;; might mess with overlay creation, so this must not be done.
;;; Download:
;; You can always get the latest version from
;; http://randomsample.de/profile-dotemacs.el
;; Aryadev Chavali: customised for this emacs specifically.
;;; Code:
(require 'thingatpt)
(require 'benchmark)
;; User variables
(defvar profile-dotemacs-file "~/.config/emacs/init.el"
"File to be profiled.")
(defvar profile-dotemacs-low-percentage 3
"Percentage which should be considered low.
All sexp's with a running time below this percentage will be
grayed out.")
(defface profile-dotemacs-time-face
'((((background dark)) (:background "OrangeRed1"))
(t (:background "red3")))
"Background color to indicate percentage of total time.")
(defface profile-dotemacs-low-percentage-face
'((((background dark)) (:foreground "gray25"))
(t (:foreground "gray75")))
"Face for sexps below `profile-dotemacs-low-percentage'.")
(defface profile-dotemacs-highlight-face
'((((background dark)) (:background "blue"))
(t (:background "yellow")))
"Highlight face for benchmark results.")
;; Main function
(defun profile-dotemacs ()
"Load `profile-dotemacs-file' and benchmark its sexps."
(interactive)
(with-current-buffer (find-file-noselect profile-dotemacs-file t)
(setq buffer-read-only t) ;; just to be sure
(goto-char (point-min))
(let (start end results)
(while
(< (point)
(setq end (progn
(forward-sexp 1)
(point))))
(forward-sexp -1)
(setq start (point))
(add-to-list
'results
`(,start ,end
,(benchmark-run
(eval (sexp-at-point)))))
(goto-char end))
(profile-dotemacs-show-results results)
(switch-to-buffer (current-buffer)))))
;; Helper functions
(defun profile-dotemacs-show-results (results)
"Show timings from RESULTS in current buffer."
(let ((totaltime (profile-dotemacs-totaltime results))
current percentage ov)
(while results
(let* ((current (pop results))
(ov (make-overlay (car current) (cadr current)))
(current (car (last current)))
(percentage (/ (+ (car current) (nth 2 current))
totaltime))
col benchstr lowface)
(setq col
(profile-dotemacs-percentage-color
percentage
(face-background 'default)
(face-background 'profile-dotemacs-time-face)))
(setq percentage (round (* 100 percentage)))
(setq benchstr (profile-dotemacs-make-benchstr current))
(overlay-put ov 'help-echo benchstr)
(if (and (numberp profile-dotemacs-low-percentage)
(< percentage profile-dotemacs-low-percentage))
(overlay-put ov 'face 'profile-dotemacs-low-percentage-face)
(overlay-put ov 'before-string
(propertize benchstr
'face 'profile-dotemacs-highlight-face))
(overlay-put ov 'face
`(:background ,col)))))
(setq ov (make-overlay (1- (point-max)) (point-max)))
(overlay-put ov 'after-string
(propertize
(format "\n-----------------\nTotal time: %.2fs\n"
totaltime)
'face 'profile-dotemacs-highlight-face))))
(defun profile-dotemacs-totaltime (results)
"Calculate total time of RESULTS."
(let ((totaltime 0))
(mapc (lambda (x)
(let ((cur (car (last x))))
(setq totaltime (+ totaltime (car cur) (nth 2 cur)))))
results)
totaltime))
(defun profile-dotemacs-percentage-color (percent col-begin col-end)
"Calculate color according to PERCENT between COL-BEGIN and COL-END."
(let* ((col1 (color-values col-begin))
(col2 (color-values col-end))
(col
(mapcar (lambda (c)
(round
(+ (* (- 1 percent) (nth c col1))
(* percent (nth c col2)))))
'(0 1 2))))
(format "RGB:%04x/%04x/%04x"
(car col)
(nth 1 col)
(nth 2 col))))
(defun profile-dotemacs-make-benchstr (timings)
"Create descriptive benchmark string from TIMINGS."
(format
(concat
"<Percentage: %d ; "
"Time: %.2f ; "
"Number of GC: %d ; "
"Time for GC: %.2f>\n")
percentage
(car timings) (nth 1 timings) (nth 2 timings)))
;; profile-dotemacs.el ends here

View File

@@ -0,0 +1,9 @@
#!/usr/bin/env sh
name=$(bluetoothctl info | grep "Name" | sed 's/.*Name: //')
if [ ! "$name" ]
then
echo ""
else
echo "" $name;
fi