summaryrefslogtreecommitdiff
path: root/.emacs.d/lisp/functions.el
blob: e330bbdb7a5b3e291c2ab5cfc5cffb419339ab7e (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
;;; package --- Summary
;;; Commentary:
;;; useful snippets of code 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 center-buffer ()
  "Center buffer."
    (interactive)
  (setq visual-fill-column-width 100
	visual-fill-column-center-text t)
  (visual-fill-column-mode 1))

(defun center-buffer-undo ()
  "Undo center-buffer."
    (interactive)
  (setq visual-fill-column-width 2000
	visual-fill-column-center-text nil)
  (visual-fill-column-mode 1))


(defun apollo/rofi-switch-window ()
  "Launch rofi.  Cant get it to work with exwm as of now tho."
  (interactive)
  (start-process-shell-command
   "rofi" nil "rofi -show window"))
;; (global-set-key (kbd "s-<tab>") 'apollo/run_rofi)

(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 ~/Downloads/winter-night-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)
  )
  
(defun apollo/exwm-update-class ()
  (exwm-workspace-rename-buffer exwm-class-name))

;;; my-functions.el ends here