diff options
Diffstat (limited to '.emacs.d/modules/thanos-commands.el')
-rw-r--r-- | .emacs.d/modules/thanos-commands.el | 89 |
1 files changed, 61 insertions, 28 deletions
diff --git a/.emacs.d/modules/thanos-commands.el b/.emacs.d/modules/thanos-commands.el index 6245098..5bdaa83 100644 --- a/.emacs.d/modules/thanos-commands.el +++ b/.emacs.d/modules/thanos-commands.el @@ -29,8 +29,33 @@ ;; ╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╰╯ ;;; Code: +;; VM (defvar vm-directory "~/virtual-machines/") +(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))) + (start-process-shell-command + "virtual-machine" nil + (format "qemu-system-x86_64 -enable-kvm -m %s -smp %s -hda %s -vga qxl -device virtio-serial-pci -spice port=5784,disable-ticketing -display spice-app %s " + memory cores image (when iso (concat "-cdrom " iso)))))) + +;; MISC (defun thanos/run-in-background (command) "Run COMMAND in the background." @@ -43,52 +68,60 @@ (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 + +(define-prefix-command 'Create) + (defun create-text-scratch () "Create a scratch buffer." (interactive) (switch-to-buffer (get-buffer-create "*Text Scratch*")) (org-mode)) -(define-key Create (kbd "t") 'create-text-scratch) - (defun create-scratch () "Create scratch buffer." (interactive) (switch-to-buffer (get-buffer-create "*scratch*")) (emacs-lisp-mode)) -(define-key Create (kbd "e") 'create-scratch) +(defvar-keymap thanos/create + :doc "Create custom buffers" + "t" #'create-text-scratch + "e" #'create-scratch) -(defun thanos/center-buffer () - (interactive) - (set-fringe-mode - (/ (- (frame-pixel-width) - (* 150 (frame-char-width))) - 2))) +;; THEMING +(defvar wallpapers-dir "~/wallpapers/") -(defun vm-create-image () - "Create qcow2 image." +(defun thanos/load-theme () + "Disable current theme and load a new one." (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)))) + (let ((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." + (call-process-shell-command + (concat "xwallpaper --focus " wallpapers-dir image) nil 0)) -(defun vm-run () - "Spawn Virtual Machine." +(defun thanos/wallpaper-random () + "Set random wallpaper." (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))) - (start-process-shell-command - "virtual-machine" nil - (format "qemu-system-x86_64 -enable-kvm -m %s -smp %s -hda %s -vga qxl -device virtio-serial-pci -spice port=5784,disable-ticketing -display spice-app %s " - memory cores image (when iso (concat "-cdrom " iso)))))) - + (let ((wallpapers (directory-files "~/wallpapers" nil "^[^.].*"))) + (thanos/wallpaper-set (nth (random (length wallpapers)) wallpapers)))) (defun thanos/wallpaper-select () "Set wallpaper." |