diff options
Diffstat (limited to '.emacs.d/modules')
-rw-r--r-- | .emacs.d/modules/thanos-commands.el | 295 | ||||
-rw-r--r-- | .emacs.d/modules/thanos-mu4e.el | 132 | ||||
-rw-r--r-- | .emacs.d/modules/thanos-pass.el | 91 |
3 files changed, 0 insertions, 518 deletions
diff --git a/.emacs.d/modules/thanos-commands.el b/.emacs.d/modules/thanos-commands.el deleted file mode 100644 index af9603f..0000000 --- a/.emacs.d/modules/thanos-commands.el +++ /dev/null @@ -1,295 +0,0 @@ -;;; thanos-commands.el --- custom commands/functions -*- lexical-binding: t; -*- - -;; Copyright (C) 2023 Thanos Apollo - -;; Author: Thanos Apollo <[email protected]> -;; Keywords: - -;; 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: -;; ╭━━━━┳╮╱╱╱╱╱╱╱╱╱╱╱╱╱╱╭━━━╮╱╱╱╱╱╭╮╭╮╱╱╱╱╱╱╱╱╭━━━╮ -;; ┃╭╮╭╮┃┃╱╱╱╱╱╱╱╱╱╱╱╱╱╱┃╭━╮┃╱╱╱╱╱┃┃┃┃╱╱╱╱╱╱╱╱┃╭━━╯ -;; ╰╯┃┃╰┫╰━┳━━┳━╮╭━━┳━━╮┃┃╱┃┣━━┳━━┫┃┃┃╭━━╮╱╱╱╱┃╰━━┳╮╭┳━━┳━━┳━━╮ -;; ╱╱┃┃╱┃╭╮┃╭╮┃╭╮┫╭╮┃━━┫┃╰━╯┃╭╮┃╭╮┃┃┃┃┃╭╮┃╭━━╮┃╭━━┫╰╯┃╭╮┃╭━┫━━┫ -;; ╱╱┃┃╱┃┃┃┃╭╮┃┃┃┃╰╯┣━━┃┃╭━╮┃╰╯┃╰╯┃╰┫╰┫╰╯┃╰━━╯┃╰━━┫┃┃┃╭╮┃╰━╋━━┃ -;; ╱╱╰╯╱╰╯╰┻╯╰┻╯╰┻━━┻━━╯╰╯╱╰┫╭━┻━━┻━┻━┻━━╯╱╱╱╱╰━━━┻┻┻┻╯╰┻━━┻━━╯ -;; ╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱┃┃ -;; ╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╰╯ -;;; Code: - -;; VM -(defvar vm-directory "~/Virtual/") - -(defun vm-create-image () - "Create qcow2 image." - (interactive) - (let ((name (format "%s%s.qcow2" vm-directory (read-string "Name: "))) - (size (format "%s" (read-string "Size(G): ")))) - (shell-command - (format "qemu-img create -f qcow2 %s %sG" name size)))) - - -(defun vm-run () - "Spawn Virtual Machine." - (interactive) - (let ((memory (format "%sG" (read-string "Memory(G): "))) - (cores (read-string "Cores: ")) - (image (read-file-name "Image: " vm-directory)) - (iso (if (y-or-n-p "Load iso? ") - (read-file-name "ISO: ") - nil))) - (async-shell-command - (format "qemu-system-x86_64 -enable-kvm -m %s -smp %s -hda %s -vga virtio -device virtio-serial-pci -netdev user,id=vmnic,hostfwd=tcp::2222-:22 -device e1000,netdev=vmnic %s" - memory cores image (if iso (concat "-cdrom " iso) ""))))) - -;; MISC - -(defun thanos/run-in-background (command) - "Run COMMAND in the background." - (let ((command-parts (split-string command "[ ]+"))) - (apply #'call-process `(,(car command-parts) nil 0 nil ,@(cdr command-parts))))) - -(defun thanos/emacs-keys () - "Swap caps with ctrl." - (interactive) - (start-process-shell-command - "setxkbmap" nil "setxkbmap us -option ctrl:swapcaps")) - -(defun thanos/center-buffer () - (interactive) - (set-fringe-mode - (/ (- (frame-pixel-width) - (* 150 (frame-char-width))) - 2))) - -(defun thanos/git-clone (repository) - "Clone git REPOSITORY." - (interactive (list (read-string "repo: "))) - (call-process-shell-command - (concat "git clone " (shell-quote-argument repository)) nil 0)) - -;; CREATE - -(defun create-text-scratch () - "Create a scratch buffer." - (interactive) - (switch-to-buffer (get-buffer-create "*Text Scratch*")) - (org-mode)) - -(defun create-scratch () - "Create scratch buffer." - (interactive) - (switch-to-buffer (get-buffer-create "*scratch*")) - (emacs-lisp-mode)) - -(defvar-keymap thanos/create-map - :doc "Create custom buffers" - "t" #'create-text-scratch - "e" #'create-scratch) - -;; THEMING -(defvar wallpapers-dir "~/wallpapers/") - -(defun thanos/load-theme (&optional theme) - "Disable current theme and load a new THEME." - (interactive) - (let ((theme (or theme (intern (completing-read "Theme: " (custom-available-themes)))))) - (disable-theme (car custom-enabled-themes)) - (load-theme theme t))) - -(defun thanos/wallpaper-set (image) - "Set IMAGE as wallpaper, using feh." - (let ((command (if is-zeus "xwallpaper --output DisplayPort-1 --stretch" "feh --bg-scale"))) - (call-process-shell-command (concat command " " wallpapers-dir image) nil 0))) - -(defun thanos/wallpaper-random () - "Set random wallpaper." - (interactive) - (let ((wallpapers (directory-files "~/wallpapers" nil "^[^.].*"))) - (thanos/wallpaper-set (nth (random (length wallpapers)) wallpapers)))) - -(defun thanos/wallpaper-select () - "Set wallpaper." - (interactive) - (let ((wallpaper (completing-read "Choose wallpaper: " (directory-files wallpapers-dir nil "^[^.].*")))) - (thanos/wallpaper-set wallpaper))) - -(defvar-keymap thanos/applications-map - :doc "Thanos commonly used programs" - "t" #'thanos/load-theme - "w" #'thanos/wallpaper-select - "C-c" thanos/create-map) - -(define-key global-map (kbd "C-c a") thanos/applications-map) - - -(defun dired-watch-video () - "Watch play file with mpv." - (interactive) - (call-process-shell-command - (format "mpv \"%s\"" (dired-get-filename)) nil 0)) - -(defun dired-set-wallpaper () - "Set NAME as wallpaper using feh." - (interactive) - (let ((command (if is-zeus "xwallpaper --output DisplayPort-1 --stretch" "feh --bg-scale"))) - (call-process-shell-command - (format "%s %s" command (dired-get-filename)) nil 0))) - -(defun dired-delete-files-except () - "Delete all files inside directory except match." - (interactive) - (let* ((directory (read-directory-name "Select directory: ")) - (files (directory-files directory t)) - (except-match (read-string "Except the ones that have: "))) - (dolist (file files) - (unless (or (string= "." (substring file -1)) - (string= ".." (substring file -2)) - (string-match except-match file)) - (dired-delete-file file t))))) - -(defun dired-delete-file-match () - "Delete all files inside directory except match." - (interactive) - (let* ((directory (read-directory-name "Select directory: ")) - (files (directory-files directory t)) - (match (read-string "Delete files that match: "))) - (dolist (file files) - (when (string-match-p match file) - (dired-delete-file file t))))) - -(defun dired-rename-capitalize-file () - "Capitalize the base name of the file at point in a Dired buffer." - (interactive) - (let* ((file (dired-get-file-for-visit)) - (new-file (capitalize (file-name-nondirectory file)))) - (if (string-prefix-p "." file) - (message "Skipping file starting with '.'") - (progn - (rename-file file (concat (file-name-directory file) new-file)) - (revert-buffer) - (message "Renamed %s to %s" file new-file))))) - -(defun thanos/0x0-upload-file () - "Update file to 0x0.st" - (interactive) - (async-shell-command (format "curl -F'file=@%s' https://0x0.st" (dired-get-filename)))) - -;; yeetube -(defun yeetube-download-videos-ffmpeg () - "Download videos using ffmpeg." - (interactive) - (let ((url "") - (name "") - (download-counter 1) - (stored-contents nil)) - ;; Read links and names until "q" is entered - (while (not (string= url "q")) - (setf url (read-string "Enter URL (q to quit): ")) - (unless (string= url "q") - (setf name (read-string (format "Custom name (download counter: %d) " download-counter))) - (push (cons url name) stored-contents) - (setf download-counter (1+ download-counter)))) - ;; Process the collected links and names - (dolist (pair stored-contents) - (let ((url (car pair)) - (name (cdr pair))) - (async-shell-command - (format - "ffmpeg -protocol_whitelist file,crypto,data,https,tls,tcp -stats -i '%s' -codec copy '%s.mp4'" - url name)))))) - -(defun yeetube-download-vimeo-videos () - "Download videos from vimeo services." - (interactive) - (let ((url "") - (name "") - (download-counter 1)) - (while (not (string= url "q")) - (setf url (read-string "Enter URL (q to quit): ")) - (unless (string= url "q") - (setf name (read-string (format "Custom name (download counter: %d) " download-counter))) - (setf download-counter (1+ download-counter)) - (call-process-shell-command - (format - "yt-dlp '%s' -o '%s'" - (replace-regexp-in-string "\\.json" ".m3u8" url) name) - nil 0))))) - -;; Input methods -(defvar thanos/input-methods - '("greek" "bulgarian-phonetic" "nil") - "List of input methods to toggle.") - -(defvar thanos/input-methods-index 0 - "Index of the next input method in `thanos/input-methods' to use.") - -(defun thanos/toggle-input-method () - "Switch to the next input method in `thanos/input-methods'." - (interactive) - (setf thanos/input-methods-index - (mod (1+ thanos/input-methods-index) (length thanos/input-methods))) - (let ((input-method (nth thanos/input-methods-index thanos/input-methods))) - (set-input-method (if (string= "nil" input-method) nil input-method)))) - -(defun thanos/toggle-input-method () - "Switch to the next input method in `thanos/input-methods'." - (interactive) - (setf thanos/input-methods-index - (mod (1+ thanos/input-methods-index) (length thanos/input-methods))) - (let ((input-method (nth thanos/input-methods-index thanos/input-methods))) - (set-input-method (if (string= "nil" input-method) nil input-method)))) - -(defun erc-libera () - "Login to liberachat with erc." - (interactive) - (erc :server (password-store-get-field "znc/admin" "server") - :port (password-store-get-field "znc/admin" "port") - :user (password-store-get-field "znc/admin" "user") - :password (password-store-get "znc/admin"))) - - -(defun thanos/iimage-mode-buffer (arg) - "Display images if ARG is non-nil, undisplay them otherwise." - (let ((image-path (cons default-directory iimage-mode-image-search-path)) - (edges (window-inside-pixel-edges (get-buffer-window))) - file) - (with-silent-modifications - (save-excursion - (dolist (pair iimage-mode-image-regex-alist) - (goto-char (point-min)) - (while (re-search-forward (car pair) nil t) - (when (and (setq file (match-string (cdr pair))) - (setq file (locate-file file image-path))) - (if arg - (add-text-properties - (match-beginning 0) (match-end 0) - `(display - ,(create-image file nil nil - :max-width 120 - :max-height 120) - keymap ,image-map - modification-hooks - (iimage-modification-hook))) - (remove-list-of-text-properties - (match-beginning 0) (match-end 0) - '(display modification-hooks)))))))))) - -(define-minor-mode thanos/iimage-mode nil - :group 'iimage :lighter " iImg" - (thanos/iimage-mode-buffer thanos/iimage-mode)) - -(provide 'thanos-commands) -;;; thanos-commands.el ends here diff --git a/.emacs.d/modules/thanos-mu4e.el b/.emacs.d/modules/thanos-mu4e.el deleted file mode 100644 index 77b2856..0000000 --- a/.emacs.d/modules/thanos-mu4e.el +++ /dev/null @@ -1,132 +0,0 @@ -;;; thanos-mu4e.el --- mu4e configuration -*- lexical-binding: t; -*- - -;; Copyright (C) 2023 Thanos Apollo - -;; Author: Thanos Apollo <[email protected]> -;; Keywords: extensions - -;; 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: -;; ╭━━━━┳╮╱╱╱╱╱╱╱╱╱╱╱╱╱╱╭━━━╮╱╱╱╱╱╭╮╭╮╱╱╱╱╱╱╱╱╭━━━╮ -;; ┃╭╮╭╮┃┃╱╱╱╱╱╱╱╱╱╱╱╱╱╱┃╭━╮┃╱╱╱╱╱┃┃┃┃╱╱╱╱╱╱╱╱┃╭━━╯ -;; ╰╯┃┃╰┫╰━┳━━┳━╮╭━━┳━━╮┃┃╱┃┣━━┳━━┫┃┃┃╭━━╮╱╱╱╱┃╰━━┳╮╭┳━━┳━━┳━━╮ -;; ╱╱┃┃╱┃╭╮┃╭╮┃╭╮┫╭╮┃━━┫┃╰━╯┃╭╮┃╭╮┃┃┃┃┃╭╮┃╭━━╮┃╭━━┫╰╯┃╭╮┃╭━┫━━┫ -;; ╱╱┃┃╱┃┃┃┃╭╮┃┃┃┃╰╯┣━━┃┃╭━╮┃╰╯┃╰╯┃╰┫╰┫╰╯┃╰━━╯┃╰━━┫┃┃┃╭╮┃╰━╋━━┃ -;; ╱╱╰╯╱╰╯╰┻╯╰┻╯╰┻━━┻━━╯╰╯╱╰┫╭━┻━━┻━┻━┻━━╯╱╱╱╱╰━━━┻┻┻┻╯╰┻━━┻━━╯ -;; ╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱┃┃ -;; ╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╰╯ -;;; Code: - -(require 'smtpmail) -(require 'server) - -(add-to-list 'load-path "/usr/share/emacs/site-lisp/mu4e/") -(require 'mu4e) - -(setf mu4e-get-mail-command "mbsync -a") - -(when (and is-zeus (server-running-p)) - (setf mu4e-update-interval (* 10 60))) - -(defun set-mu4e-context (context-name full-name mail-address signature) - "Return a mu4e context named CONTEXT-NAME with :match-func matching - folder name CONTEXT-NAME in Maildir. The context's `user-mail-address', - `user-full-name' and `mu4e-compose-signature'`smtpmail-smpt-server' is set to MAIL-ADDRESS - FULL-NAME SIGNATURE and SERVER respectively. - Special folders are set to context specific folders." - (let ((dir-name (concat "/" context-name))) - (make-mu4e-context - :name context-name - ;; we match based on the maildir of the message - :match-func - `(lambda (msg) - (when msg - (string-match-p - ,(concat "^" dir-name) - (mu4e-message-field msg :maildir)))) - :vars - `((user-mail-address . ,mail-address) - (user-full-name . ,full-name) - (mu4e-sent-folder . ,(concat dir-name "/Sent")) - (mu4e-drafts-folder . ,(concat dir-name "/Drafts")) - (mu4e-trash-folder . ,(concat dir-name "/Trash")) - (mu4e-trash-folder . ,(concat dir-name "/Starred")) - (mu4e-refile-folder . ,(concat dir-name "/Archive")) - (mu4e-compose-signature . ,signature))))) -;;Fixing duplicate UID errors when using mbsync and mu4e -(setf mu4e-change-filenames-when-moving t) - -(setf mu4e-maildir-shortcuts - '(("/Fastmail/Inbox" . ?i) - ("/Drafts" . ?d) - ("/Sent" . ?s) - ("/Fastmail/Emacs/dev" . ?e) - ("/MUSofia/[Gmail]/All Mail" . ?u) - ("/Fastmail/Gentoo" . ?g))) - -(setf mu4e-contexts - (list - (make-mu4e-context - :name "Public" - :match-func - (lambda (msg) - (when msg - (string-prefix-p "/Fastmail" (mu4e-message-field msg :maildir)))) - :vars '((user-mail-address . "[email protected]") - (user-full-name . "Thanos Apollo") - (smtpmail-smtp-server . "smtp.fastmail.com") - (smtpmail-smtp-service . 465) - (smtpmail-stream-type . ssl) - (mu4e-drafts-folder . "/Drafts") - (mu4e-sent-folder . "/Sent") - (mu4e-refile-folder . "/Archive") - (mu4e-trash-folder . "/Trash"))) - (make-mu4e-context - :name "MUSofia" - :match-func - (lambda (msg) - (when msg - (string-prefix-p "/MUSofia" (mu4e-message-field msg :maildir)))) - :vars '((user-mail-address . "[email protected]") - (user-full-name . "Thanos Apollo") - (smtpmail-smtp-server . "smtp.gmail.com") - (smtpmail-smtp-service . 465) - (smtpmail-stream-type . ssl))))) - -(setf message-send-mail-function 'smtpmail-send-it - mu4e-compose-signature "\nThanos Apollo\n \nhttps://thanosapollo.org\n -62B7 58D0 F671 9938 BC09 CECA 339F 736C 3A72 0928\n" - mu4e-compose-context-policy 'ask) - -(setf mu4e-view-actions - (delete-dups - (append - '(("gapply git patches" . mu4e-action-git-apply-patch) - ("mgit am patch" . mu4e-action-git-apply-mbox) - ("bb4 am patch" . mu4e-action-git-apply-b4) - ("ssetup reword list with b4" . mu4e-action-setup-reword-b4) - ("crun checkpatch script" . my-mu4e-action-run-check-patch) - ("MCheck if merged" . my-mu4e-action-check-if-merged))))) - -(add-hook 'mu4e-main-mode-hook #'(lambda () - (display-line-numbers-mode -1) - (auto-save-mode -1))) -;; Sign messages -(add-hook 'message-send-hook 'mml-secure-message-sign-pgpmime) - -(define-key global-map (kbd "C-x m") 'mu4e) - -(provide 'thanos-mu4e) -;;; thanos-mu4e.el ends here diff --git a/.emacs.d/modules/thanos-pass.el b/.emacs.d/modules/thanos-pass.el deleted file mode 100644 index 0e996f6..0000000 --- a/.emacs.d/modules/thanos-pass.el +++ /dev/null @@ -1,91 +0,0 @@ -;;; thanos-pass.el --- Pass configuration -*- lexical-binding: t; -*- - -;; Copyright (C) 2023 Thanos Apollo - -;; Author: Thanos Apollo <[email protected]> - -;; 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: -;; ╭━━━━┳╮╱╱╱╱╱╱╱╱╱╱╱╱╱╱╭━━━╮╱╱╱╱╱╭╮╭╮╱╱╱╱╱╱╱╱╭━━━╮ -;; ┃╭╮╭╮┃┃╱╱╱╱╱╱╱╱╱╱╱╱╱╱┃╭━╮┃╱╱╱╱╱┃┃┃┃╱╱╱╱╱╱╱╱┃╭━━╯ -;; ╰╯┃┃╰┫╰━┳━━┳━╮╭━━┳━━╮┃┃╱┃┣━━┳━━┫┃┃┃╭━━╮╱╱╱╱┃╰━━┳╮╭┳━━┳━━┳━━╮ -;; ╱╱┃┃╱┃╭╮┃╭╮┃╭╮┫╭╮┃━━┫┃╰━╯┃╭╮┃╭╮┃┃┃┃┃╭╮┃╭━━╮┃╭━━┫╰╯┃╭╮┃╭━┫━━┫ -;; ╱╱┃┃╱┃┃┃┃╭╮┃┃┃┃╰╯┣━━┃┃╭━╮┃╰╯┃╰╯┃╰┫╰┫╰╯┃╰━━╯┃╰━━┫┃┃┃╭╮┃╰━╋━━┃ -;; ╱╱╰╯╱╰╯╰┻╯╰┻╯╰┻━━┻━━╯╰╯╱╰┫╭━┻━━┻━┻━┻━━╯╱╱╱╱╰━━━┻┻┻┻╯╰┻━━┻━━╯ -;; ╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱┃┃ -;; ╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╰╯ -;;; Code: - -(require 'password-store) - -(setf password-store-password-length (+ 20 (random 20))) - -(defun thanos/pass-launcher () - "Launch Emacs as a front-end for pass." - (interactive) - (unwind-protect - (with-selected-frame - (make-frame '((name . "thanos/pass-launcher") - (fullscreen . 0) - (undecorated . t) - (minibuffer . only) - (width . 70) - (height . 15))) - (let* ((choice (completing-read "Choose an action: " - '("AUTO" "COPY PASS" "COPY USERNAME" "EDIT" "GENERATE"))) - (action (pcase choice - ("AUTO" #'(lambda (entry) (let ((user (password-store-get-field entry "user")) (pass (password-store-get entry))) - (start-process-shell-command - "xdotool" nil - (format "sleep 0.3 && xdotool getactivewindow type '%s' && xdotool getactivewindow key Tab && xdotool getactivewindow type '%s'" - (if user user 'thanosapollo) pass))))) - ("COPY PASS" #'password-store-copy) - ("COPY USERNAME" #'(lambda (entry) (password-store-copy-field entry "user"))) - ("EDIT" #'password-store-edit) - ("GENERATE" #'password-store-generate)))) - (funcall action (completing-read "Search: " (password-store-list))) - (delete-frame))))) - -(defun smtp-get-pass () - "Get password for smtp." - (interactive) - (password-store-copy-field "fastmail.com/[email protected]" "smtp")) - -(define-prefix-command 'thanos/pass) -(global-set-key (kbd "C-c p") 'thanos/pass) -(define-key thanos/pass (kbd "i") 'password-store-insert) -(define-key thanos/pass (kbd "e") 'password-store-edit) -(define-key thanos/pass (kbd "g") 'password-store-generate) -(define-key thanos/pass (kbd "c") 'password-store-copy) -(define-key thanos/pass (kbd "s") 'smtp-get-pass) - -(defun thanos/app-launcher () - "Launch Emacs as an Application Launcher." - (interactive) - (let ((ivy-height 100)) - (unwind-protect - (with-selected-frame - (make-frame '((name . "thanos/emacs-launcher") - (minibuffer . only) - (fullscreen . 0) - (undecorated . t) - (internal-border-width . 10) - (width . 80) - (height . 11))) - (counsel-linux-app) - (delete-frame))))) - -(provide 'thanos-pass) -;;; thanos-pass.el ends here |