summaryrefslogtreecommitdiff
path: root/emacs.org
blob: 5d06ae6c5b99dc9b2108810ffc9e25962e658803 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
#+TITLE: Emacs Configuration
#+AUTHOR: Thanos Apollo
#+PROPERTY: header-args :tangle ~/.emacs.d/init.el :mkdirp yes
#+auto_tangle: t
#+STARTUP: overview

* System information
Check the ~$HOSTNAME~ to set a variable for different devices
#+begin_src emacs-lisp
  (defvar is-zeus (equal (system-name) "zeus"))
  (defvar is-hermes (equal (system-name) "hermes"))
  (defvar is-phone (equal (system-name) "localhost"))
#+end_src
Setup default browser as ~mullvad-browser~
#+begin_src emacs-lisp
  (setq browse-url-browser-function 'browse-url-generic
	browse-url-generic-program "mullvad-browser")
#+end_src
Set backup fails at ~~/Trash~
#+begin_src emacs-lisp
  (setq backup-directory-alist '((".*" . "~/.Trash")))
#+end_src
Define essential keybindings 
#+begin_src emacs-lisp
  (define-prefix-command 'thanos/applications-map)
  (global-set-key (kbd "C-c a") 'thanos/applications-map)

  (define-prefix-command 'Create)
  (define-key thanos/applications-map (kbd "C-c") 'Create)

  (global-set-key (kbd "<escape>") 'keyboard-escape-quit)
#+end_src
* Setting up Packages
** List of required packages
Request the following packages:
#+begin_src emacs-lisp
  (defconst my-package-list '(emms
			      tree-sitter
			      org-snooze
			      org-drill
			      all-the-icons
			      all-the-icons-dired
			      all-the-icons-ivy-rich
			      dap-mode
			      toc-org
			      emojify
			      doom-themes
			      gruvbox-theme
			      doom-modeline
			      counsel
			      vterm
			      multi-vterm
			      which-key
			      ivy
			      ivy-rich
			      helpful
			      password-store
			      org
			      org-modern
			      org-roam
			      visual-fill-column
			      rainbow-delimiters
			      flycheck
			      lsp-mode
			      lsp-ui
			      json-mode
			      rjsx-mode
			      typescript-mode
			      python-mode
			      pyvenv
			      company
			      company-box
			      magit
			      elfeed
			      elfeed-goodies
			      paredit
			      corfu
			      monkeytype
			      sudo-edit
			      consult
			      alsamixer
			      simple-httpd
			      eshell-syntax-highlighting
			      org-superstar
			      pdf-tools
			      org-auto-tangle
			      sly
			      chatgpt
			      org-download
			      eshell-git-prompt
			      eshell-vterm
			      hackernews
			      circe))
#+end_src
** Installation & activation
Set ~package-archives~, and install packages
#+begin_src emacs-lisp
  (setq package-archives '(("melpa" . "https://melpa.org/packages/")
			   ("org" . "https://orgmode.org/elpa/")
			   ("elpa" . "https://elpa.gnu.org/packages/")
			   ("jcs-elpa" . "https://jcs-emacs.github.io/jcs-elpa/packages/")))
  ; Activate all the packages
  (package-initialize)

  ; Fetch the list of packages available 
  (unless package-archive-contents
    (package-refresh-contents))

  ; Install the missing packages
  (dolist (package my-package-list)
    (unless (package-installed-p package)
      (package-install package)))

  ;; Set and load custom.el
  (setq custom-file (concat user-emacs-directory "custom.el"))
  (load custom-file 'noerror)
#+end_src

* UI Settings
** Basic UI
Fonts and basic appearance settings for each device
#+begin_src emacs-lisp
  (setq inhibit-startup-message t)
  (setq initial-scratch-message nil)
  ;; Transparency
  (set-frame-parameter (selected-frame) 'alpha '(90 95))
  (add-to-list 'default-frame-alist '(alpha 90 90))

  (add-hook 'dired-mode-hook 'all-the-icons-dired-mode)


  (if is-zeus
      (display-battery-mode 0)
    (display-battery-mode 1))

  (when (equal is-phone nil)
      (scroll-bar-mode -1)
      (set-fringe-mode 10))

  (tool-bar-mode -1)
  (tooltip-mode -1)
  (menu-bar-mode -1)
  (which-key-mode 1)
  (blink-cursor-mode -1)
  (menu-bar--visual-line-mode-enable)
  (global-visual-line-mode 1)

  (require 'emojify)
  (if (version< emacs-version "29")
      (setq global-emojify-mode 1)
    (setq global-emojify-mode 0))

  (setq visible-bell t)


  (column-number-mode)
  (global-display-line-numbers-mode 0)
  (menu-bar--display-line-numbers-mode-relative)
  ;;Disable line numbers for some modes
  (dolist (mode '(pdf-view-mode-hook
		  org-mode-hook
		  term-mode-hook
		  shell-mode-hook
		  eshell-mode-hook
		  vterm-mode-hook
		  elfeed))
    (add-hook mode (lambda () (display-line-numbers-mode 0))))

  (defvar thanos/default-font-size 140)
  (when is-hermes 
    (setq thanos/default-font-size 120))

  (set-face-attribute 'default nil
		      :font "JetBrains Mono"
		      :height thanos/default-font-size)

  (set-face-attribute 'fixed-pitch nil
		      :font "JetBrains Mono"
		      :height thanos/default-font-size)

  (set-face-attribute 'variable-pitch nil
		      :font "JetBrains Mono"
		      :height thanos/default-font-size
		      :weight 'regular)

#+end_src
** Theme & modeline
#+begin_src emacs-lisp
  (load-theme 'doom-old-hope t)
  (doom-modeline-mode 1)

  (setq doom-modeline-height 35)
#+end_src
** Ivy
#+begin_src emacs-lisp
  (require 'ivy)

  (ivy-mode 1)
  ;(setq ivy-use-virtual-buffers t)
  ;(setq enable-recursive-minibuffers t)
  (global-set-key (kbd "C-s") 'swiper)
  (define-key ivy-minibuffer-map (kbd "TAB") 'ivy-alt-done)
  (global-set-key "\C-s" 'swiper)
  (global-set-key (kbd "C-c C-r") 'ivy-resume)
  (global-set-key (kbd "<f6>") 'ivy-resume)
  (global-set-key (kbd "M-x") 'counsel-M-x)
  (global-set-key (kbd "C-x C-f") 'counsel-find-file)
  (global-set-key (kbd "<f1> f") 'counsel-describe-function)
  (global-set-key (kbd "<f1> v") 'counsel-describe-variable)
  (global-set-key (kbd "<f1> o") 'counsel-describe-symbol)
  (global-set-key (kbd "<f1> l") 'counsel-find-library)
  (global-set-key (kbd "<f2> i") 'counsel-info-lookup-symbol)
  (global-set-key (kbd "<f2> u") 'counsel-unicode-char)
  (global-set-key (kbd "C-c g") 'counsel-git)
  (global-set-key (kbd "C-c j") 'counsel-git-grep)
  (global-set-key (kbd "C-c k") 'counsel-ag)
  (global-set-key (kbd "C-x l") 'counsel-locate)
  (global-set-key (kbd "C-S-o") 'counsel-rhythmbox)
  (define-key minibuffer-local-map (kbd "C-r") 'counsel-minibuffer-history)

  (ivy-rich-mode 1)
  (all-the-icons-ivy-rich-mode 1)

  (setq ivy-use-selectable-prompt t)

  (global-set-key (kbd "C-c m") 'consult-imenu)
  (define-key thanos/applications-map (kbd "t") 'counsel-load-theme)
#+end_src
** Helpful
#+begin_src emacs-lisp
  (require 'helpful)
  (global-set-key (kbd "C-h f") #'helpful-callable)
  (global-set-key (kbd "C-h v") #'helpful-variable)
  (global-set-key (kbd "C-h k") #'helpful-key)
  (global-set-key (kbd "C-h x") #'helpful-command)

  (global-set-key (kbd "C-c C-d") #'helpful-at-point)
  (global-set-key (kbd "C-h F") #'helpful-function)

  (setq counsel-describe-function-function #'helpful-callable)
  (setq counsel-describe-variable-function #'helpful-variable)
#+end_src
* Pass
** Keybindings
#+begin_src emacs-lisp
  (global-set-key (kbd "C-c p i") 'password-store-insert)
  (global-set-key (kbd "C-c p e") 'password-store-edit)
  (global-set-key (kbd "C-c p g") 'password-store-generate)
#+end_src
* Dired
** Functions
#+begin_src emacs-lisp
  (defun dired-watch-video ()
    (interactive)
    (async-shell-command (format "mpv \"%s\"" (dired-get-filename))))
#+end_src
** Keybindings
#+begin_src emacs-lisp
  (require 'dired)
  (define-key dired-mode-map "b" 'dired-up-directory)
#+end_src
** All-the-icons
#+begin_src emacs-lisp
(add-hook 'dired-mode-hook 'all-the-icons-dired-mode)
#+end_src
* Org
** Org-Roam
#+begin_src emacs-lisp
  ;; Create ~/Notes, ignore errors if it's already made
  (ignore-error (make-directory "~/Notes"))

  (setq org-roam-directory "~/Notes"
	org-roam-dailies-directory "journal/")

  (org-roam-db-autosync-enable)
#+end_src
*** Keybindings
#+begin_src emacs-lisp
  ;; Set maps
  (define-prefix-command 'thanos/notes)
  (global-set-key (kbd "C-c n") 'thanos/notes)
  ;; org-roam keys
  (define-key thanos/notes (kbd "t") 'org-roam-buffer-toggle)
  (define-key thanos/notes (kbd "f") 'org-roam-node-find)
  (define-key thanos/notes (kbd "i") 'org-roam-node-insert)
  ;; Journaling
  (define-prefix-command 'Journal)
  (define-key thanos/notes (kbd "j") 'Journal)
  (define-key Journal (kbd "d") 'Journaling/dailies)
  (define-key Journal (kbd "C-c") 'org-roam-dailies-capture-today)
  (define-key Journal (kbd "C-t") 'org-roam-dailies-capture-tomorrow)
  (define-key Journal (kbd "C-y") 'org-roam-dailies-capture-yesterday)
  (define-key Journal (kbd "c") 'org-roam-dailies-goto-today)
  (define-key Journal (kbd "t") 'org-roam-dailies-goto-tomorrow)
  (define-key Journal (kbd "y") 'org-roam-dailies-goto-yesterday)
#+end_src
*** Templates
#+begin_src emacs-lisp
  (setq org-roam-capture-templates
	'(("d" "default" plain
	   "%?"
	   :if-new (file+head "%<%Y%m%d%H%M%S>-${slug}.org" "#+title: ${title}\n")
	   :unnarrowed t)
	  ("l" "programming language" plain
	   "* Characteristics\n\n- Family: %?\n- Inspired by: \n\n* Reference:\n\n"
	   :if-new (file+head "%<%Y%m%d%H%M%S>-${slug}.org" "#+title: ${title}\n")
	   :unnarrowed t)
	  ("p" "MUS" plain "* Goals\n\n%?\n\n* Tasks\n\n** TODO Add initial tasks\n\n* Dates\n\n"
	   :if-new (file+head "%<%Y%m%d%H%M%S>-${slug}.org" "#+title: ${title}\n#+filetags: MUS")
	   :unnarrowed t)))
  ;; Dailies
  (setq org-roam-dailies-capture-templates
	'(("d" "default" entry
	   "* %?"
	   :target (file+head "%<%Y-%m-%d>.org"
			      "#+title: %<%Y-%m-%d>\n"))
	  ("j" "Daily Journaling" entry
	   (file "~/org/Templates/journaling.org")
	   :target (file+head "%<%Y-%m-%d>.org"
			      "#+title: %<%Y-%m-%d>\n"))
	  ("i" "Improve" entry
	   (file "~/org/Templates/improve.org")
	   :target (file+head "%<%Y-%m-%d>.org"
			      "#+title: %<%Y-%m-%d>\n"))))
#+end_src
** Themes
*** Dracula
#+begin_src emacs-lisp
(defun thanos/org-theme-dracula ()
  "Enable Dracula theme for Org headers."
  (interactive)
  (dolist
      (face
       '((org-level-1 1.7 "#8be9fd" extra-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"))
#+end_src
*** Darkone
#+begin_src emacs-lisp
(defun thanos/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"))
#+end_src
*** Gruvbox
#+begin_src emacs-lisp
  (defun thanos/org-theme-gruvbox ()
    "Enable Darkone theme for Org headers."
    (interactive)
    (dolist
	(face
	 '((org-level-1 1.70 "#fb4934" bold)
	   (org-level-2 1.55 "#98971a" bold)
	   (org-level-3 1.40 "#458588" bold)
	   (org-level-4 1.20 "#b16286" semi-bold)
	   (org-level-5 1.20 "#689d6a" normal)
	   (org-level-6 1.20 "#d3869b" normal)
	   (org-level-7 1.10 "#8ec07c" normal)
	   (org-level-8 1.00 "#ebdbb2" 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"))
#+end_src
*** Org Modern
#+begin_src emacs-lisp
  (modify-all-frames-parameters
   '((right-divider-width . 5)
     (internal-border-width . 5)))
  (dolist (face '(window-divider
                  window-divider-first-pixel
                  window-divider-last-pixel))
    (face-spec-reset-face face)
    (set-face-foreground face (face-attribute 'default :background)))
  (set-face-background 'fringe (face-attribute 'default :background))

  (setq
   ;; Edit settings
   org-auto-align-tags nil
   org-tags-column 0
   org-catch-invisible-edits 'show-and-error
   org-special-ctrl-a/e t
   org-insert-heading-respect-content t

   ;; Org styling, hide markup etc.
   org-hide-emphasis-markers t
   org-pretty-entities t

   ;; Agenda styling
   org-agenda-tags-column 0
   org-agenda-block-separator ?─
   org-agenda-time-grid
   '((daily today require-timed)
     (800 1000 1200 1400 1600 1800 2000)
     " ┄┄┄┄┄ " "┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄")
   org-agenda-current-time-string
   "⭠ now ─────────────────────────────────────────────────")

  (global-org-modern-mode)
#+end_src
** Settings
#+begin_src emacs-lisp
  (require 'ox-md nil t)
  (require 'org-download)
  (require 'org-drill)

  (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-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)
#+end_src
~Keybindings:~
  #+begin_src emacs-lisp
  (define-key org-mode-map (kbd "C-c t") 'org-time-stamp-inactive)
  (define-key org-mode-map (kbd "C-c s") 'org-download-screenshot)
  #+end_src
~Hooks~
#+begin_src emacs-lisp
  (add-hook 'org-mode-hook 'thanos/org-theme-gruvbox)
  (add-hook 'org-mode-hook 'flyspell-mode)
  (add-hook 'org-mode-hook 'toc-org-mode)
#+end_src
** Babel
#+begin_src emacs-lisp
  (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)))


  (setq org-structure-template-alist
	'(("e" . "src emacs-lisp")
	  ("p" . "src python")
	  ("l" . "src lisp")
	  ("b" . "src bash")
	  ("q" . "QUOTE")))

  ;;Auto tangle
  (add-hook 'org-mode-hook 'org-auto-tangle-mode)
#+end_src
** Org-download
#+begin_src emacs-lisp
  (when (or (eq is-zeus t)
	    (eq is-hermes t))
    (setq org-download-screenshot-method "grim -g \"$(slurp)\" %s"))
#+end_src
** Org-drill
#+begin_src emacs-lisp
  (when is-zeus
    (load-file "~/Developer/org-drill/org-drill.el"))
  (setq org-drill-spaced-repetition-algorithm 'sm2
	org-drill-learn-fraction 0.45
	org-drill-maximum-items-per-session nil)
#+end_src
* Markdown
** Theme
#+begin_src emacs-lisp
(defun thanos/markdown-theme ()
  (interactive)
  (dolist
      (face
       '(markdown-header-face-1 :height 2.0))))
#+end_src
** Settings
#+begin_src emacs-lisp
  (require 'markdown-mode)
  (setq markdown-header-scaling t)
  (add-to-list 'auto-mode-alist '("\\.md\\'" . gfm-mode))
  (setq markdown-command "multimarkdown")
#+end_src
* Programming
** Essentials
#+begin_src emacs-lisp
  (electric-pair-mode 1)
  (global-flycheck-mode)
  (global-set-key (kbd "M-.") 'xref-find-definitions)
  (global-set-key (kbd "C-c l") 'display-line-numbers-mode)

  (require 'company)
  (add-hook 'after-init-hook 'global-company-mode)
  (define-key company-active-map (kbd "TAB") 'company-indent-or-complete-common)
  (setq company-idle-delay
	(lambda () (if (company-in-string-or-comment) nil 0.0)))

  (require 'company-box)
  (add-hook 'company-mode-hook 'company-box-mode)

  (require 'dap-mode)
  (dap-ui-mode)
#+end_src
*** Magit
#+begin_src emacs-lisp
  (require 'magit)
#+end_src
** Emacs lisp
#+begin_src emacs-lisp
  (setq tab-always-indent 'complete)
  (add-to-list 'completion-styles 'initials t)

  (add-hook 'emacs-lisp-mode-hook #'rainbow-delimiters-mode)
  (add-hook 'emacs-lisp-mode-hook #'company-mode)
  (add-hook 'emacs-lisp-mode-hook #'display-line-numbers-mode)
#+end_src
** Common Lisp
#+begin_src emacs-lisp
  (setq inferior-lisp-program "sbcl")
  (add-hook 'lisp-mode-hook #'rainbow-delimiters-mode)
  (add-hook 'lisp-mode-hook #'company-mode)
  (add-hook 'lisp-mode-hook #'display-line-numbers-mode)
#+end_src
** LSP
#+begin_src emacs-lisp
  (defun thanos/lsp-mode-setup ()
    (setq lsp-headerline-breadcrumb-segments '(path-up-to-project file symbols))
    (lsp-headerline-breadcrumb-mode))

  (require 'lsp-mode)
  (add-hook 'lsp-mode #'thanos/lsp-mode-setup)
  (setq lsp-keymap-prefix "C-c l")
  (lsp-enable-which-key-integration t)

  (require 'lsp-ui)
  (add-hook 'lsp-mode 'lsp-ui-mode)
  (setq lsp-ui-doc-position 'bottom)
#+end_src
** Python
#+begin_src emacs-lisp
  ;; set pylsp with lsp-mode
  (setq lsp-pyls-server-command "~/.local/bin/pylsp")

  (require 'python-mode)
  (add-to-list 'auto-mode-alist '("\\.py\\'" . python-mode))
  (add-hook 'python-mode 'lsp-deferred)
#+end_src
** JSON
#+begin_src emacs-lisp
  (require 'json-mode)
  (add-to-list 'auto-mode-alist '("\\.json'" . json-mode))
#+end_src
* Elfeed
** Feeds
#+begin_src emacs-lisp
  (require 'elfeed)
  (require 'elfeed-goodies)
  (setq elfeed-feeds '(("https://hackaday.com/blog/feed/"
			hackaday linux)
		       ("https://protesilaos.com/news.xml"
			protesilaos)
		       ("https://protesilaos.com/codelog.xml"
			proetesilaos)
		       ("https://guix.gnu.org/feeds/blog.atom"
			gnu guix)
		       ("https://thanosapollo.com/posts/index.xml"
			thanos)
		       ("http://nullprogram.com/feed/"
			emacs linux)
		       ("https://drewdevault.com/blog/index.xml"
			sourcehut drewdevault)
		       ("https://spacepub.space/feeds/videos.xml?videoChannelId=2"
			drewdevault youtube)
		       ("https://www.youtube.com/feeds/videos.xml?channel_id=UCVls1GmFKf6WlTraIb_IaJg"
			video dt)
		       ("https://www.youtube.com/feeds/videos.xml?channel_id=UC7YOGHUfC1Tb6E4pudI9STA"
			video mental)
		       ("https://www.youtube.com/feeds/videos.xml?channel_id=UCAiiOTio8Yu69c3XnR7nQBQ"
			video daviwil)
		       ("https://videos.lukesmith.xyz/feeds/videos.atom?sort=-publishedAt&isLocal=true"
			video luke)
		       ("https://www.youtube.com/feeds/videos.xml?channel_id=UCrc2iv2-G1FZ3VscM3zu2jg"
			video zoogirl)
		       ("https://www.youtube.com/feeds/videos.xml?channel_id=UC0uTPqBCFIpZxlz_Lv1tk_g"
			video prot)
		       ("https://www.youtube.com/feeds/videos.xml?channel_id=UCq6VFHwMzcMXbuKyG7SQYIg"
			video moist)
		       ("https://www.youtube.com/feeds/videos.xml?channel_id=UC05XpvbHZUQOfA6xk4dlmcw"
			video djware)
		       ("https://archlinux.org/feeds/news/"
			ArchLinux Latest)
		       ("https://www.youtube.com/feeds/videos.xml?channel_id=UCsBjURrPoezykLs9EqgamOA"
			fireship video)
		       ("https://www.youtube.com/feeds/videos.xml?channel_id=UCl-J-ovSJhA3or73Q2uVpow"
			medicosperf video)
		       ("https://www.youtube.com/feeds/videos.xml?channel_id=UCSuHzQ3GrHSzoBbwrIq3LLA"
			naomi video)
		       ("https://www.youtube.com/feeds/videos.xml?channel_id=UCqYPhGiB9tkShZorfgcL2lA"
			WhatIveLearned video)
		       ("http://wikileaks.org/feed"
			wikileaks)
		       ("https://hackernoon.com/feed"
			hackernoon)
		       ("https://sachachua.com/blog/feed/"
			sacha emacs)
		       ("https://www.youtube.com/feeds/videos.xml?channel_id=UCtMVHI3AJD4Qk4hcbZnI9ZQ"
			video OrdinaeryGamers)
		       ("https://www.youtube.com/feeds/videos.xml?channel_id=UCl2mFZoRqjw_ELax4Yisf6w"
			video Louis)))
#+end_src
** Watch Videos
Create function to watch videos using ~mpv~
#+begin_src emacs-lisp
  (defun elfeed-v-mpv (url)
    "Watch a video from URL in MPV" 
    (async-shell-command (format "mpv \"%s\"" url)))

  (defun elfeed-view-mpv (&optional use-generic-p)
    "Youtube-feed link"
    (interactive "P")
    (let ((entries (elfeed-search-selected)))
      (cl-loop for entry in entries
	       do (elfeed-untag entry 'unread)
	       when (elfeed-entry-link entry) 
	       do (elfeed-v-mpv it)) 
      (mapc #'elfeed-search-update-entry entries) 
      (unless (use-region-p) (forward-line))))
#+end_src
** Settings & Keys
#+begin_src emacs-lisp
  (define-key elfeed-search-mode-map (kbd "v") 'elfeed-view-mpv)
  (define-key elfeed-search-mode-map (kbd "U") 'elfeed-update)
  (define-key thanos/applications-map (kbd "f") 'elfeed)

  (setq elfeed-goodies/entry-pane-size 0.55)
  (elfeed-goodies/setup)
#+end_src

* PDF
#+begin_src emacs-lisp

;;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)
(add-to-list 'auto-mode-alist '("\\.pdf\\'" . pdf-view-mode))
#+end_src
* mu4e 
** Setting up mail
#+begin_src emacs-lisp
  ;; Check if we have mu4e available
  ;; if t load mu4e settings
  (when (require 'mu4e nil 'noerror)
    (when is-zeus (setq mu4e-update-interval (* 10 60)))
    (setq mu4e-get-mail-command "mbsync -a")

    (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
	  '(("/Public/Inbox"             . ?i)
	    ("/Public/Sent" . ?s)
	    ))

    (setq mu4e-contexts
	  `(, (set-mu4e-context
	       "Public" "Thanos Apollo"
	       "[email protected]" "Thanos\nhttps://thanosapollo.com"
	       "mail.gandi.net")))

    (setq message-send-mail-function 'smtpmail-send-it
	  smtpmail-stream-type 'ssl))
#+end_src
** Actions
#+begin_src emacs-lisp
  (setq 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)))))
#+end_src
** Keybindings
#+begin_src emacs-lisp
  (define-key thanos/applications-map (kbd "m") 'mu4e)
#+end_src
* EMMS
#+begin_src emacs-lisp
  (emms-all)
  (setq emms-player-list '(emms-player-mpv)
	emms-player-mpv-parameters '("--no-video")
	emms-info-functions '(emms-info-native)
	emms-playlist-buffer-name "*Music*"
	emms-source-file-default-directory "~/Music/work-playlists")
#+end_src
** Keybindings
#+begin_src emacs-lisp
  (define-key 'thanos/applications-map (kbd "e") 'emms)
#+end_src
* Eshell
First let's set ~eshell-visual-commands~
+ This are commands cannot be displayed properly with ~eshell~ 
#+begin_src emacs-lisp
  (setq eshell-visual-commands '("mocp" "htop" "nvim"))
#+end_src
** Completions
#+begin_src emacs-lisp
  ;;;; sudo completion
  (defun pcomplete/sudo ()
    "Completion rules for the `sudo' command."
    (let ((pcomplete-ignore-case t))
      (pcomplete-here (funcall pcomplete-command-completion-function))
      (while (pcomplete-here (pcomplete-entries)))))

  ;;;; systemctl completion
  (defcustom pcomplete-systemctl-commands
    '("disable" "enable" "status" "start" "restart" "stop" "reenable"
      "list-units" "list-unit-files")
    "p-completion candidates for `systemctl' main commands"
    :type '(repeat (string :tag "systemctl command"))
    :group 'pcomplete)

  (defvar pcomplete-systemd-units
    (split-string
     (shell-command-to-string
      "(systemctl list-units --all --full --no-legend;systemctl list-unit-files --full --no-legend)|while read -r a b; do echo \" $a\";done;"))
    "p-completion candidates for all `systemd' units")

  (defvar pcomplete-systemd-user-units
    (split-string
     (shell-command-to-string
      "(systemctl list-units --user --all --full --no-legend;systemctl list-unit-files --user --full --no-legend)|while read -r a b;do echo \" $a\";done;"))
    "p-completion candidates for all `systemd' user units")

  (defun pcomplete/systemctl ()
    "Completion rules for the `systemctl' command."
    (pcomplete-here (append pcomplete-systemctl-commands '("--user")))
    (cond ((pcomplete-test "--user")
	   (pcomplete-here pcomplete-systemctl-commands)
	   (pcomplete-here pcomplete-systemd-user-units))
	  (t (pcomplete-here pcomplete-systemd-units))))

  ;;;; man completion
  (defvar pcomplete-man-user-commands
    (split-string
     (shell-command-to-string
      "apropos -s 1 .|while read -r a b; do echo \" $a\";done;"))
    "p-completion candidates for `man' command")

  (defun pcomplete/man ()
    "Completion rules for the `man' command."
    (pcomplete-here pcomplete-man-user-commands))

  ;; hut completion
  (defcustom pcomplete-hut-commands
    '("builds" "export" "git" "graphql" "lists" "help" "hg"
      "init" "meta" "pages" "paste" "todo")
    "p-completion candidates for `hut' main commands"
    :type '(repeat (string :tag "hut command"))
    :group 'pcomplete)

  (defun pcomplete/hut ()
    "Completion rules for `hut' command"
    (pcomplete-here (append pcomplete-hut-commands)))
#+end_src
** Aliases & Paths
Set aliases for ~~/.emacs.d/eshell/alias~ similarly that I would for a ~~/.bashrc~ file
#+begin_src fundamental :tangle ~/.emacs.d/eshell/alias
  alias ls ls -lah
  alias anki QTWEBENGINE_CHROMIUM_FLAGS="--disable-seccomp-filter-sandbox" anki
  alias b bluetoothctl
  alias ba bluetooth-autoconnect
  alias c pavucontrol
  alias ca config add
  alias cc config commit -m
  alias cpm config push -u origin master
  alias cs config status
  alias fanki flatpak run net.ankiweb.Anki
  alias ga git add
  alias gaa git add .
  alias gc git commit -m
  alias gp git push -u origin
  alias gpd git push -u origin developer
  alias gpm git push -u origin master
  alias grep grep --color=auto
  alias gs git status
  alias klight='brightnessctl --device \''tpacpi::kbd_backlight'\'' set 1
  alias logout pkill -U $USER
  alias music mocp
  alias mykeys setxkbmap -option caps:escape
  alias r ranger
  alias sb sudo systemctl start bluetooth
  alias sweb BROWSER="firefox" yarn start
  alias vi nvim
  alias vim nvim
  alias weather curl wttr.in
  alias yeet paru -Rsc
  alias ytd yt-dlp
#+end_src
Set aliases for emacs functions and ~PATH~
#+begin_src emacs-lisp
  (defvar eshell-path-env (getenv "~/.local/bin"))
  (defalias 'o 'find-file)
  (defalias 'oo 'find-file-other-window)
#+end_src
** Prompt
#+begin_src emacs-lisp
  (eshell-git-prompt-use-theme 'powerline)
  (eshell-syntax-highlighting-global-mode 1)

  (setq eshell-highlight-prompt t)
#+end_src
** Multi Eshell
#+begin_src emacs-lisp
  (defun if-void (arg default)
    (if (boundp arg)
	(eval arg)
      default
	))

  (defgroup multi-eshell nil
    "Simple support for having multiple shells open."
    :group 'languages)

  (defcustom multi-eshell-shell-function '(eshell)
    "Command called to create shell"
    :group 'multi-eshell)

  (defcustom multi-eshell-name "*eshell*" "The name of the buffer opened by the shell command."
    :type 'string
    :group 'multi-eshell)

  (defun multi-eshell-function () "This function opens the appropriate shell." (eval multi-eshell-shell-function) )
  ;;;(defvar multi-eshell-function `(shell) ) ;;; Defines the shell. ('shell) or ('eshell)
  ;(defvar multi-eshell-name "*eshell*") ;;; Name of default shell or eshell buffer

  (defvar multi-eshell-ring (make-ring 100) "This stores a bunch of buffers, which are shells created by multi-eshell." )
  (setq multi-eshell-index 0 )
  (defvar multi-eshell-last-buffer nil)

  (defun multi-eshell-is-current-buffer-current-multi-eshell (&optional ignored)
    "Checks if current buffer is the current multi-eshell."
    (eq (current-buffer) (ring-ref multi-eshell-ring multi-eshell-index))
  )

  (defun multi-eshell-switch-to-current-shell (&optional ignored)
    "Switch to shell buffer."
    (if (buffer-live-p (ring-ref multi-eshell-ring multi-eshell-index))
	(switch-to-buffer (ring-ref multi-eshell-ring multi-eshell-index))
      )
  )

  (defun multi-eshell-current-shell (&optional ignored)
    "Returns the current multi-eshell."
    (ring-ref multi-eshell-ring multi-eshell-index)
  )

  (defun multi-eshell-switch-to-next-live-shell (&optional ignored)
    "Switches to the next live shell. Creates one if none exists."
    (interactive "p")
    (let ((still-looking t)
	  (empty nil))
      (while (and still-looking (not empty))
	(if (ring-empty-p multi-eshell-ring)
	    (progn
	      (setq empty t)
	      (multi-eshell 1)
	      )
	  (progn
	    (if (buffer-live-p (ring-ref multi-eshell-ring multi-eshell-index))
		(progn
		  (setq multi-eshell-index (+ multi-eshell-index 1))
		  (switch-to-buffer (ring-ref multi-eshell-ring multi-eshell-index))
		  (setq still-looking nil)
		  )
	      (ring-remove multi-eshell-ring multi-eshell-index)
	      )
	    )
	  )
	)
      )
  )

  ;;;###autoload
  (defun multi-eshell-go-back (&optional ignored)
    "Switch to buffer multi-eshell-last-buffer."
    (interactive "p")
    (if (buffer-live-p multi-eshell-last-buffer)
	(switch-to-buffer multi-eshell-last-buffer)
      (message "Last buffer visited before multi-eshell is gone. Nothing to go back to..")
       ))


  ;;;###autoload
  (defun multi-eshell-switch (&optional ignored)
    "If current buffer is not an multi-eshell, switch to current multi-eshell buffer. Otherwise, switch to next multi-eshell buffer."
    (interactive "p")
    (progn
      (setq multi-eshell-last-buffer (current-buffer))
      (let ((still-looking t)
	    (empty nil))
	(if (ring-empty-p multi-eshell-ring)
	    (multi-eshell 1)
	  (if (and (buffer-live-p (multi-eshell-current-shell) )
	       (not (eq (multi-eshell-current-shell) (current-buffer))))
	  (switch-to-buffer (multi-eshell-current-shell))
	(multi-eshell-switch-to-next-live-shell)
	)
      )
    )))

  ;;;###autoload
  (defun multi-eshell (&optional numshells)
    "Creates a shell buffer. If one already exists, this creates a new buffer, with the name '*shell*<n>', where n is chosen by the function generate-new-buffer-name."
    (interactive "p")
    (progn
      (setq multi-eshell-last-buffer (current-buffer))
      (dotimes (i (if-void 'numshells 1) nil)
	(let ( (tempname (generate-new-buffer-name "*tempshell*"))
	       (new-buff-name (generate-new-buffer-name multi-eshell-name))
	       (localdir default-directory)
	       )
	  (if (eq (get-buffer multi-eshell-name) nil) ;If a
	      (progn
		(multi-eshell-function)
		;(process-send-string (get-buffer-process new-buff-name) (concat "cd " localdir "\n"))
		(ring-insert multi-eshell-ring (current-buffer) )
		(setq multi-eshell-index (+ multi-eshell-index 1))
		)
	    (progn
	      (interactive)
	      (multi-eshell-function)
	      (rename-buffer tempname)
	      (multi-eshell-function)
	      (rename-buffer new-buff-name )
	      (switch-to-buffer tempname)
	      (rename-buffer multi-eshell-name)
	  (switch-to-buffer new-buff-name)
	  ;(process-send-string (get-buffer-process new-buff-name) (concat "cd " localdir "\n"))
	  (ring-insert multi-eshell-ring (current-buffer) )
	  (setq multi-eshell-index (+ multi-eshell-index 1))
	  )
	    )
	  )
	)
      )
    )

  (defun shell-with-name (name)
    "Creates a shell with name given by the first argument, and switches to it. If a buffer with name already exists, we simply switch to it."
    (let ((buffer-of-name (get-buffer name))
	  (tempname (generate-new-buffer-name "*tempshell*") ) )
      (cond ((bufferp buffer-of-name) ;If the buffer exists, switch to it (assume it is a shell)
	     (switch-to-buffer name))
	    ( (bufferp (get-buffer multi-eshell-name))
	    (progn
	      (multi-eshell-function)
	      (rename-buffer tempname)
	      (multi-eshell-function)
	      (rename-buffer name)
	      (switch-to-buffer tempname)
	      (rename-buffer multi-eshell-name)
	      (switch-to-buffer name)))
	    ( t
	      (progn
		(multi-eshell-function)
		(rename-buffer name))))))
#+end_src
** Keybindings
#+begin_src emacs-lisp
  (define-prefix-command 'thanos/eshell-map)
  (global-set-key (kbd "C-c e") 'thanos/eshell-map)

  (define-key thanos/eshell-map (kbd "o") 'multi-eshell)
  (define-key thanos/eshell-map (kbd "n") 'multi-eshell-switch)
#+end_src
* Vterm
#+begin_src emacs-lisp
  (defvar thanos/vterm-map (make-sparse-keymap))
  (define-prefix-command 'thanos/vterm-map)
  (define-key global-map (kbd "C-c v") 'thanos/vterm-map)
  (define-key thanos/vterm-map (kbd "n") 'multi-vterm-next)
  (define-key thanos/vterm-map (kbd "p") 'multi-vterm-prev)
  (define-key thanos/vterm-map (kbd "d") 'multi-vterm-dedicated-open)
  (define-key thanos/vterm-map (kbd "o") 'multi-vterm)
#+end_src
* Circe
#+begin_src emacs-lisp
  (require 'circe)
  (setq circe-network-options
	`(("Libera Chat"
	   :tls t
	   :nick "thanosapollo"
	   :sasl-username "thanosapollo"
	   :sasl-password ,(password-store-get "liberachat/thanos_apollo")
	   :channels ("#emacs-circe"
		      "#emacs"
		      "#systemcrafters"))))
#+end_src
** Keybindings
#+begin_src emacs-lisp
  (define-key thanos/applications-map (kbd "i") 'circe)
#+end_src
* Chatgpt
#+begin_src emacs-lisp
  (setq openai-key (password-store-get "chatgpt/api"))
  (define-key 'thanos/applications-map (kbd "c") 'chatgpt)
#+end_src
* Misc
** Random functions
#+begin_src emacs-lisp
  (defun thanos/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))


  (defun thanos/rofi-switch-window ()
    "Navigate X11 buffers using rofi."
    (interactive)
    (start-process-shell-command
     "rofi" nil "rofi -show window"))

  (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 rofi ()
    "Run Rofi."
    (interactive)
    (thanos/run-in-background "rofi -show drun"))

  (defun thanos/volume-increase ()
    "Increase Volume."
    (interactive)
    (start-process-shell-command
     "amixer" nil "amixer sset Master 5%+"))

  (defun thanos/volume-decrease ()
    "Decrease Volume."
    (interactive)
    (start-process-shell-command
     "amixer" nil "amixer sset Master 5%-"))

  (defun thanos/restore-wallpaper ()
    "Set NAME as wallpaper."
    (interactive)
    (start-process-shell-command
     "feh" nil  "feh --bg-scale ~/dotfiles/wallpaper.png"))

  (defun thanos/emacs-keys ()
      "Swap caps with ctrl."
      (interactive)
      (start-process-shell-command
       "setxkbmap" nil "setxkbmap us -option ctrl:swapcaps"))

  (defun thanos/greek-keyboard ()
      "Swap caps with ctrl."
      (interactive)
      (start-process-shell-command
       "setxkbmap" nil "setxkbmap gr"))

  (defun thanos/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-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")))

  (defun create-text-scratch ()
    "create a scratch buffer"
    (interactive)
    (switch-to-buffer (get-buffer-create "*Text Scratch*"))
    (text-mode))

  (define-key Create (kbd "t") 'create-text-scratch)

  (defun create-scratch ()
    (interactive)
    (switch-to-buffer (get-buffer-create "*scratch*"))
    (emacs-lisp-mode))

  (define-key Create (kbd "e") 'create-scratch)
#+end_src