diff options
author | Thanos Apollo <[email protected]> | 2023-02-10 06:41:33 +0200 |
---|---|---|
committer | GitHub <[email protected]> | 2023-02-10 06:41:33 +0200 |
commit | f68a4b1d3234b1a154d8aa293d2891d4280e559a (patch) | |
tree | d227a078b10bac5b9b85b1057589f8182bff2b97 | |
parent | 53762337d4e35d320dc7ad543dfdf5cbb0256866 (diff) | |
parent | 94909bbe12ada172c63387025bad189f4a851b84 (diff) |
Merge pull request #5 from ThanosApollo/org-config
Update literate configuration, adding qtile
-rw-r--r-- | .config/qtile/config.py | 366 | ||||
-rw-r--r-- | .config/qtile/keys.py | 302 | ||||
-rw-r--r-- | .emacs.d/init.el | 586 | ||||
-rw-r--r-- | .emacs.d/snippets/all-the-icons-dired.el | 104 | ||||
-rw-r--r-- | .emacs.d/snippets/apollo-eshell.el | 23 | ||||
-rw-r--r-- | .emacs.d/snippets/email-module.el | 68 | ||||
-rw-r--r-- | .emacs.d/snippets/functions.el | 130 | ||||
-rw-r--r-- | .emacs.d/snippets/keys.el | 98 | ||||
-rw-r--r-- | .emacs.d/snippets/org-config.el | 160 | ||||
-rw-r--r-- | Qtile.org | 536 | ||||
-rw-r--r-- | README.org | 9 | ||||
-rw-r--r-- | pictures/showcase2.png | bin | 0 -> 1899445 bytes |
12 files changed, 1102 insertions, 1280 deletions
diff --git a/.config/qtile/config.py b/.config/qtile/config.py index 306057f..a128fd5 100644 --- a/.config/qtile/config.py +++ b/.config/qtile/config.py @@ -31,25 +31,25 @@ groups = [] group_names = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", ] group_labels = ["Ⅰ", "Ⅱ", "Ⅲ", "Ⅳ", "Ⅴ", "Ⅵ", "Ⅶ", "Ⅷ", "Ⅸ", "Ⅹ", ] group_layouts = ["monadtall", "monadtall", "monadtall", "monadtall", - "monadtall", "monadtall", "monadtall", "monadtall", - "monadtall", "monadtall", ] + "monadtall", "monadtall", "monadtall", "monadtall", + "monadtall", "monadtall", ] for i in range(len(group_names)): groups.append( - Group( - name=group_names[i], - layout=group_layouts[i].lower(), - label=group_labels[i], - )) + Group( + name=group_names[i], + layout=group_layouts[i].lower(), + label=group_labels[i], + )) def init_layout_theme(): """Layout default theme.""" return {"margin": 5, - "border_width": 2, - "border_focus": dracula["cyan"], - "border_normal": dracula["bg"], - } + "border_width": 2, + "border_focus": dracula["cyan"], + "border_normal": dracula["bg"], + } layout_theme = init_layout_theme() @@ -65,14 +65,14 @@ layouts = [ # layout.Max(**layout_theme), # layout.Spiral(**layout_theme), layout.TreeTab(bg_color=dracula["bg"], - active_bg=dracula["purple"], - active_fg=dracula["fg"], - inactive_fg=dracula["fg"], - inactive_bg=dracula["bg"], - font="JetBrains Mono", - fontshadow=None, - section_fontsize=14, - panel_width=135,), + active_bg=dracula["purple"], + active_fg=dracula["fg"], + inactive_fg=dracula["fg"], + inactive_bg=dracula["bg"], + font="JetBrains Mono", + fontshadow=None, + section_fontsize=14, + panel_width=135,), # layout.Zoomy(**layout_theme), ] @@ -82,11 +82,11 @@ layouts = [ def init_widgets_defaults(): """Set widget default settings.""" return dict(font="JetBrains Mono", - fontsize=12, - padding=2, - foreground=dracula["fg"], - background=dracula["bg"] - ) + fontsize=12, + padding=2, + foreground=dracula["fg"], + background=dracula["bg"] + ) widget_defaults = init_widgets_defaults() @@ -95,162 +95,162 @@ widget_defaults = init_widgets_defaults() def init_widgets_list(): """My widget list.""" widgets_list = [ - widget.Spacer( - length=7, - ), - widget.Image( - filename="~/.config/qtile/rms.png", - scale="True", - margin=2, - ), - widget.Spacer( - length=7, - ), - widget.GroupBox( - font="FontAwesome", - fontsize=20, - padding=3, - margin=4, - borderwidth=1, - active=dracula["cyan"], - inactive=dracula["curr"], - rounded=False, - highlight_method="line", - this_current_screen_border=dracula["red"], - other_current_screen_border=dracula["curr"], - ), - widget.CurrentLayout( - font="Noto Sans Bold", - foreground=dracula["fg"], - background="#5B4B8A", - ), - widget.Spacer( - length=5 - ), - widget.WindowName( - font="JetBrains Mono Bold", - fontsize=12, - foreground=dracula["green"], - background=dracula["bg"], - ), - # widget.Image( - # filename = "~/.config/qtile/spotify2.png", - # scale = True, - # ), - # Spotify( - # fontsize = 12, - # background = dracula["bg"], - # color = dracula["green"], - # fmt = '{}', - # font = "JetBrains Mono Bold" - # ), - # widget.Moc( - # font = "JetBrains Mono", - # fontsize= 13, - # play_color=dracula["green"], - # paddig = 10, - # ), - widget.Pomodoro( - color_active=dracula["cyan"], - color_break=dracula["orange"], - color_inactive=dracula["curr"], - lenghth_pomodori=30, - fontsize=17, - ), - widget.Spacer( - length=10, - ), - widget.Image( - filename="~/.config/qtile/volume1.png", - scale=True, - ), - widget.Spacer( - length=7, - padding=10, - ), - widget.Volume( - fontsize=15, - fmt='{} ', - background=dracula["bg"], - foreground=dracula['orange'], - font="JetBrains Mono", - margin=10, - ), - # widget.Mpris2( - # fontsize= 16, - # background = my_colors["red"], - # objname="org.mpris.MediaPlayer2.spotify" - # ), - widget.Spacer( - length=7, - padding=10, - ), - widget.Image( - filename="~/.config/qtile/ram2.png", - scale=True, - ), - widget.Memory( - measure_mem="G", - fontsize=15, - foreground=dracula["cyan"], - background=dracula["bg"], - font='JetBrains Mono Bold', - ), - widget.MemoryGraph( - type='box', - graph_color=dracula["cyan"], - foreground=dracula["fg"], - background=dracula["bg"], - ), - widget.Spacer( - length=7 - ), - widget.Image( - filename="~/.config/qtile/cpu1.png", - scale=True, - ), - widget.ThermalSensor( - threshold=50, - fontsize=15, - font='JetBrains Mono Bold', - foreground=dracula["cyan"], - background=dracula["bg"], - ), - widget.CPUGraph( - type='box', - graph_color=dracula["cyan"], - background=dracula["bg"], - ), - widget.Spacer( - length=5 - ), - widget.TextBox( - font="FontAwesome", - text=" ", - foreground=dracula["orange"], - background=dracula["bg"], - padding=2, - fontsize=18 - ), - widget.Clock( - font='JetBrains Mono Bold', - foreground=dracula["cyan"], - background=dracula["bg"], - fontsize=18, - format="%d-%m-%Y | %H:%M" - ), - widget.Spacer( - length=6 - ), - widget.Systray( - background=dracula["bg"], - icon_size=20, - padding=10, - margin=10, - ), - widget.Spacer( - length=5 - ), + widget.Spacer( + length=7, + ), + widget.Image( + filename="~/.config/qtile/rms.png", + scale="True", + margin=2, + ), + widget.Spacer( + length=7, + ), + widget.GroupBox( + font="FontAwesome", + fontsize=20, + padding=3, + margin=4, + borderwidth=1, + active=dracula["cyan"], + inactive=dracula["curr"], + rounded=False, + highlight_method="line", + this_current_screen_border=dracula["red"], + other_current_screen_border=dracula["curr"], + ), + widget.CurrentLayout( + font="Noto Sans Bold", + foreground=dracula["fg"], + background="#5B4B8A", + ), + widget.Spacer( + length=5 + ), + widget.WindowName( + font="JetBrains Mono Bold", + fontsize=12, + foreground=dracula["green"], + background=dracula["bg"], + ), + # widget.Image( + # filename = "~/.config/qtile/spotify2.png", + # scale = True, + # ), + # Spotify( + # fontsize = 12, + # background = dracula["bg"], + # color = dracula["green"], + # fmt = '{}', + # font = "JetBrains Mono Bold" + # ), + # widget.Moc( + # font = "JetBrains Mono", + # fontsize= 13, + # play_color=dracula["green"], + # paddig = 10, + # ), + widget.Pomodoro( + color_active=dracula["cyan"], + color_break=dracula["orange"], + color_inactive=dracula["curr"], + lenghth_pomodori=30, + fontsize=17, + ), + widget.Spacer( + length=10, + ), + widget.Image( + filename="~/.config/qtile/volume1.png", + scale=True, + ), + widget.Spacer( + length=7, + padding=10, + ), + widget.Volume( + fontsize=15, + fmt='{} ', + background=dracula["bg"], + foreground=dracula['orange'], + font="JetBrains Mono", + margin=10, + ), + # widget.Mpris2( + # fontsize= 16, + # background = my_colors["red"], + # objname="org.mpris.MediaPlayer2.spotify" + # ), + widget.Spacer( + length=7, + padding=10, + ), + widget.Image( + filename="~/.config/qtile/ram2.png", + scale=True, + ), + widget.Memory( + measure_mem="G", + fontsize=15, + foreground=dracula["cyan"], + background=dracula["bg"], + font='JetBrains Mono Bold', + ), + widget.MemoryGraph( + type='box', + graph_color=dracula["cyan"], + foreground=dracula["fg"], + background=dracula["bg"], + ), + widget.Spacer( + length=7 + ), + widget.Image( + filename="~/.config/qtile/cpu1.png", + scale=True, + ), + widget.ThermalSensor( + threshold=50, + fontsize=15, + font='JetBrains Mono Bold', + foreground=dracula["cyan"], + background=dracula["bg"], + ), + widget.CPUGraph( + type='box', + graph_color=dracula["cyan"], + background=dracula["bg"], + ), + widget.Spacer( + length=5 + ), + widget.TextBox( + font="FontAwesome", + text=" ", + foreground=dracula["orange"], + background=dracula["bg"], + padding=2, + fontsize=18 + ), + widget.Clock( + font='JetBrains Mono Bold', + foreground=dracula["cyan"], + background=dracula["bg"], + fontsize=18, + format="%d-%m-%Y | %H:%M" + ), + widget.Spacer( + length=6 + ), + widget.Systray( + background=dracula["bg"], + icon_size=20, + padding=10, + margin=10, + ), + widget.Spacer( + length=5 + ), ] return widgets_list @@ -277,9 +277,9 @@ widgets_screen2 = init_widgets_screen2() def init_screens(): """Panel settings.""" return [Screen(top=bar.Bar(widgets=init_widgets_screen1(), size=33, - margin=11),), - Screen(top=bar.Bar(widgets=init_widgets_screen2(), size=28, - margin=7))] + margin=11),), + Screen(top=bar.Bar(widgets=init_widgets_screen2(), size=28, + margin=7))] screens = init_screens() diff --git a/.config/qtile/keys.py b/.config/qtile/keys.py index 85bf7ef..477c164 100644 --- a/.config/qtile/keys.py +++ b/.config/qtile/keys.py @@ -1,5 +1,3 @@ -#!/usr/bin/env python3 - from libqtile.config import Key from libqtile.command import lazy from libqtile.config import Click, Drag @@ -13,159 +11,159 @@ class MyKeys(): """ def __init__(self): - """ - Default customization - """ - self.mod = "mod4" - self.browser = "firefox" - self.term = "emacsclient -c" - self.editor = "emacsclient -c -a 'emacs'" + """ + Default customization + """ + self.mod = "mod4" + self.browser = "firefox" + self.term = "emacsclient -c" + self.editor = "emacsclient -c -a 'emacs'" def init_keys(self): - """ - Keyboard keybindings | Emacs-like | Set them and forget them. + """ + Keyboard keybindings | Emacs-like | Set them and forget them. - I'm used to having the superkey to control my window manager, - and control for my emacs. - """ - my_keys = [ - Key([self.mod], "Return", - lazy.spawn(self.term), - ), - Key([self.mod, "shift"], "a", - lazy.spawn('anki'), - ), - Key([self.mod, "shift"], "m", - lazy.spawn("spotify"), - ), - Key([self.mod], "Tab", - lazy.spawn("rofi -show drun"), - ), - Key([self.mod], "r", - lazy.spawn("rofi -show run"), - ), - Key([self.mod], "w", - lazy.spawn("rofi -show window"), - ), - Key([self.mod], "p", - lazy.spawn("passmenu -p 'Password for: '"), - ), - Key([self.mod], "b", - lazy.spawn(self.browser), - ), - Key([self.mod, "shift"], "c", - lazy.next_layout(), - ), - Key([self.mod], "q", - lazy.window.kill(), - ), - Key([self.mod, "shift"], "r", - lazy.restart(), - ), - Key([self.mod, "shift"], "0", - lazy.shutdown(), - ), - Key([self.mod, "shift"], "e", - lazy.spawn(self.editor), - ), - # Switch focus of monitors - Key([self.mod], "period", - lazy.next_screen(), - ), - # Treetab controls - Key([self.mod, "shift"], "h", - lazy.layout.move_left(), - ), - Key([self.mod, "shift"], "l", - lazy.layout.move_right(), - ), - # Window controls - Key([self.mod], "n", - lazy.layout.down(), - ), - Key([self.mod], "p", - lazy.layout.up(), - ), - Key([self.mod, "shift"], "n", - lazy.layout.shuffle_down(), - lazy.layout.section_down(), - ), - Key([self.mod, "shift"], "p", - lazy.layout.shuffle_up(), - lazy.layout.section_up(), - ), - Key([self.mod], "s", - lazy.layout.shrink(), - lazy.layout.decrease_nmaster(), - ), - Key([self.mod], "l", - lazy.layout.grow(), - lazy.layout.increase_nmaster(), - ), - Key([self.mod], "o", - lazy.layout.normalize(), - ), - Key([self.mod], "m", - lazy.layout.maximize(), - ), - Key([self.mod, "shift"], "f", - lazy.window.toggle_floating(), - ), - Key([self.mod], "f", - lazy.window.toggle_fullscreen(), - ), - # Stack controls - Key([self.mod, "shift"], "Tab", - lazy.layout.rotate(), - lazy.layout.flip(), - ), - Key([self.mod, "shift"], "space", - lazy.layout.toggle_split(), - ), - # Volume controls - Key([], "XF86AudioLowerVolume", - lazy.spawn('amixer sset Master 5%-'), - ), - Key([], "XF86AudioRaiseVolume", - lazy.spawn('amixer sset Master 5%+'), - ), - # I use mod+F[key] to change volume in my thinkpad, - # as I dislike using "fn" key in laptops - Key([self.mod], "F11", - lazy.spawn('amixer sset Master 5%-'), - ), - Key([self.mod], "F12", - lazy.spawn('amixer sset Master 5%+'), - ), - # Music controls | MOC - Key([self.mod], "u", - lazy.spawn("mocp -G "), - ), - Key([self.mod], "o", - lazy.spawn("mocp -f"), - ), - Key([self.mod], "i", - lazy.spawn("mocp -r"), - ), - # Change languages - Key([self.mod], "F1", - lazy.spawn("setxkbmap us -option ctrl:swapcaps"), - ), - Key([self.mod], "F2", - lazy.spawn("setxkbmap gr"), - ), - ] + I'm used to having the superkey to control my window manager, + and control for my emacs. + """ + my_keys = [ + Key([self.mod], "Return", + lazy.spawn(self.term), + ), + Key([self.mod, "shift"], "a", + lazy.spawn('anki'), + ), + Key([self.mod, "shift"], "m", + lazy.spawn("spotify"), + ), + Key([self.mod], "Tab", + lazy.spawn("rofi -show drun"), + ), + Key([self.mod], "r", + lazy.spawn("rofi -show run"), + ), + Key([self.mod], "w", + lazy.spawn("rofi -show window"), + ), + Key([self.mod], "p", + lazy.spawn("passmenu -p 'Password for: '"), + ), + Key([self.mod], "b", + lazy.spawn(self.browser), + ), + Key([self.mod, "shift"], "c", + lazy.next_layout(), + ), + Key([self.mod], "q", + lazy.window.kill(), + ), + Key([self.mod, "shift"], "r", + lazy.restart(), + ), + Key([self.mod, "shift"], "0", + lazy.shutdown(), + ), + Key([self.mod, "shift"], "e", + lazy.spawn(self.editor), + ), + # Switch focus of monitors + Key([self.mod], "period", + lazy.next_screen(), + ), + # Treetab controls + Key([self.mod, "shift"], "h", + lazy.layout.move_left(), + ), + Key([self.mod, "shift"], "l", + lazy.layout.move_right(), + ), + # Window controls + Key([self.mod], "n", + lazy.layout.down(), + ), + Key([self.mod], "p", + lazy.layout.up(), + ), + Key([self.mod, "shift"], "n", + lazy.layout.shuffle_down(), + lazy.layout.section_down(), + ), + Key([self.mod, "shift"], "p", + lazy.layout.shuffle_up(), + lazy.layout.section_up(), + ), + Key([self.mod], "s", + lazy.layout.shrink(), + lazy.layout.decrease_nmaster(), + ), + Key([self.mod], "l", + lazy.layout.grow(), + lazy.layout.increase_nmaster(), + ), + Key([self.mod], "o", + lazy.layout.normalize(), + ), + Key([self.mod], "m", + lazy.layout.maximize(), + ), + Key([self.mod, "shift"], "f", + lazy.window.toggle_floating(), + ), + Key([self.mod], "f", + lazy.window.toggle_fullscreen(), + ), + # Stack controls + Key([self.mod, "shift"], "Tab", + lazy.layout.rotate(), + lazy.layout.flip(), + ), + Key([self.mod, "shift"], "space", + lazy.layout.toggle_split(), + ), + # Volume controls + Key([], "XF86AudioLowerVolume", + lazy.spawn('amixer sset Master 5%-'), + ), + Key([], "XF86AudioRaiseVolume", + lazy.spawn('amixer sset Master 5%+'), + ), + # I use mod+F[key] to change volume in my thinkpad, + # as I dislike using "fn" key in laptops + Key([self.mod], "F11", + lazy.spawn('amixer sset Master 5%-'), + ), + Key([self.mod], "F12", + lazy.spawn('amixer sset Master 5%+'), + ), + # Music controls | MOC + Key([self.mod], "u", + lazy.spawn("mocp -G "), + ), + Key([self.mod], "o", + lazy.spawn("mocp -f"), + ), + Key([self.mod], "i", + lazy.spawn("mocp -r"), + ), + # Change languages + Key([self.mod], "F1", + lazy.spawn("setxkbmap us -option ctrl:swapcaps"), + ), + Key([self.mod], "F2", + lazy.spawn("setxkbmap gr"), + ), + ] - return my_keys + return my_keys def init_mouse(self): - """Mouse keys | cause sometimes we have to use the mouse.""" - mouse_keys = [ - Drag([self.mod], "Button1", lazy.window.set_position_floating(), - start=lazy.window.get_position()), - Drag([self.mod], "Button3", lazy.window.set_size_floating(), - start=lazy.window.get_size()), - Click([self.mod], "Button2", - lazy.window.bring_to_front()), - ] - return mouse_keys + """Mouse keys | cause sometimes we have to use the mouse.""" + mouse_keys = [ + Drag([self.mod], "Button1", lazy.window.set_position_floating(), + start=lazy.window.get_position()), + Drag([self.mod], "Button3", lazy.window.set_size_floating(), + start=lazy.window.get_size()), + Click([self.mod], "Button2", + lazy.window.bring_to_front()), + ] + return mouse_keys diff --git a/.emacs.d/init.el b/.emacs.d/init.el index 531c460..1180323 100644 --- a/.emacs.d/init.el +++ b/.emacs.d/init.el @@ -7,6 +7,7 @@ all-the-icons all-the-icons-dired all-the-icons-ivy-rich + toc-org general doom-themes doom-modeline @@ -306,7 +307,7 @@ Contains the list of packages that need to be installed.") (setq vterm-shell "/bin/zsh"))) (use-package eshell - :ensure t + :ensure nil :bind (("C-c e" . 'eshell)) :config (defvar eshell-path-env (getenv "~/.local/bin"))) @@ -330,10 +331,173 @@ Contains the list of packages that need to be installed.") (with-face (format-time-string " | %H:%M" (current-time)) :background winter-blue :foreground "#888") (with-face "\n -> ")))) -(setq eshell-prompt-function 'apollo-eshell-prompt) -(setq eshell-highlight-prompt t) +;; (setq eshell-prompt-function 'apollo-eshell-prompt) +;; (setq eshell-highlight-prompt t) -(global-set-key (kbd "<escape>") 'keyboard-escape-quit) +(require 'seq) +(eval-when-compile + (require 'cl-lib) + (require 'subr-x) + (require 'env) + (require 'json)) +(defgroup chatgpt nil + "ChatGPT frontend." + :group 'convenience + :prefix "chatgpt-") +(defcustom chatgpt-max-tokens 300 + "Upper limit on the number of tokens the API will return." + :type 'integer) +(defvar chatgpt-buffer "*ChatGPT*" + "Title of the buffer used to store the results of an OpenAI API query.") +(define-error 'chatgpt-error "An error related to the ChatGPT emacs package") +(define-error 'chatgpt-parsing-error + "An error caused by a failure to parse an OpenAI API Response") +(defmacro chatgpt-show-results-buffer-if-active () + "Show the results in other window if necessary." + `(if (and (not ;; visible + (get-buffer-window chatgpt-buffer)) + (called-interactively-p 'interactive)) + (lambda (&optional buf) (ignore buf) + (with-current-buffer buf + (view-mode t)) + (switch-to-buffer-other-window chatgpt-buffer)) + #'identity)) +;;;###autoload +(defun chatgpt-prompt (prompt callback) + "Query OpenAI with PROMPT calling the CALLBACK function on the resulting buffer. +Returns buffer containing the text from this query" + (interactive (list (read-string "Prompt ChatGPT with: ") + (lambda (buf) (with-current-buffer buf + (view-mode t)) + (switch-to-buffer-other-window chatgpt-buffer)))) + (chatgpt--query-open-api prompt + (lambda (results) + (with-current-buffer (get-buffer-create chatgpt-buffer) + ;; Erase contents of buffer after receiving response + (read-only-mode -1) + (erase-buffer) + (insert results) + ;; Return the chatgpt output buffer for non interactive usage + (funcall callback (current-buffer)))))) +;;;###autoload +(defun chatgpt-fix-region (BEG END) + "Takes a region BEG to END asks ChatGPT to explain whats wrong with it. +It then displays the answer in the `chatgpt-buffer'." + (interactive "r") + (let ((current-code (buffer-substring BEG END))) + (chatgpt-prompt (chatgpt--append-to-prompt + current-code + "Why doesn't this code work?") + (chatgpt-show-results-buffer-if-active)))) +;;;###autoload +(defun chatgpt-explain-region (BEG END) + "Takes a region BEG to END asks ChatGPT what it does. +The answer in the displays in `chatgpt-buffer'." + (interactive "r") + (let ((current-code (buffer-substring BEG END))) + (chatgpt-prompt (chatgpt--append-to-prompt + current-code + "What does this code do?") + (chatgpt-show-results-buffer-if-active)))) +;;;###autoload +(defun chatgpt-gen-tests-for-region (BEG END) + "Takes a region BEG to END asks ChatGPT to write a test for it. +It then displays the answer in the `chatgpt-buffer'." + (interactive "r") + (let ((current-code (buffer-substring BEG END))) + (chatgpt-prompt (chatgpt--append-to-prompt + current-code + "Write me a tests for this code") + (chatgpt-show-results-buffer-if-active)))) +;; TODO currently just says what changed but doesn't wanna show the code it's self +;; (defun chatgpt-optimize-region (BEG END) +;; "Takes a region BEG to END asks ChatGPT to optimize it for speed. +;; It then displays the answer in the `chatgpt-buffer'." +;; (interactive "r") +;; (let ((current-code (buffer-substring BEG END))) +;; (chatgpt-prompt (chatgpt--append-to-prompt +;; current-code +;; "Refactor this code for speed and tell me what you changed and why it's faster") +;; (chatgpt-show-results-buffer-if-active)))) +;;;###autoload +(defun chatgpt-refactor-region (BEG END) + "Takes a region BEG to END asks ChatGPT refactor it. +It then displays the answer in the `chatgpt-buffer'." + (interactive "r") + (let ((current-code (buffer-substring BEG END))) + (chatgpt-prompt (chatgpt--append-to-prompt + current-code + "Refactor this code and tell me what you changed") + (chatgpt-show-results-buffer-if-active)))) +;;;###autoload +(defun chatgpt-prompt-region (BEG END) + "Prompt ChatGPT with the region BEG END. +It then displays the results in a separate buffer `chatgpt-buffer'." + (interactive "r") + (chatgpt-prompt (buffer-substring BEG END) + ;; Show the results if not already being viewed + (chatgpt-show-results-buffer-if-active))) +;;;###autoload +(defun chatgpt-prompt-region-and-replace (BEG END) + "Replace region from BEG to END with the response from the ChatGPT API. +The region is BEG and until END" + (interactive "r") + (let ((og-buf (current-buffer))) + (chatgpt-prompt (buffer-substring BEG END) + (lambda (buf) + (save-excursion + (with-current-buffer og-buf + (delete-region BEG END) + (goto-char BEG) + (insert (with-current-buffer buf (buffer-string))))))))) +(defun chatgpt--append-to-prompt (prompt comment-str) + "Append the string COMMENT-STR extra information to a PROMPT as a comment." + (concat prompt + "\n" + comment-start + " " + comment-str)) +(defun chatgpt--extract-text-from-query (query-result) + "Extract the resulting text from a given OpenAI response QUERY-RESULT." + (condition-case err + (thread-last query-result + (assoc-default 'choices) + seq-first + (assoc-default 'text) + string-trim) + (error + (signal 'chatgpt-parsing-error err)))) +(defun chatgpt--parse-response (status callback) + "Ignoring STATUS and parse the response executing the CALLBACK function on the resulting string." + (ignore status) + ;; All this is ran inside the buffer containing the response + (goto-char 0) + (re-search-forward "^$") + (funcall callback (chatgpt--extract-text-from-query (json-read)))) +(defun chatgpt--query-open-api (prompt callback) + "Send a string PROMPT to OpenAI API and pass the resulting buffer to CALLBACK. +The environment variable OPENAI_API_KEY is used as your API key +You can register an account here +https://beta.openai.com/docs/introduction/key-concepts" + (let* ((api-key (getenv secret-api)) + (url-request-method (encode-coding-string "POST" 'us-ascii)) + (url-request-extra-headers `(("Content-Type" . "application/json") + ("Authorization" . ,(format "Bearer %s" api-key)))) + (url-request-data (json-encode + `(("model" . "text-davinci-003") + ("prompt" . ,prompt) + ("max_tokens" . ,chatgpt-max-tokens) + ("temperature" . 0))))) + (cl-assert (not (string= "" api-key)) + t + "Current contents of the environmental variable OPENAI_API_KEY +are '%s' which is not an appropriate OpenAI token please ensure +you have the correctly set the OPENAI_API_KEY variable" + api-key) + (url-retrieve + "https://api.openai.com/v1/completions" + 'chatgpt--parse-response + (list callback)))) (defun apollo/html-boostrap-boilerplate () "Insert html boilerplate with boostrap link." @@ -413,22 +577,6 @@ Contains the list of packages that need to be installed.") (interactive) (start-process-shell-command "setxkbmap" nil "setxkbmap gr")) - -(defun apollo/exwm-init-hook () - "Do this upon start." - (display-battery-mode 0) ;;Change to 1 to display battery - - (setq display-time-day-and-date t) - (display-time-mode 1) - - ;;Launch apps that will run in the background -;; (apollo/run-in-background "blueman-applet") - (apollo/run-in-background "picom") -;; (apollo/run-in-background "nm-applet") - (apollo/emacs-keys) - (apollo/set-wallpaper) - (start-polybar) - ) (defun apollo/exwm-update-class () (exwm-workspace-rename-buffer exwm-class-name)) @@ -438,11 +586,6 @@ Contains the list of packages that need to be installed.") (interactive) (eshell 'N)) -(defun make-mini-buffer () - (interactive) - (split-window-below 40) - (other-window 1)) - (defun make-mini-geiser () (interactive) (split-window-below 60) @@ -457,68 +600,7 @@ Contains the list of packages that need to be installed.") (start-process-shell-command "polybar" nil "polybar main"))) -(when (equal system-type 'darwin) - (use-package mu4e - :load-path "/opt/homebrew/share/emacs/site-lisp/mu/mu4e/")) - -(require 'mu4e) - -(setq mu4e-update-interval (* 10 60)) -(setq mu4e-get-mail-command "mbsync -a") -(setq mu4e-maildir-list "~/Mail/Inbox") - -(defun set-mu4e-context (context-name full-name mail-address signature server) - "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")) - (smtpmail-smtp-service . ,465) - (smtpmail-smtp-server . ,server) - (mu4e-compose-signature . ,signature))))) -;;Fixing duplicate UID errors when using mbsync and mu4e -(setq mu4e-change-filenames-when-moving t) - -(setq mu4e-maildir-shortcuts - '(("/Fastmail/Inbox" . ?i) - ("/Fastmail/Sent" . ?s) - ;; ("/Gmail/Trash" . ?t) - ;; ("/Gmail/Drafts" . ?d) - ;; ("/Gmail/[Gmail]/All Mail" . ?a - )) - -(setq mu4e-contexts - `(, (set-mu4e-context - "Fastmail" "Thanos Apollo" - "[email protected]" "Thanos\nhttps://thanosapollo.com/public" - "smtp.fastmail.com"))) - -;; (setq smtpmail-smtp-service 465 -;; smtpmail-stream-type 'ssl -;; smtpmail-smtp-server "smtp.fastmail.com") - - - -(setq message-send-mail-function 'smtpmail-send-it - smtpmail-stream-type 'ssl) +(global-set-key (kbd "<escape>") 'keyboard-escape-quit) ;; my general's leader key! (defconst general-key "C-c g") @@ -656,6 +738,12 @@ Contains the list of packages that need to be installed.") (add-hook 'org-mode-hook 'apollo/org-theme-dracula) (add-hook 'org-mode-hook 'org-superstar-mode) (add-hook 'org-mode-hook 'flyspell-mode) +(add-hook 'org-mode-hook 'toc-org-mode) + +(defadvice org-edit-src-code (around set-buffer-file-name activate compile) + (let ((file-name (buffer-file-name))) ;; (1) + ad-do-it ;; (2) + (setq buffer-file-name file-name))) ;; (3) (org-babel-do-load-languages 'org-babel-load-languages @@ -663,7 +751,7 @@ Contains the list of packages that need to be installed.") (python . t))) (add-to-list 'org-structure-template-alist '("sh" . "src shell")) -(add-to-list 'org-structure-template-alist '("b" . "src shell")) +(add-to-list 'org-structure-template-alist '("b" . "src bash")) (add-to-list 'org-structure-template-alist '("el" . "src emacs-lisp")) (add-to-list 'org-structure-template-alist '("py" . "src python")) @@ -797,281 +885,65 @@ Contains the list of packages that need to be installed.") :config (setq telega-server-libs-prefix "/opt/homebrew/Cellar/tdlib/HEAD-3d0140b"))) -(require 'seq) -(eval-when-compile - (require 'cl-lib) - (require 'subr-x) - (require 'env) - (require 'json)) -(defgroup chatgpt nil - "ChatGPT frontend." - :group 'convenience - :prefix "chatgpt-") -(defcustom chatgpt-max-tokens 300 - "Upper limit on the number of tokens the API will return." - :type 'integer) -(defvar chatgpt-buffer "*ChatGPT*" - "Title of the buffer used to store the results of an OpenAI API query.") -(define-error 'chatgpt-error "An error related to the ChatGPT emacs package") -(define-error 'chatgpt-parsing-error - "An error caused by a failure to parse an OpenAI API Response") -(defmacro chatgpt-show-results-buffer-if-active () - "Show the results in other window if necessary." - `(if (and (not ;; visible - (get-buffer-window chatgpt-buffer)) - (called-interactively-p 'interactive)) - (lambda (&optional buf) (ignore buf) - (with-current-buffer buf - (view-mode t)) - (switch-to-buffer-other-window chatgpt-buffer)) - #'identity)) -;;;###autoload -(defun chatgpt-prompt (prompt callback) - "Query OpenAI with PROMPT calling the CALLBACK function on the resulting buffer. -Returns buffer containing the text from this query" - (interactive (list (read-string "Prompt ChatGPT with: ") - (lambda (buf) (with-current-buffer buf - (view-mode t)) - (switch-to-buffer-other-window chatgpt-buffer)))) - (chatgpt--query-open-api prompt - (lambda (results) - (with-current-buffer (get-buffer-create chatgpt-buffer) - ;; Erase contents of buffer after receiving response - (read-only-mode -1) - (erase-buffer) - (insert results) - ;; Return the chatgpt output buffer for non interactive usage - (funcall callback (current-buffer)))))) -;;;###autoload -(defun chatgpt-fix-region (BEG END) - "Takes a region BEG to END asks ChatGPT to explain whats wrong with it. -It then displays the answer in the `chatgpt-buffer'." - (interactive "r") - (let ((current-code (buffer-substring BEG END))) - (chatgpt-prompt (chatgpt--append-to-prompt - current-code - "Why doesn't this code work?") - (chatgpt-show-results-buffer-if-active)))) -;;;###autoload -(defun chatgpt-explain-region (BEG END) - "Takes a region BEG to END asks ChatGPT what it does. -The answer in the displays in `chatgpt-buffer'." - (interactive "r") - (let ((current-code (buffer-substring BEG END))) - (chatgpt-prompt (chatgpt--append-to-prompt - current-code - "What does this code do?") - (chatgpt-show-results-buffer-if-active)))) -;;;###autoload -(defun chatgpt-gen-tests-for-region (BEG END) - "Takes a region BEG to END asks ChatGPT to write a test for it. -It then displays the answer in the `chatgpt-buffer'." - (interactive "r") - (let ((current-code (buffer-substring BEG END))) - (chatgpt-prompt (chatgpt--append-to-prompt - current-code - "Write me a tests for this code") - (chatgpt-show-results-buffer-if-active)))) -;; TODO currently just says what changed but doesn't wanna show the code it's self -;; (defun chatgpt-optimize-region (BEG END) -;; "Takes a region BEG to END asks ChatGPT to optimize it for speed. -;; It then displays the answer in the `chatgpt-buffer'." -;; (interactive "r") -;; (let ((current-code (buffer-substring BEG END))) -;; (chatgpt-prompt (chatgpt--append-to-prompt -;; current-code -;; "Refactor this code for speed and tell me what you changed and why it's faster") -;; (chatgpt-show-results-buffer-if-active)))) -;;;###autoload -(defun chatgpt-refactor-region (BEG END) - "Takes a region BEG to END asks ChatGPT refactor it. -It then displays the answer in the `chatgpt-buffer'." - (interactive "r") - (let ((current-code (buffer-substring BEG END))) - (chatgpt-prompt (chatgpt--append-to-prompt - current-code - "Refactor this code and tell me what you changed") - (chatgpt-show-results-buffer-if-active)))) -;;;###autoload -(defun chatgpt-prompt-region (BEG END) - "Prompt ChatGPT with the region BEG END. -It then displays the results in a separate buffer `chatgpt-buffer'." - (interactive "r") - (chatgpt-prompt (buffer-substring BEG END) - ;; Show the results if not already being viewed - (chatgpt-show-results-buffer-if-active))) -;;;###autoload -(defun chatgpt-prompt-region-and-replace (BEG END) - "Replace region from BEG to END with the response from the ChatGPT API. -The region is BEG and until END" - (interactive "r") - (let ((og-buf (current-buffer))) - (chatgpt-prompt (buffer-substring BEG END) - (lambda (buf) - (save-excursion - (with-current-buffer og-buf - (delete-region BEG END) - (goto-char BEG) - (insert (with-current-buffer buf (buffer-string))))))))) -(defun chatgpt--append-to-prompt (prompt comment-str) - "Append the string COMMENT-STR extra information to a PROMPT as a comment." - (concat prompt - "\n" - comment-start - " " - comment-str)) -(defun chatgpt--extract-text-from-query (query-result) - "Extract the resulting text from a given OpenAI response QUERY-RESULT." - (condition-case err - (thread-last query-result - (assoc-default 'choices) - seq-first - (assoc-default 'text) - string-trim) - (error - (signal 'chatgpt-parsing-error err)))) -(defun chatgpt--parse-response (status callback) - "Ignoring STATUS and parse the response executing the CALLBACK function on the resulting string." - (ignore status) - ;; All this is ran inside the buffer containing the response - (goto-char 0) - (re-search-forward "^$") - (funcall callback (chatgpt--extract-text-from-query (json-read)))) -(defun chatgpt--query-open-api (prompt callback) - "Send a string PROMPT to OpenAI API and pass the resulting buffer to CALLBACK. -The environment variable OPENAI_API_KEY is used as your API key -You can register an account here -https://beta.openai.com/docs/introduction/key-concepts" - (let* ((api-key (getenv secret-api)) - (url-request-method (encode-coding-string "POST" 'us-ascii)) - (url-request-extra-headers `(("Content-Type" . "application/json") - ("Authorization" . ,(format "Bearer %s" api-key)))) - (url-request-data (json-encode - `(("model" . "text-davinci-003") - ("prompt" . ,prompt) - ("max_tokens" . ,chatgpt-max-tokens) - ("temperature" . 0))))) - (cl-assert (not (string= "" api-key)) - t - "Current contents of the environmental variable OPENAI_API_KEY -are '%s' which is not an appropriate OpenAI token please ensure -you have the correctly set the OPENAI_API_KEY variable" - api-key) - (url-retrieve - "https://api.openai.com/v1/completions" - 'chatgpt--parse-response - (list callback)))) - -(defun apollo/html-boostrap-boilerplate () - "Insert html boilerplate with boostrap link." - (interactive) - (insert -"<!DOCTYPE html> -<html lang=\"en\"> - <head> - <meta charset=\"UTF-8\"> - <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"> - <meta http-equiv=\"X-UA-Compatible\" content=\"ie=edge\"> - <title>My Title</title> - <link rel=\"stylesheet\" href=\"./style.css\"> - <link href=\"https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css\" rel=\"stylesheet\" integrity=\"sha384-Zenh87qX5JnK2Jl0vWa8Ck2rdkQ2Bzep5IDxbcnCeuOxjzrPF/et3URy9Bv1WTRi\" crossorigin=\"anonymous\"> - </head> - <body> - <main> - <h1>Starting point</h1> - </main> - <script src=\"index.js\"></script> - </body> -</html>" )) - - -(defun apollo/center-buffer () - "Centers/Uncenters selected buffer" - (interactive) - (if visual-fill-column-center-text - (setq visual-fill-column-center-text nil) - (setq visual-fill-column-center-text t)) - (visual-fill-column-mode 1) - (message "General's task completed!")) - - -(defun apollo/rofi-switch-window () - "Navigate X11 buffers using rofi." - (interactive) - (start-process-shell-command - "rofi" nil "rofi -show window")) - -(defun apollo/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))))) +(when (equal system-type 'darwin) + (use-package mu4e + :load-path "/opt/homebrew/share/emacs/site-lisp/mu/mu4e/")) -(defun rofi () - "Run Rofi." - (interactive) - (apollo/run-in-background "rofi -show drun")) +(require 'mu4e) -(defun apollo/volume-increase () - "Increase Volume." - (interactive) - (start-process-shell-command - "amixer" nil "amixer sset Master 5%+")) +(setq mu4e-update-interval (* 10 60)) +(setq mu4e-get-mail-command "mbsync -a") +(setq mu4e-maildir-list "~/Mail/Inbox") -(defun apollo/volume-decrease () - "Decrease Volume." - (interactive) - (start-process-shell-command - "amixer" nil "amixer sset Master 5%-")) +(defun set-mu4e-context (context-name full-name mail-address signature server) + "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")) + (smtpmail-smtp-service . ,465) + (smtpmail-smtp-server . ,server) + (mu4e-compose-signature . ,signature))))) +;;Fixing duplicate UID errors when using mbsync and mu4e +(setq mu4e-change-filenames-when-moving t) -(defun apollo/restore-wallpaper () - "Set NAME as wallpaper." - (interactive) - (start-process-shell-command - "feh" nil "feh --bg-scale ~/dotfiles/wallpaper.png")) +(setq mu4e-maildir-shortcuts + '(("/Fastmail/Inbox" . ?i) + ("/Fastmail/Sent" . ?s) + ;; ("/Gmail/Trash" . ?t) + ;; ("/Gmail/Drafts" . ?d) + ;; ("/Gmail/[Gmail]/All Mail" . ?a + )) -(defun apollo/emacs-keys () - "Swap caps with ctrl." - (interactive) - (start-process-shell-command - "setxkbmap" nil "setxkbmap us -option ctrl:swapcaps")) +(setq mu4e-contexts + `(, (set-mu4e-context + "Fastmail" "Thanos Apollo" + "[email protected]" "Thanos\nhttps://thanosapollo.com/public" + "smtp.fastmail.com"))) -(defun apollo/greek-keyboard () - "Swap caps with ctrl." - (interactive) - (start-process-shell-command - "setxkbmap" nil "setxkbmap gr")) - -(defun apollo/exwm-update-class () - (exwm-workspace-rename-buffer exwm-class-name)) +;; (setq smtpmail-smtp-service 465 +;; smtpmail-stream-type 'ssl +;; smtpmail-smtp-server "smtp.fastmail.com") -(defun eshell-new() - "Open a new instance of eshell." - (interactive) - (eshell 'N)) -(defun make-mini-geiser () - (interactive) - (split-window-below 60) - (geiser nil)) -(defun start-polybar () - "Check which system is running, start polybar accordingly." - (interactive) - (if (string= (system-name) "fsociety") - (start-process-shell-command - "polybar" nil "polybar main & polybar second") - (start-process-shell-command - "polybar" nil "polybar main"))) -(custom-set-variables - ;; custom-set-variables was added by Custom. - ;; If you edit it by hand, you could mess it up, so be careful. - ;; Your init file should contain only one such instance. - ;; If there is more than one, they won't work right. - '(package-selected-packages - '(geiser-guile desktop-environment multi-vterm vertico-posframe page-break-lines dashboard notmuch mbsync mu4e-alert zone-nyan which-key weblorg typescript-mode sudo-edit simple-httpd rjsx-mode rainbow-delimiters quelpa-use-package pyvenv python-mode pelican-mode pdf-tools paredit org-superstar org-snooze org-modern org-make-toc org-auto-tangle nyan-mode monkeytype mastodon magit lsp-ui json-mode helpful guix general flycheck fireplace exwm-mff exwm-firefox-core eshell-syntax-highlighting embark elfeed-goodies ef-themes doom-themes doom-modeline dap-mode counsel corfu consult company-box circe chatgpt babel-repl alsamixer all-the-icons-ivy-rich all-the-icons-dired))) -(custom-set-faces - ;; custom-set-faces was added by Custom. - ;; If you edit it by hand, you could mess it up, so be careful. - ;; Your init file should contain only one such instance. - ;; If there is more than one, they won't work right. - ) +(setq message-send-mail-function 'smtpmail-send-it + smtpmail-stream-type 'ssl) diff --git a/.emacs.d/snippets/all-the-icons-dired.el b/.emacs.d/snippets/all-the-icons-dired.el deleted file mode 100644 index d2a8763..0000000 --- a/.emacs.d/snippets/all-the-icons-dired.el +++ /dev/null @@ -1,104 +0,0 @@ -;;; all-the-icons-dired.el --- Shows icons for each file in dired mode -*- lexical-binding: t; -*- -;customized from https://github.com/jtbm37/all-the-icons-dired -;;; Code: - -(require 'cl-lib) -(require 'dired) - - -(defface all-the-icons-dired-dir-face - '((((background dark)) :foreground "white") - (((background light)) :foreground "black")) - "Face for the directory icon" - :group 'all-the-icons-faces) - -(defcustom all-the-icons-dired-v-adjust 0.01 - "The default vertical adjustment of the icon in the dired buffer." - :group 'all-the-icons - :type 'number) - -(defvar all-the-icons-dired-mode) - -(defun all-the-icons-dired--add-overlay (pos string) - "Add overlay to display STRING at POS." - (let ((ov (make-overlay (1- pos) pos))) - (overlay-put ov 'all-the-icons-dired-overlay t) - (overlay-put ov 'after-string string))) - -(defun all-the-icons-dired--overlays-in (beg end) - "Get all all-the-icons-dired overlays between BEG to END." - (cl-remove-if-not - (lambda (ov) - (overlay-get ov 'all-the-icons-dired-overlay)) - (overlays-in beg end))) - -(defun all-the-icons-dired--overlays-at (pos) - "Get all-the-icons-dired overlays at POS." - (apply #'all-the-icons-dired--overlays-in `(,pos ,pos))) - -(defun all-the-icons-dired--remove-all-overlays () - "Remove all `all-the-icons-dired' overlays." - (save-restriction - (widen) - (mapc #'delete-overlay - (all-the-icons-dired--overlays-in (point-min) (point-max))))) - -(defun all-the-icons-dired--refresh () - "Display the icons of files in a dired buffer." - (all-the-icons-dired--remove-all-overlays) - (save-excursion - (goto-char (point-min)) - (while (not (eobp)) - (when (dired-move-to-filename nil) - (let ((file (dired-get-filename 'relative 'noerror))) - (when file - (let ((icon (if (file-directory-p file) - (all-the-icons-icon-for-dir file - :face 'all-the-icons-dired-dir-face - :v-adjust all-the-icons-dired-v-adjust) - (all-the-icons-icon-for-file file :v-adjust all-the-icons-dired-v-adjust)))) - (if (member file '("." "..")) - (all-the-icons-dired--add-overlay (point) " \t") - (all-the-icons-dired--add-overlay (point) (concat icon "\t"))))))) - (forward-line 1)))) - -(defun all-the-icons-dired--refresh-advice (fn &rest args) - "Advice function for FN with ARGS." - (apply fn args) - (when all-the-icons-dired-mode - (all-the-icons-dired--refresh))) - -(defun all-the-icons-dired--setup () - "Setup `all-the-icons-dired'." - (when (derived-mode-p 'dired-mode) - (setq-local tab-width 1) - (advice-add 'dired-readin :around #'all-the-icons-dired--refresh-advice) - (advice-add 'dired-revert :around #'all-the-icons-dired--refresh-advice) - (advice-add 'dired-internal-do-deletions :around #'all-the-icons-dired--refresh-advice) - (advice-add 'dired-insert-subdir :around #'all-the-icons-dired--refresh-advice) - (advice-add 'dired-do-kill-lines :around #'all-the-icons-dired--refresh-advice) - (with-eval-after-load 'dired-narrow - (advice-add 'dired-narrow--internal :around #'all-the-icons-dired--refresh-advice)) - (all-the-icons-dired--refresh))) - -(defun all-the-icons-dired--teardown () - "Functions used as advice when redisplaying buffer." - (advice-remove 'dired-readin #'all-the-icons-dired--refresh-advice) - (advice-remove 'dired-revert #'all-the-icons-dired--refresh-advice) - (advice-remove 'dired-internal-do-deletions #'all-the-icons-dired--refresh-advice) - (advice-remove 'dired-narrow--internal #'all-the-icons-dired--refresh-advice) - (advice-remove 'dired-insert-subdir #'all-the-icons-dired--refresh-advice) - (advice-remove 'dired-do-kill-lines #'all-the-icons-dired--refresh-advice) - (all-the-icons-dired--remove-all-overlays)) - -;;;###autoload -(define-minor-mode all-the-icons-dired-mode - "Display all-the-icons icon for each files in a dired buffer." - :lighter " all-the-icons-dired-mode" - (when (and (derived-mode-p 'dired-mode) (display-graphic-p)) - (if all-the-icons-dired-mode - (all-the-icons-dired--setup) - (all-the-icons-dired--teardown)))) - -(provide 'all-the-icons-dired) -;;; all-the-icons-dired.el ends here diff --git a/.emacs.d/snippets/apollo-eshell.el b/.emacs.d/snippets/apollo-eshell.el deleted file mode 100644 index aba141d..0000000 --- a/.emacs.d/snippets/apollo-eshell.el +++ /dev/null @@ -1,23 +0,0 @@ - -(defun with-face (str &rest face-plist) - (propertize str 'face face-plist)) - -(defun apollo-eshell-prompt () - (let ((winter-blue "#3F3B6C") - (white-summer "#E5E5CB") - (green-night "#03C988") - (orange-summer "#FFB100") - (green-summer "#A3BB98") - (summer-sea "#2192FF") - (black "#000000")) - (concat - (with-face (concat "[" user-login-name) :foreground orange-summer :background black) - (with-face "@" :foreground orange-summer :background black) - (with-face (concat system-name "]\n") :foreground orange-summer :background black) - (with-face (concat "|" (eshell/pwd) ) :foreground "#F0E9D2" :background winter-blue) - (with-face (format-time-string " | %H:%M" (current-time)) :background winter-blue :foreground "#888") - (with-face "\n -> ")))) - -(setq eshell-prompt-function 'apollo-eshell-prompt) -(setq eshell-highlight-prompt t) - diff --git a/.emacs.d/snippets/email-module.el b/.emacs.d/snippets/email-module.el deleted file mode 100644 index 494bd7b..0000000 --- a/.emacs.d/snippets/email-module.el +++ /dev/null @@ -1,68 +0,0 @@ - - -(when (equal system-type 'darwin) - (use-package mu4e - :load-path "/opt/homebrew/share/emacs/site-lisp/mu/mu4e/")) - -(require 'mu4e) - -(setq mu4e-update-interval (* 10 60)) -(setq mu4e-get-mail-command "mbsync -a") -(setq mu4e-maildir-list "~/Mail/Inbox") - -(defun set-mu4e-context (context-name full-name mail-address signature server) - "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")) - (smtpmail-smtp-service . ,465) - (smtpmail-smtp-server . ,server) - (mu4e-compose-signature . ,signature))))) -;;Fixing duplicate UID errors when using mbsync and mu4e -(setq mu4e-change-filenames-when-moving t) - -(setq mu4e-maildir-shortcuts - '(("/Fastmail/Inbox" . ?i) - ("/Fastmail/Sent" . ?s) - ;; ("/Gmail/Trash" . ?t) - ;; ("/Gmail/Drafts" . ?d) - ;; ("/Gmail/[Gmail]/All Mail" . ?a - )) - -(setq mu4e-contexts - `(, (set-mu4e-context - "Fastmail" "Thanos Apollo" - "[email protected]" "Thanos\nhttps://thanosapollo.com/public" - "smtp.fastmail.com"))) - -;; (setq smtpmail-smtp-service 465 -;; smtpmail-stream-type 'ssl -;; smtpmail-smtp-server "smtp.fastmail.com") - - - -(setq message-send-mail-function 'smtpmail-send-it - smtpmail-stream-type 'ssl) - -(provide 'email-module) -;;; email-module.el ends here - diff --git a/.emacs.d/snippets/functions.el b/.emacs.d/snippets/functions.el deleted file mode 100644 index 97156f6..0000000 --- a/.emacs.d/snippets/functions.el +++ /dev/null @@ -1,130 +0,0 @@ -;;; package --- Summary -;;; Commentary: -;;; Random functions for my daily use. -;;; Code: - - -(defun apollo/html-boostrap-boilerplate () - "Insert html boilerplate with boostrap link." - (interactive) - (insert -"<!DOCTYPE html> -<html lang=\"en\"> - <head> - <meta charset=\"UTF-8\"> - <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"> - <meta http-equiv=\"X-UA-Compatible\" content=\"ie=edge\"> - <title>My Title</title> - <link rel=\"stylesheet\" href=\"./style.css\"> - <link href=\"https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css\" rel=\"stylesheet\" integrity=\"sha384-Zenh87qX5JnK2Jl0vWa8Ck2rdkQ2Bzep5IDxbcnCeuOxjzrPF/et3URy9Bv1WTRi\" crossorigin=\"anonymous\"> - </head> - <body> - <main> - <h1>Starting point</h1> - </main> - <script src=\"index.js\"></script> - </body> -</html>" )) - - -(defun apollo/center-buffer () - "Centers/Uncenters selected buffer" - (interactive) - (if visual-fill-column-center-text - (setq visual-fill-column-center-text nil) - (setq visual-fill-column-center-text t)) - (visual-fill-column-mode 1) - (message "General's task completed!")) - - -(defun apollo/rofi-switch-window () - "Navigate X11 buffers using rofi." - (interactive) - (start-process-shell-command - "rofi" nil "rofi -show window")) - -(defun apollo/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 rofi () - "Run Rofi." - (interactive) - (apollo/run-in-background "rofi -show drun")) - -(defun apollo/volume-increase () - "Increase Volume." - (interactive) - (start-process-shell-command - "amixer" nil "amixer sset Master 5%+")) - -(defun apollo/volume-decrease () - "Decrease Volume." - (interactive) - (start-process-shell-command - "amixer" nil "amixer sset Master 5%-")) - -(defun apollo/restore-wallpaper () - "Set NAME as wallpaper." - (interactive) - (start-process-shell-command - "feh" nil "feh --bg-scale ~/dotfiles/wallpaper.png")) - -(defun apollo/emacs-keys () - "Swap caps with ctrl." - (interactive) - (start-process-shell-command - "setxkbmap" nil "setxkbmap us -option ctrl:swapcaps")) - -(defun apollo/greek-keyboard () - "Swap caps with ctrl." - (interactive) - (start-process-shell-command - "setxkbmap" nil "setxkbmap gr")) - -(defun apollo/exwm-init-hook () - "Do this upon start." - (display-battery-mode 0) ;;Change to 1 to display battery - - (setq display-time-day-and-date t) - (display-time-mode 1) - - ;;Launch apps that will run in the background -;; (apollo/run-in-background "blueman-applet") - (apollo/run-in-background "picom") -;; (apollo/run-in-background "nm-applet") - (apollo/emacs-keys) - (apollo/set-wallpaper) - (start-polybar) - ) - -(defun apollo/exwm-update-class () - (exwm-workspace-rename-buffer exwm-class-name)) - -(defun eshell-new() - "Open a new instance of eshell." - (interactive) - (eshell 'N)) - -(defun make-mini-buffer () - (interactive) - (split-window-below 40) - (other-window 1)) - -(defun make-mini-geiser () - (interactive) - (split-window-below 60) - (geiser nil)) - -(defun start-polybar () - "Check which system is running, start polybar accordingly." - (interactive) - (if (string= (system-name) "fsociety") - (start-process-shell-command - "polybar" nil "polybar main & polybar second") - (start-process-shell-command - "polybar" nil "polybar main"))) -;;; my-functions.el ends here. - - diff --git a/.emacs.d/snippets/keys.el b/.emacs.d/snippets/keys.el deleted file mode 100644 index 0d88af6..0000000 --- a/.emacs.d/snippets/keys.el +++ /dev/null @@ -1,98 +0,0 @@ -;; init-keys.el -;;; Code: -(require 'multi-vterm) -(require 'vterm) -(require 'general) -(require 'pdf-tools) -(require 'hydra) - -;; my general's leader key! -(defconst general-key "C-c g") - -(define-prefix-command 'window-control-map) -(global-set-key (kbd "C-w") 'window-control-map) - -(general-create-definer general-does - :prefix general-key) - -(defhydra hydra-zoom (global-map "s-z") - "zoom" - ("=" text-scale-increase "in") - ("-" text-scale-decrease "out")) - - - -;; Basic functions -(general-define-key - "C-d" 'kill-region - "C-k" 'copy-region-as-kill - "C-c v" 'multi-vterm-next - "C-x 9" 'make-mini-buffer - "C-c l e" 'apollo/emacs-keys - ;;Change keyboard layouts/language - "C-c l g" 'apollo/greek-keyboard - "C-κ" 'apollo/emacs-keys - "C-x C-b" 'ibuffer) - - - -;; My Generals does: -(general-does - "t" 'counsel-load-theme - "l" 'display-line-numbers-mode - "v" 'multi-vterm-next - "e" 'eshell - "i" 'circe - "c" 'apollo/center-buffer - "m" 'mu4e - "f" 'elfeed) - -;;pdf-tools -(general-define-key - :keymaps 'pdf-view-mode-map - "C-c d" 'pdf-view-midnight-minor-mode - "C-s" 'isearch-forward - "C-o" 'pdf-isearch-occur) - - - -;;vterm -(general-does - :keymaps 'vterm-mode-map - "n" 'multi-vterm-next - "o" 'multi-vterm - "p" 'multi-vterm-prev) - -(general-define-key - :keymaps 'vterm-mode-map - "C-c v n" 'multi-vterm-next - "C-c v p" 'multi-vterm-prev - "C-c v o" 'multi-vterm) - -;;eshell -(general-does - :keymaps 'eshell-mode-map - "n" 'eshell-new) -;;org -(general-does - :keymaps 'org-mode-map - "3" 'org-insert-image-size-300) -;;pdf-tools - -;;Add pdf-isearch-minor-mode hook, otherwise isearch will be buggy -;;Darkmode hook, cause I don't want color or light in my life, I'm a vampire. -(add-hook 'pdf-view-mode-hook 'pdf-isearch-minor-mode) -(add-hook 'pdf-view-mode-hook 'pdf-view-midnight-minor-mode) - -(general-define-key - :keymaps 'pdf-view-mode-map - "C-c d" 'pdf-view-midnight-minor-mode - "C-s" 'isearch-forward - "C-o" 'pdf-isearch-occur) - -;;scheme -(general-does - :keymaps 'scheme-mode-map - "g" 'make-mini-geiser) - -;;init-keys ends here diff --git a/.emacs.d/snippets/org-config.el b/.emacs.d/snippets/org-config.el deleted file mode 100644 index 6e73844..0000000 --- a/.emacs.d/snippets/org-config.el +++ /dev/null @@ -1,160 +0,0 @@ -(require 'org) -(require 'org-agenda) -(require 'org-superstar) -(require 'org-tempo) - -(defun apollo/org-mode-setup () - (setq evil-auto-indent nil) - (apollo/org-theme-dracula)) - -(add-hook 'org-mode-hook 'apollo/org-mode-setup) -(add-hook 'org-mode-hook 'org-superstar-mode) -(add-hook 'org-mode-hook 'flyspell-mode) - -(setq org-directory "~/org/" - org-agenda-files '("~/org/agenda.org") - org-default-notes-file (expand-file-name "notes.org" org-directory) - org-ellipsis " ▼ " - org-log-done 'time - org-hide-emphasis-markers nil ;;change to t to hide emphasis markers - org-table-convert-region-max-lines 20000 - org-agenda-start-log-mode t - org-log-done 'time - org-log-into-drawer t - org-indent-mode t - org-todo-keywords ;; This overwrites the default Doom org-todo-keywords - '((sequence - "TODO(t)" ;; A task that is ready to be tackled - "BLOG(b)" ;; Blog writing assignments - "GYM(g)" ;; Things to accomplish at the gym - "WAIT(w)" ;; Something is holding up this task - "|" ;; The pipe necessary to separate "active" states and "inactive" states - "DONE(d)" ;; Task has been completed - "CANCELLED(c)" )) - org-superstar-headline-bullets-list '("◉" "●" "○" "●" "○" "●" "◆") - org-superstar-itembullet-alist '((?+ . ?➤) (?- . ?✦))) ;; changes +/- symbols in item lists) - -;; Use either org-bullets or org-superstar -;; (use-package org-bullets -;; :after org -;; :hook (org-mode . org-bullets-mode) -;; :custom -;; (org-bullets-bullet-list '("●" "○" "●" "○" "●" "●" ))) - -;; Org Themes -(defun apollo/org-theme-none () - "Enable Darkone theme for Org headers." - (interactive) - (dolist - (face - '((org-level-1 1.60) - (org-level-2 1.55) - (org-level-3 1.40) - (org-level-4 1.20) - (org-level-5 1.20) - (org-level-6 1.20) - (org-level-7 1.10) - (org-level-8 1.00))))) -(defun my-org-faces () - (set-face-attribute 'org-todo nil :height 0.8) - (set-face-attribute 'org-level-1 nil :height 1.70 :weight bold) - (set-face-attribute 'org-level-2 nil :height 1.50)) -(defun apollo/org-theme-darkone () - "Enable Darkone theme for Org headers." - (interactive) - (dolist - (face - '((org-level-1 1.70 "#51afef" bold) - (org-level-2 1.55 "#7FBCD2" bold) - (org-level-3 1.40 "#da8548" bold) - (org-level-4 1.20 "#da8548" semi-bold) - (org-level-5 1.20 "#5699af" normal) - (org-level-6 1.20 "#a9a1e1" normal) - (org-level-7 1.10 "#46d9ff" normal) - (org-level-8 1.00 "#ff6c6b" normal))) - (set-face-attribute (nth 0 face) nil - :font "Jetbrains Mono" - :weight (nth 3 face) - :height (nth 1 face) - :foreground (nth 2 face))) - (set-face-attribute 'org-table nil - :font "Jetbrains Mono" - :weight 'normal - :height 1.0 - :foreground "#A66CFF")) - -(defun apollo/org-theme-dracula () - "Enable Dracula theme for Org headers." - (interactive) - (dolist - (face - '((org-level-1 1.7 "#8be9fd" ultra-bold) - (org-level-2 1.6 "#bd93f9" extra-bold) - (org-level-3 1.5 "#50fa7b" bold) - (org-level-4 1.4 "#ff79c6" semi-bold) - (org-level-5 1.3 "#9aedfe" normal) - (org-level-6 1.2 "#caa9fa" normal) - (org-level-7 1.1 "#5af78e" normal) - (org-level-8 1.0 "#ff92d0" normal))) - (set-face-attribute (nth 0 face) nil - :font "JetBrains Mono" - :weight (nth 3 face) - :height (nth 1 face) - :foreground (nth 2 face))) - (set-face-attribute 'org-table nil - :font "JetBrains Mono" - :weight 'normal - :height 1.0 - :foreground "#bfafdf")) - -(defun apollo/org-mode-visual () - (interactive) - (setq visual-fill-column-width 100 - visual-fill-column-center-text t) - (visual-fill-column-mode 1)) -(defun apollo/org-mode-visual-undo () - (interactive) - (setq visual-fill-column-width 2000 - visual-fill-column-center-text nil) - (visual-fill-column-mode 1)) - -(defadvice org-edit-src-code (around set-buffer-file-name activate compile) - (let ((file-name (buffer-file-name))) ;; (1) - ad-do-it ;; (2) - (setq buffer-file-name file-name))) ;; (3) - -(org-babel-do-load-languages - 'org-babel-load-languages - '((emacs-lisp . t) - (python . t))) - -(add-to-list 'org-structure-template-alist '("sh" . "src shell")) -(add-to-list 'org-structure-template-alist '("b" . "src shell")) -(add-to-list 'org-structure-template-alist '("el" . "src emacs-lisp")) -(add-to-list 'org-structure-template-alist '("py" . "src python")) - -;; Automatically tangle our Emacs.org config file when we save it -(defun apollo/org-babel-tangle-config () - (when (string-equal (buffer-file-name) - (expand-file-name "~/.emacs.d/emacs.org" - "~/.config/qtile/README.org")) - ;; Dynamic scoping to the rescue - (let ((org-confirm-babel-evaluate nil)) - (org-babel-tangle)))) - -(add-hook 'org-mode-hook (lambda () (add-hook 'after-save-hook #'apollo/org-babel-tangle-config))) - -(defun apollo/markdown-theme () - (interactive) - (dolist - (face - '(markdown-header-face-1 :height 2.0)))) - -(setq markdown-header-scaling t) - - -(use-package markdown-mode - :ensure t - :mode (".md" . gfm-mode) - :init (setq markdown-command "multimarkdown")) - diff --git a/Qtile.org b/Qtile.org new file mode 100644 index 0000000..1857fdf --- /dev/null +++ b/Qtile.org @@ -0,0 +1,536 @@ +#+TITLE: Qtile Configuration +#+auto_tangle: t +* Table of contents :toc: +- [[#colors][Colors]] +- [[#base][Base]] +- [[#keys][Keys]] + +* Colors +#+begin_src python :tangle .config/qtile/colors.py + """ + My Favorite Color Themes For Qtile | + + Feel free to change them as you like + """ + + # Dracula theme + dracula = { + "bg": "#282a36", + "fg": "#f8f8f2", + "curr": "#44475a", + "cyan": "#8be9fd", + "green": "#50fa7b", + "orange": "#ffb86c", + "purple": "#bd93f9", + "red": "#ff5555", + } + + # Gruvbox theme + gruvbox = { + 'bg': '#282828', + 'fg': '#d4be98', + 'dark-red': '#ea6962', + 'red': '#ea6962', + 'dark-green': '#a9b665', + 'green': '#a9b665', + 'dark-yellow': '#e78a4e', + 'yellow': '#d8a657', + 'dark-blue': '#7daea3', + 'blue': '#7daea3', + 'dark-magenta': '#d3869b', + 'magenta': '#d3869b', + 'dark-cyan': '#89b482', + 'cyan': '#89b482', + 'dark-gray': '#665c54', + 'gray': '#928374', + + 'fg4': '#766f64', + 'fg3': '#665c54', + 'fg2': '#504945', + 'fg1': '#3c3836', + 'bg0': '#32302f', + 'fg0': '#1d2021', + 'fg9': '#ebdbb2' + } + + # Custom version of arcolinux theme + my_colors = { + "black": "#000000", + "black2": "#2F343F", + "blue": "#3384d0", + "red": "#ff0000", + "grey": "#a9a9a9", + "grey2": "#C0C5CE", + "cyan": "#6790EB", + "green": "#62FF00", + "white": "#F3F4F5", + "orange": "#FBA922", + } +#+end_src +* Base +#+begin_src python :tangle .config/qtile/config.py + """Configuration for qtile.""" + + import os + import subprocess + from libqtile import layout, bar, widget, hook + from libqtile.config import Group, Screen + from libqtile.dgroups import simple_key_binder + from keys import MyKeys + from colors import dracula + + + @hook.subscribe.startup_once + def start_once(): + """Set your autostart script.""" + autostart_path = os.path.expanduser('~/.config/autostart/autostart.sh') + subprocess.run([autostart_path]) + + + # Keybindings + my_keys = MyKeys() + + keys = my_keys.init_keys() + + # Use this to change between workspaces + dgroups_key_binder = simple_key_binder("mod4") + + mouse = my_keys.init_mouse() + + # Groups and layouts + groups = [] + group_names = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", ] + group_labels = ["Ⅰ", "Ⅱ", "Ⅲ", "Ⅳ", "Ⅴ", "Ⅵ", "Ⅶ", "Ⅷ", "Ⅸ", "Ⅹ", ] + group_layouts = ["monadtall", "monadtall", "monadtall", "monadtall", + "monadtall", "monadtall", "monadtall", "monadtall", + "monadtall", "monadtall", ] + + for i in range(len(group_names)): + groups.append( + Group( + name=group_names[i], + layout=group_layouts[i].lower(), + label=group_labels[i], + )) + + + def init_layout_theme(): + """Layout default theme.""" + return {"margin": 5, + "border_width": 2, + "border_focus": dracula["cyan"], + "border_normal": dracula["bg"], + } + + + layout_theme = init_layout_theme() + + + layouts = [ + layout.MonadTall(**layout_theme), + # layout.MonadWide(**layout_theme), + # layout.Matrix(**layout_theme), + # layout.Bsp(**layout_theme), + layout.Floating(**layout_theme), + # layout.RatioTile(**layout_theme), + # layout.Max(**layout_theme), + # layout.Spiral(**layout_theme), + layout.TreeTab(bg_color=dracula["bg"], + active_bg=dracula["purple"], + active_fg=dracula["fg"], + inactive_fg=dracula["fg"], + inactive_bg=dracula["bg"], + font="JetBrains Mono", + fontshadow=None, + section_fontsize=14, + panel_width=135,), + # layout.Zoomy(**layout_theme), + ] + + # Widgets + + + def init_widgets_defaults(): + """Set widget default settings.""" + return dict(font="JetBrains Mono", + fontsize=12, + padding=2, + foreground=dracula["fg"], + background=dracula["bg"] + ) + + + widget_defaults = init_widgets_defaults() + + + def init_widgets_list(): + """My widget list.""" + widgets_list = [ + widget.Spacer( + length=7, + ), + widget.Image( + filename="~/.config/qtile/rms.png", + scale="True", + margin=2, + ), + widget.Spacer( + length=7, + ), + widget.GroupBox( + font="FontAwesome", + fontsize=20, + padding=3, + margin=4, + borderwidth=1, + active=dracula["cyan"], + inactive=dracula["curr"], + rounded=False, + highlight_method="line", + this_current_screen_border=dracula["red"], + other_current_screen_border=dracula["curr"], + ), + widget.CurrentLayout( + font="Noto Sans Bold", + foreground=dracula["fg"], + background="#5B4B8A", + ), + widget.Spacer( + length=5 + ), + widget.WindowName( + font="JetBrains Mono Bold", + fontsize=12, + foreground=dracula["green"], + background=dracula["bg"], + ), + # widget.Image( + # filename = "~/.config/qtile/spotify2.png", + # scale = True, + # ), + # Spotify( + # fontsize = 12, + # background = dracula["bg"], + # color = dracula["green"], + # fmt = '{}', + # font = "JetBrains Mono Bold" + # ), + # widget.Moc( + # font = "JetBrains Mono", + # fontsize= 13, + # play_color=dracula["green"], + # paddig = 10, + # ), + widget.Pomodoro( + color_active=dracula["cyan"], + color_break=dracula["orange"], + color_inactive=dracula["curr"], + lenghth_pomodori=30, + fontsize=17, + ), + widget.Spacer( + length=10, + ), + widget.Image( + filename="~/.config/qtile/volume1.png", + scale=True, + ), + widget.Spacer( + length=7, + padding=10, + ), + widget.Volume( + fontsize=15, + fmt='{} ', + background=dracula["bg"], + foreground=dracula['orange'], + font="JetBrains Mono", + margin=10, + ), + # widget.Mpris2( + # fontsize= 16, + # background = my_colors["red"], + # objname="org.mpris.MediaPlayer2.spotify" + # ), + widget.Spacer( + length=7, + padding=10, + ), + widget.Image( + filename="~/.config/qtile/ram2.png", + scale=True, + ), + widget.Memory( + measure_mem="G", + fontsize=15, + foreground=dracula["cyan"], + background=dracula["bg"], + font='JetBrains Mono Bold', + ), + widget.MemoryGraph( + type='box', + graph_color=dracula["cyan"], + foreground=dracula["fg"], + background=dracula["bg"], + ), + widget.Spacer( + length=7 + ), + widget.Image( + filename="~/.config/qtile/cpu1.png", + scale=True, + ), + widget.ThermalSensor( + threshold=50, + fontsize=15, + font='JetBrains Mono Bold', + foreground=dracula["cyan"], + background=dracula["bg"], + ), + widget.CPUGraph( + type='box', + graph_color=dracula["cyan"], + background=dracula["bg"], + ), + widget.Spacer( + length=5 + ), + widget.TextBox( + font="FontAwesome", + text=" ", + foreground=dracula["orange"], + background=dracula["bg"], + padding=2, + fontsize=18 + ), + widget.Clock( + font='JetBrains Mono Bold', + foreground=dracula["cyan"], + background=dracula["bg"], + fontsize=18, + format="%d-%m-%Y | %H:%M" + ), + widget.Spacer( + length=6 + ), + widget.Systray( + background=dracula["bg"], + icon_size=20, + padding=10, + margin=10, + ), + widget.Spacer( + length=5 + ), + ] + return widgets_list + + + widgets_list = init_widgets_list() + + + def init_widgets_screen1(): + """Init every widget for primary screen.""" + widgets_screen1 = init_widgets_list() + return widgets_screen1 + + + def init_widgets_screen2(): + """Remove systray and spacer for second screen.""" + widgets_screen2 = init_widgets_list() + return widgets_screen2[:-2] + + + widgets_screen1 = init_widgets_screen1() + widgets_screen2 = init_widgets_screen2() + + + def init_screens(): + """Panel settings.""" + return [Screen(top=bar.Bar(widgets=init_widgets_screen1(), size=33, + margin=11),), + Screen(top=bar.Bar(widgets=init_widgets_screen2(), size=28, + margin=7))] + + + screens = init_screens() + follow_mouse_focus = True + bring_front_click = False + cursor_warp = True + auto_fullscreen = True + focus_on_window_activation = "smart" # or focus + wmname = "Qtile-Apo11o" +#+end_src + +* Keys +#+begin_src python :tangle .config/qtile/keys.py + from libqtile.config import Key + from libqtile.command import lazy + from libqtile.config import Click, Drag + + + class MyKeys(): + """ + Emacs-like keybindings for qtile + I prefer having my keys seperated so I won't mess anything up, + especially if you are running the same config in different machines + """ + + def __init__(self): + """ + Default customization + """ + self.mod = "mod4" + self.browser = "firefox" + self.term = "emacsclient -c" + self.editor = "emacsclient -c -a 'emacs'" + + def init_keys(self): + """ + Keyboard keybindings | Emacs-like | Set them and forget them. + + I'm used to having the superkey to control my window manager, + and control for my emacs. + """ + my_keys = [ + Key([self.mod], "Return", + lazy.spawn(self.term), + ), + Key([self.mod, "shift"], "a", + lazy.spawn('anki'), + ), + Key([self.mod, "shift"], "m", + lazy.spawn("spotify"), + ), + Key([self.mod], "Tab", + lazy.spawn("rofi -show drun"), + ), + Key([self.mod], "r", + lazy.spawn("rofi -show run"), + ), + Key([self.mod], "w", + lazy.spawn("rofi -show window"), + ), + Key([self.mod], "p", + lazy.spawn("passmenu -p 'Password for: '"), + ), + Key([self.mod], "b", + lazy.spawn(self.browser), + ), + Key([self.mod, "shift"], "c", + lazy.next_layout(), + ), + Key([self.mod], "q", + lazy.window.kill(), + ), + Key([self.mod, "shift"], "r", + lazy.restart(), + ), + Key([self.mod, "shift"], "0", + lazy.shutdown(), + ), + Key([self.mod, "shift"], "e", + lazy.spawn(self.editor), + ), + # Switch focus of monitors + Key([self.mod], "period", + lazy.next_screen(), + ), + # Treetab controls + Key([self.mod, "shift"], "h", + lazy.layout.move_left(), + ), + Key([self.mod, "shift"], "l", + lazy.layout.move_right(), + ), + # Window controls + Key([self.mod], "n", + lazy.layout.down(), + ), + Key([self.mod], "p", + lazy.layout.up(), + ), + Key([self.mod, "shift"], "n", + lazy.layout.shuffle_down(), + lazy.layout.section_down(), + ), + Key([self.mod, "shift"], "p", + lazy.layout.shuffle_up(), + lazy.layout.section_up(), + ), + Key([self.mod], "s", + lazy.layout.shrink(), + lazy.layout.decrease_nmaster(), + ), + Key([self.mod], "l", + lazy.layout.grow(), + lazy.layout.increase_nmaster(), + ), + Key([self.mod], "o", + lazy.layout.normalize(), + ), + Key([self.mod], "m", + lazy.layout.maximize(), + ), + Key([self.mod, "shift"], "f", + lazy.window.toggle_floating(), + ), + Key([self.mod], "f", + lazy.window.toggle_fullscreen(), + ), + # Stack controls + Key([self.mod, "shift"], "Tab", + lazy.layout.rotate(), + lazy.layout.flip(), + ), + Key([self.mod, "shift"], "space", + lazy.layout.toggle_split(), + ), + # Volume controls + Key([], "XF86AudioLowerVolume", + lazy.spawn('amixer sset Master 5%-'), + ), + Key([], "XF86AudioRaiseVolume", + lazy.spawn('amixer sset Master 5%+'), + ), + # I use mod+F[key] to change volume in my thinkpad, + # as I dislike using "fn" key in laptops + Key([self.mod], "F11", + lazy.spawn('amixer sset Master 5%-'), + ), + Key([self.mod], "F12", + lazy.spawn('amixer sset Master 5%+'), + ), + # Music controls | MOC + Key([self.mod], "u", + lazy.spawn("mocp -G "), + ), + Key([self.mod], "o", + lazy.spawn("mocp -f"), + ), + Key([self.mod], "i", + lazy.spawn("mocp -r"), + ), + # Change languages + Key([self.mod], "F1", + lazy.spawn("setxkbmap us -option ctrl:swapcaps"), + ), + Key([self.mod], "F2", + lazy.spawn("setxkbmap gr"), + ), + ] + + return my_keys + + def init_mouse(self): + """Mouse keys | cause sometimes we have to use the mouse.""" + mouse_keys = [ + Drag([self.mod], "Button1", lazy.window.set_position_floating(), + start=lazy.window.get_position()), + Drag([self.mod], "Button3", lazy.window.set_size_floating(), + start=lazy.window.get_size()), + Click([self.mod], "Button2", + lazy.window.bring_to_front()), + ] + return mouse_keys +#+end_src @@ -12,14 +12,13 @@ Personal dotfiles, managed with GNU stow I use this repo to keep my configurations synchronized across different machines. Including a macOS laptop. - - * Contents + [[file:.emacs.d/emacs.org][Emacs]] + [[file:shells.org][Shells]] - -/Qtile with vanilla emacs/ - [[file:pictures/showcase.png]] ++ [[file:Qtile.org][Qtile]] + +/Qtile with emacs/ + [[file:pictures/showcase2.png]] * Installation + clone repository diff --git a/pictures/showcase2.png b/pictures/showcase2.png Binary files differnew file mode 100644 index 0000000..e13539f --- /dev/null +++ b/pictures/showcase2.png |