aboutsummaryrefslogtreecommitdiffstats
path: root/modules/init-gui.el
blob: 98573265e007956be4232f5197410d79e681a68b (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
;;; init-gui.el --- .Emacs Configuration -*- lexical-binding: t -*-
;;; Commentary:
;;

;;; Code:
;;-----------------------
;; Remove some GUI stuff
;;-----------------------
(setq use-file-dialog nil)
(setq use-dialog-box nil)
(setq inhibit-startup-screen t)
(setq inhibit-startup-echo-area-message t)
(setq inhibit-startup-message t)
(setq inhibit-hello-hook t)
(setq inhibit-x-resources t)
(when (display-graphic-p)
  (tool-bar-mode 0)
  (scroll-bar-mode 0)
  (menu-bar-mode 0))
(setq make-backup-files nil)
(setq auto-save-default nil)
(setq create-lockfiles nil)
(setq ad-redefinition-action 'accept)

;; Disable unnecessary features for speed
(setq ring-bell-function 'ignore)
(setq use-short-answers t)
(setq confirm-kill-emacs nil)

;;------------------------------
;; Core settings | UTF-8 please
;;------------------------------
;; Set Unicode character priority
(set-charset-priority 'unicode)
;; Set language environment to UTF-8
(set-language-environment "UTF-8")
;; Set terminal coding system to UTF-8
(set-terminal-coding-system 'utf-8)
;; Set keyboard coding system to UTF-8
(set-keyboard-coding-system 'utf-8)
;; Set selection coding system to UTF-8
(set-selection-coding-system 'utf-8)
;; Prefer UTF-8 coding system
(prefer-coding-system 'utf-8)

;;----------------------------------------------------------------------------
;; Editor configuration
;;----------------------------------------------------------------------------
(setq indicate-empty-lines t)

(when (display-graphic-p)
  (let ((no-border '(internal-border-width . 0)))
    (add-to-list 'default-frame-alist no-border)
    (add-to-list 'initial-frame-alist no-border))

  (setq frame-title-format
        '((:eval (if (buffer-file-name)
                     (abbreviate-file-name (buffer-file-name))
                   "%b"))))

  ;; Font theme (DejaVu Sans Mono if Hack isn't present)
  (if (member "Hack" (font-family-list))
      (set-frame-font "Hack-9")
    (set-frame-font "DejaVu Sans Mono-10")))

;;----------------------------------------------------------------------------
;; Configure keys
;;----------------------------------------------------------------------------
(global-unset-key (kbd "C-z")) ; Stops C-z from minimizing window
(when (display-graphic-p)
  (global-set-key (kbd "M-0") (lambda () (interactive) (modify-frame-parameters nil '((alpha . 100))))) ; M-0 standard visibility
  (global-set-key (kbd "s-C-+") 'sacha/increase-font-size)  ; C-+ increase font size
  (global-set-key (kbd "s-C--") 'sacha/decrease-font-size))  ; C-- decrease font size
(global-set-key (kbd "<f12>") 'revert-buffer-no-confirm)
(when (display-graphic-p)
  (global-set-key (kbd "s-h") 'global-hl-line-mode))         ; Highlight current line
(global-set-key (kbd "M-c") nil) ; disable capitalize-word
(global-set-key (kbd "<f6>") 'display-line-numbers-mode)
;; muti-curses
(global-set-key (kbd "C->") 'mc/mark-next-like-this)
(global-set-key (kbd "C-<") 'mc/mark-previous-like-this)
(global-set-key (kbd "C-c C-<") 'mc/mark-all-like-this)

;;---------------------------------------------------------------------------
;; FullScreen
;;---------------------------------------------------------------------------
(when (display-graphic-p)
  (defun myemacs/toggle-fullscreen ()
    "Toggle fullscreen mode using X11 client message."
    (interactive)
    (x-send-client-message nil 0 nil "_NET_WM_STATE" 32
                           '(2 "_NET_WM_STATE_FULLSCREEN" 0)))
  (global-set-key (kbd "<f11>") 'myemacs/toggle-fullscreen)) ; F11 FullScreen

;;----------------------------------------------------------------------------
;; Define custom browser
;;----------------------------------------------------------------------------
(setq browse-url-browser-function 'browse-url-generic
      browse-url-generic-program (getenv "WEB_BROWSER_APP"))

;;----------------------------------------------------------------------------
;; doas open file option
;;----------------------------------------------------------------------------
(defun doas-find-file (file-name)
  "Like find file, but opens the file as root."
  (interactive "FDoas Find File: ")
  (let ((tramp-file-name (concat "/doas::" (expand-file-name file-name))))
    (find-file tramp-file-name)))

;;----------------------------------------------------------------------------
;; clock
;;----------------------------------------------------------------------------
(setq display-time-day-and-date t)
(display-time)

(provide 'init-gui)

;; End:
;;; init-gui.el ends here