summaryrefslogtreecommitdiff
path: root/src/en/articles/gnu+linux-and-emacs-introduction/index.org
blob: 38ebc8a2eb481b6fbe744cd2f7d046a50fa32e84 (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
#+title: GNU/Linux and GNU Emacs Introduction
#+keywords: beginner gnu linux emacs

* Installing Debian
** Preparations
*** Getting debian
Download Debian [[https://www.debian.org/][installer image]]

*** Creating installation medium
On =M$= Windows, use a tool like [[https://rufus.ie/en/][Rufus]] to create a bootable USB flash
drive with the downloaded =.iso= file

*** Allocating disk space
Either get an empty disk or shrink on of your data partitions (toms) to get a continuous region of free space which is at least around 100GB.

** Installation process
If installing on a laptop, make sure that it's fully charged and keep
the charger plugged in.

*** Booting from the installation medium
NOTE: You might have to enable booting from USB in BIOS.

Select the USB from boot menu or change boot order.

*** The Debian installer
Select the =install= option (not the =Graphical install=) in the GRUB bootloader.

To navigate the menus, use arrow keys and TAB, to toggle check boxes use spacebar and to press button use the enter key.

Simple guide:
1. Select region
2. Select localization (US)
3. Select keyboard layout (most likely US/ISO)
4. Select connected if you have Ethernet connection or wireless if you
   want to connect to wifi.
5. Choose hostname.
6. Skip domain name.
7. Skip proxy.
8. Select mirror in your region.
9. Set root password.
10. Set user's full name, username and password.
11. Deselect all software packages except base.
12. To dual boot with Windows select guided partitioning (free space).
13. Select =/home= folder on a separate partition.
14. Start the installation.
15. Reboot and check that you can boot everything.

* Setting up GNU/Linux
** User setup
1. Login as root
1. Edit =/etc/apt/sources= and add =non-free contrib testing unstable=
2. ~apt udpate~
3. ~apt upgrade~
4. ~apt install sudo~
5. ~visudo~ (%wheel ALL=(ALL) NOPASSWD: ALL)
6. ~groupadd wheel~
7. ~usermod -aG wheel YOUR_USERNAME~
8. ~exit~

** Environment setup
*** Folder setup
#+begin_src sh
cd
rmdir Downloads Desktop ...
mkdir downloads documents multimedia
cd multimedia
mkdir screenshots
mkdir screencasts
#+end_src

*** Emacs setup
~sudo apt install emacs git vterm-module libtd~

Delete =~/.emacs.d=

Edit =~/.config/emacs/init.el=

#+name: emacs-server
#+header: :tangle emacs/init.el
#+begin_src emacs-lisp
(server-start)
#+end_src

#+name: emacs-straight
#+header: :tangle emacs/init.el
#+begin_src emacs-lisp
(defvar bootstrap-version)
(let ((bootstrap-file
       (expand-file-name
        "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
      (bootstrap-version 6))
  (unless (file-exists-p bootstrap-file)
    (with-current-buffer
        (url-retrieve-synchronously
         "https://raw.githubusercontent.com/radian-software/straight.el/develop/install.el"
         'silent 'inhibit-cookies)
      (goto-char (point-max))
      (eval-print-last-sexp)))
  (load bootstrap-file nil 'nomessage))

(straight-use-package 'use-package)
(setq straight-use-package-by-default t
      use-package-always-ensure t)
#+end_src

#+name: emacs-coding
#+header: :tangle emacs/init.el
#+begin_src emacs-lisp
(prefer-coding-system 'utf-8)
(set-language-environment "UTF-8")
(set-default-coding-systems 'utf-8)
(set-terminal-coding-system 'utf-8)
(setq-default buffer-file-coding-system 'utf-8)
#+end_src

#+name: emacs-clean-look
#+header: :tangle emacs/init.el
#+begin_src emacs-lisp
(menu-bar-mode   -1)
(tool-bar-mode   -1)
(scroll-bar-mode -1)
#+end_src

#+name: emacs-misc
#+header: :tangle emacs/init.el
#+begin_src emacs-lisp
(setq kill-ring-max 10000)
(repeat-mode 1)
(auto-insert-mode 1)
(global-hl-line-mode 1)
(setq display-time-24hr-format t)
(setq default-input-method "russian-computer")
(load-theme 'modus-vivendi t)
(fset 'yes-or-no-p 'y-or-n-p)
(set-face-attribute 'default nil :font "Iosevka" :height 180)
(global-subword-mode)
#+end_src

#+name: emacs-compilation
#+header: :tangle emacs/init.el
#+begin_src emacs-lisp
(require 'ansi-color)
(add-hook 'compilation-filter-hook 'ansi-color-compilation-filter)
(add-hook 'compilation-mode-hook 'toggle-truncate-lines)
(define-key global-map (kbd "C-<f5>") 'compile)
(define-key global-map (kbd "<f5>") 'recompile)
#+end_src

#+name: emacs-trash
#+header: :tangle emacs/init.el
#+begin_src emacs-lisp
(use-package trashed)
(setq delete-by-moving-to-trash t)
#+end_src

#+name: emacs-undo-tree
#+header: :tangle emacs/init.el
#+begin_src emacs-lisp
(use-package undo-tree
  :config
  (global-undo-tree-mode))
#+end_src

#+name: emacs-page-break-lines
#+header: :tangle emacs/init.el
#+begin_src emacs-lisp
(use-package page-break-lines
  :config
  (global-page-break-lines-mode))
#+end_src

#+name: emacs-pdf-tools
#+header: :tangle emacs/init.el
#+begin_src emacs-lisp
(use-package pdf-tools
  :demand t
  :hook (pdf-view-mode . pdf-view-themed-minor-mode)
  :config
  ;; Initialize the package
  (pdf-tools-install)
  ;; Associate pdf-view-mode with PDF files
  (add-to-list 'auto-mode-alist '("\\.pdf\\'" . pdf-view-mode))
  ;; Enable seamless scrolling between pages
  (setq pdf-view-continuous-scroll-mode t)
  ;; Use normal Emacs keybindings for scrolling
  (setq pdf-view-continuous-scroll-keystrokes nil))
#+end_src

#+name: emacs-eglot
#+header: :tangle emacs/init.el
#+begin_src emacs-lisp
(use-package eglot)
#+end_src

#+name: emacs-project
#+header: :tangle emacs/init.el
#+begin_src emacs-lisp
(use-package project)
#+end_src

#+name: emacs-terminals
#+header: :tangle emacs/init.el
#+begin_src emacs-lisp
(use-package vterm)
(use-package eat)
#+end_src

#+name: emacs-telega
#+header: :tangle emacs/init.el
#+begin_src emacs-lisp
(use-package telega
  :custom
  (telega-server-libs-prefix "/usr"))
#+end_src

#+name: emacs-emms
#+header: :tangle emacs/init.el
#+begin_src emacs-lisp
(use-package emms)
#+end_src

#+name: emacs-multitran
#+header: :tangle emacs/init.el
#+begin_src emacs-lisp
(use-package multitran
  :bind
  (("s-t" . multitran-at-pos)))
#+end_src

#+name: emacs-savehist
#+header: :tangle emacs/init.el
#+begin_src emacs-lisp
(use-package savehist
  :config
  (savehist-mode))
#+end_src

#+name: emacs-lorem-ipsum
#+header: :tangle emacs/init.el
#+begin_src emacs-lisp
(use-package lorem-ipsum)
#+end_src

#+name: emacs-smartparens
#+header: :tangle emacs/init.el
#+begin_src emacs-lisp
(use-package smartparens
  :init
  (smartparens-global-mode t))
#+end_src

#+name: emacs-completion
#+header: :tangle emacs/init.el
#+begin_src emacs-lisp
(use-package vertico
  :init
  (vertico-mode)
  ;; (setq vertico-scroll-margin 0)
  ;; (setq vertico-count 20)
  ;; (setq vertico-resize t)
  (setq vertico-cycle t))

(use-package orderless
  :init
  ;; (setq orderless-style-dispatchers '(+orderless-consult-dispatch
  ;;                                     orderless-affix-dispatch)
  orderless-component-separator #'orderless-escapable-split-on-space)
(setq completion-styles '(orderless basic)
      completion-category-defaults nil
      completion-category-overrides '((file (styles partial-completion)))))

(use-package consult
  :bind (;; C-c bindings in `mode-specific-map'
         ("C-c M-x" . consult-mode-command)
         ("C-c h" . consult-history)
         ("C-c k" . consult-kmacro)
         ("C-c m" . consult-man)
         ("C-c i" . consult-info)
         ([remap Info-search] . consult-info)
         ;; C-x bindings in `ctl-x-map'
         ("C-x M-:" . consult-complex-command)     ;; orig. repeat-complex-command
         ("C-x b" . consult-buffer)                ;; orig. switch-to-buffer
         ("C-x 4 b" . consult-buffer-other-window) ;; orig. switch-to-buffer-other-window
         ("C-x 5 b" . consult-buffer-other-frame)  ;; orig. switch-to-buffer-other-frame
         ("C-x r b" . consult-bookmark)            ;; orig. bookmark-jump
         ("C-x p b" . consult-project-buffer)      ;; orig. project-switch-to-buffer
         ;; Custom M-# bindings for fast register access
         ("M-#" . consult-register-load)
         ("M-'" . consult-register-store)          ;; orig. abbrev-prefix-mark (unrelated)
         ("C-M-#" . consult-register)
         ;; Other custom bindings
         ("M-y" . consult-yank-pop)                ;; orig. yank-pop
         ;; M-g bindings in `goto-map'
         ("M-g e" . consult-compile-error)
         ("M-g f" . consult-flymake)               ;; Alternative: consult-flycheck
         ("M-g g" . consult-goto-line)             ;; orig. goto-line
         ("M-g M-g" . consult-goto-line)           ;; orig. goto-line
         ("M-g o" . consult-outline)               ;; Alternative: consult-org-heading
         ("M-g m" . consult-mark)
         ("M-g k" . consult-global-mark)
         ("M-g i" . consult-imenu)
         ("M-g I" . consult-imenu-multi)
         ;; M-s bindings in `search-map'
         ("M-s d" . consult-find)                  ;; Alternative: consult-fd
         ("M-s D" . consult-locate)
         ("M-s g" . consult-grep)
         ("M-s G" . consult-git-grep)
         ("M-s r" . consult-ripgrep)
         ("M-s l" . consult-line)
         ("M-s L" . consult-line-multi)
         ("M-s k" . consult-keep-lines)
         ("M-s u" . consult-focus-lines)
         ;; Isearch integration
         ("M-s e" . consult-isearch-history)
         :map isearch-mode-map
         ("M-e" . consult-isearch-history)         ;; orig. isearch-edit-string
         ("M-s e" . consult-isearch-history)       ;; orig. isearch-edit-string
         ("M-s l" . consult-line)                  ;; needed by consult-line to detect isearch
         ("M-s L" . consult-line-multi)            ;; needed by consult-line to detect isearch
         ;; Minibuffer history
         :map minibuffer-local-map
         ("M-s" . consult-history)                 ;; orig. next-matching-history-element
         ("M-r" . consult-history))                ;; orig. previous-matching-history-element

  ;; Enable automatic preview at point in the *Completions* buffer. This is
  ;; relevant when you use the default completion UI.
  :hook (completion-list-mode . consult-preview-at-point-mode)
  :init
  ;; Optionally configure the register formatting. This improves the register
  ;; preview for `consult-register', `consult-register-load',
  ;; `consult-register-store' and the Emacs built-ins.
  (setq register-preview-delay 0.5
        register-preview-function #'consult-register-format)

  ;; Optionally tweak the register preview window.
  ;; This adds thin lines, sorting and hides the mode line of the window.
  (advice-add #'register-preview :override #'consult-register-window)

  ;; Use Consult to select xref locations with preview
  (setq xref-show-xrefs-function #'consult-xref
        xref-show-definitions-function #'consult-xref)

  ;; Configure other variables and modes in the :config section,
  ;; after lazily loading the package.
  :config

  ;; Optionally configure preview. The default value
  ;; is 'any, such that any key triggers the preview.
  ;; (setq consult-preview-key 'any)
  ;; (setq consult-preview-key "M-.")
  ;; (setq consult-preview-key '("S-<down>" "S-<up>"))
  ;; For some commands and buffer sources it is useful to configure the
  ;; :preview-key on a per-command basis using the `consult-customize' macro.
  (consult-customize
   consult-theme :preview-key '(:debounce 0.2 any)
   consult-ripgrep consult-git-grep consult-grep
   consult-bookmark consult-recent-file consult-xref
   consult--source-bookmark consult--source-file-register
   consult--source-recent-file consult--source-project-recent-file
   ;; :preview-key "M-."
   :preview-key '(:debounce 0.4 any))

  ;; Optionally configure the narrowing key.
  ;; Both < and C-+ work reasonably well.
  (setq consult-narrow-key "<") ;; "C-+"

  ;; Optionally make narrowing help available in the minibuffer.
  ;; You may want to use `embark-prefix-help-command' or which-key instead.
  ;; (define-key consult-narrow-map (vconcat consult-narrow-key "?") #'consult-narrow-help)
  )

(use-package corfu
  :custom
  (corfu-cycle t)                ;; Enable cycling for `corfu-next/previous'
  (corfu-auto t)                 ;; Enable auto completion
  (corfu-separator ?\s)          ;; Orderless field separator
  (corfu-quit-at-boundary nil)   ;; Never quit at completion boundary
  (corfu-quit-no-match nil)      ;; Never quit, even if there is no match
  (corfu-preview-current nil)    ;; Disable current candidate preview
  (corfu-preselect 'prompt)      ;; Preselect the prompt
  (corfu-on-exact-match nil)     ;; Configure handling of exact matches
  (corfu-scroll-margin 5)        ;; Use scroll margin
  :init
  (global-corfu-mode))
#+end_src

#+name: emacs-dired
#+header: :tangle emacs/init.el
#+begin_src emacs-lisp
(setq dired-listing-switches "-alh"
      dired-dwim-target t
      dired-recursive-copies  'always
      dired-recursive-deletes 'always)
(use-package dired-single)
#+end_src

#+name: emacs-emacs
#+header: :tangle emacs/init.el
#+begin_src emacs-lisp
(use-package emacs
  :init
  ;; Add prompt indicator to `completing-read-multiple'.
  ;; We display [CRM<separator>], e.g., [CRM,] if the separator is a comma.
  (defun crm-indicator (args)
    (cons (format "[CRM%s] %s"
                  (replace-regexp-in-string
                   "\\`\\[.*?]\\*\\|\\[.*?]\\*\\'" ""
                   crm-separator)
                  (car args))
          (cdr args)))
  (advice-add #'completing-read-multiple :filter-args #'crm-indicator)

  ;; Do not allow the cursor in the minibuffer prompt
  (setq minibuffer-prompt-properties
        '(read-only t cursor-intangible t face minibuffer-prompt))
  (add-hook 'minibuffer-setup-hook #'cursor-intangible-mode)

  ;; Enable recursive minibuffers
  (setq enable-recursive-minibuffers t))

;; Save all tempfiles in $TMPDIR/emacs$UID/
(defconst emacs-tmp-dir (expand-file-name (format "emacs%d" (user-uid)) temporary-file-directory))
(setq backup-directory-alist
      `((".*" . ,emacs-tmp-dir)))
(setq auto-save-file-name-transforms
      `((".*" ,emacs-tmp-dir t)))
(setq auto-save-list-file-prefix
      emacs-tmp-dir)
#+end_src

#+name: emacs-multiple-cursors
#+header: :tangle emacs/init.el
#+begin_src emacs-lisp
(use-package multiple-cursors
  :bind
  (("C-S-c"     . mc/edit-lines)
   ("C->"       . mc/mark-next-like-this)
   ("C-<"       . mc/mark-previous-like-this)
   ("C-c C-S-c" . mc/mark-all-like-this)
   ("C-\""      . mc/skip-to-next-like-this)
   ("C-:"       . mc/skip-to-previous-like-this)))
#+end_src

#+name: emacs-expand-region
#+header: :tangle emacs/init.el
#+begin_src emacs-lisp
(use-package expand-region
  :bind
  (("C-M-=" . er/expand-region)))
#+end_src

#+name: emacs-move-text
#+header: :tangle emacs/init.el
#+begin_src emacs-lisp
(use-package move-text
  :bind
  (("M-P" . move-text-up)
   ("M-N" . move-text-down)))
#+end_src

#+name: emacs-duplicate
#+header: :tangle emacs/init.el
#+begin_src emacs-lisp
(keymap-global-set "C-'" 'duplicate-dwim)
(setq duplicate-line-final-position 1)
#+end_src

#+name: emacs-hl-todo
#+header: :tangle emacs/init.el
#+begin_src emacs-lisp
(use-package hl-todo
  :config
  (global-hl-todo-mode 1))
#+end_src

#+name: emacs-ligature
#+header: :tangle emacs/init.el
#+begin_src emacs-lisp
(use-package ligature
  :config
  (ligature-set-ligatures
   't '("-<<" "-<" "-<-" "<--" "<---" "<<-" "<-" "->" "->>" "-->" "--->" "->-" ">-" ">>-"
        "=<<" "=<" "=<=" "<==" "<===" "<<=" "<=" "=>" "=>>" "==>" "===>" "=>=" ">=" ">>="
        "<->" "<-->" "<--->" "<---->" "<=>" "<==>" "<===>" "<====>" "::" ":::" "__"
        "<~~" "</" "</>" "/>" "~~>" "==" "!=" "/=" "~=" "<>" "===" "!==" "!===" "=/=" "=!="
        "<:" ":=" "*=" "*+" "<*" "<*>" "*>" "<|" "<|>" "|>" "<." "<.>" ".>" "+*" "=*" "=:" ":>"
        "(*" "*)" "/*" "*/" "[|" "|]" "{|" "|}" "++" "+++" "\\/" "/\\" "|-" "-|" "<!--" "<!---"))
  (global-ligature-mode -1))
#+end_src

#+name: emacs-magit
#+header: :tangle emacs/init.el
#+begin_src emacs-lisp
(use-package magit)
#+end_src

#+name: emacs-restart-emacs
#+header: :tangle emacs/init.el
#+begin_src emacs-lisp
(use-package restart-emacs)
#+end_src

#+name: emacs-bluetooth
#+header: :tangle emacs/init.el
#+begin_src emacs-lisp
(use-package bluetooth)
#+end_src

*** Installing fonts
1. Wget latest =PkgTTC-Iosevka-X.X.X.zip= asset from [[https://github.com/be5invis/Iosevka/releases][iosevka releases]]
2. ~unzip DOWNLOADED_FILE~
3. ~mv contents ~/.local/share/fonts~
4. ~fc-cache -fv~

*** i3 setup
~sudo apt install xorg i3 dbus-launch maim udiskie~
Edit =~/.xinitrc=

Disable access control for the current user.
#+name: xinitrc-xhost
#+header: :tangle .xinitrc
#+begin_src sh
xhost +SI:localuser:$USER
#+end_src

#+name: xinitrc-xset
#+header: :tangle .xinitrc
#+begin_src sh
xset r rate 250 30
#+end_src

#+name: xinitrc-dbus-launch
#+header: :tangle .xinitrc
#+begin_src sh
exec dbus-launch --exit-with-session i3
#+end_src

Edit =~/.config/i3/config=

#+header: :tangle i3/config :exports none
#+begin_src conf-space
# Please see https://i3wm.org/docs/userguide.html for a complete reference!
#+end_src
#+name: i3-config-mod
#+header: :tangle i3/config
#+begin_src conf-space
set $mod Mod4
#+end_src

Font for window titles.  Will also be used by the bar unless a
different font is used in the bar ={}= block below.
#+header: :tangle i3/config :exports none
#+begin_src conf-space
# Font for window titles. Will also be used by the bar unless a different font
# is used in the bar {} block below.
#+end_src
#+name: i3-config-font
#+header: :tangle i3/config
#+begin_src conf-space
font pango:monospace 12
#+end_src

Start XDG autostart =.desktop= files using =dex=. See also [[https://wiki.archlinux.org/index.php/XDG_Autostart][XDG Autostart -
ArchWiki]]
#+header: :tangle i3/config :exports none
#+begin_src conf-space
# Start XDG autostart .desktop files using dex. See also
# https://wiki.archlinux.org/index.php/XDG_Autostart
#+end_src
#+name: i3-config-dex
#+header: :tangle i3/config
#+begin_src conf-space
exec --no-startup-id dex --autostart --environment i3
#+end_src

The combination of ~xss-lock~, ~nm-applet~ and ~pactl~ is a popular choice,
so they are included here as an example. Modify as you see fit.

~xss-lock~ grabs a =logind suspend inhibit lock= and will use ~i3lock~ to
lock the screen before suspend. Use ~loginctl lock-session~ to lock your
screen.

#+header: :tangle i3/config :exports none
#+begin_src conf-space
# The combination of xss-lock, nm-applet and pactl is a popular choice, so
# they are included here as an example. Modify as you see fit.

# xss-lock grabs a logind suspend inhibit lock and will use i3lock to lock the
# screen before suspend. Use loginctl lock-session to lock your screen.
#+end_src
#+name: i3-config-xss-lock
#+header: :tangle i3/config
#+begin_src conf-space
exec --no-startup-id xss-lock --transfer-sleep-lock -- i3lock --nofork
#+end_src

#+name: i3-config-setxkbmap
#+header: :tangle i3/config
#+begin_src conf-space
exec --no-startup-id setxkbmap -layout "us,ru" -option 'grp:shifts_toggle' -option "ctrl:nocaps"
#+end_src

#+name: i3-config-udiskie
#+header: :tangle i3/config
#+begin_src conf-space
exec --no-startup-id udiskie --automount
#+end_src

NetworkManager is the most popular way to manage wireless networks on
Linux, and ~nm-applet~ is a desktop environment-independent system tray
GUI for it.
#+header: :tangle i3/config :exports none
#+begin_src conf-space
# NetworkManager is the most popular way to manage wireless networks on Linux,
# and nm-applet is a desktop environment-independent system tray GUI for it.
#+end_src
#+name: i3-config-nm-applet
#+header: :tangle i3/config
#+begin_src conf-space
exec --no-startup-id nm-applet
#+end_src

#+name: i3-config-emacs
#+header: :tangle i3/config
#+begin_src conf-space
exec emacs --background black
#+end_src

Use ~pactl~ to adjust volume in PulseAudio.
#+header: :tangle i3/config :exports none
#+begin_src conf-space
# Use pactl to adjust volume in PulseAudio.
#+end_src
#+name: i3-config-pulseaudio
#+header: :tangle i3/config
#+begin_src conf-space
set $refresh_i3status killall -SIGUSR1 i3status
bindsym XF86AudioRaiseVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ +10% && $refresh_i3status
bindsym XF86AudioLowerVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ -10% && $refresh_i3status
bindsym XF86AudioMute exec --no-startup-id pactl set-sink-mute @DEFAULT_SINK@ toggle && $refresh_i3status
bindsym XF86AudioMicMute exec --no-startup-id pactl set-source-mute @DEFAULT_SOURCE@ toggle && $refresh_i3status
#+end_src

Change brightness.
#+header: :tangle i3/config :exports none
#+begin_src conf-space
# Change brightness
#+end_src
#+name: i3-config-brightnessctl
#+header: :tangle i3/config
#+begin_src conf-space
bindsym XF86MonBrightnessUp exec --no-startup-id brightnessctl set +5%
bindsym XF86MonBrightnessDown exec --no-startup-id brightnessctl set 5%-
#+end_src

Use =Mouse+$mod= to drag floating windows to their wanted position.
#+header: :tangle i3/config :exports none
#+begin_src conf-space
# Use Mouse+$mod to drag floating windows to their wanted position.
#+end_src
#+name: i3-config-floating_modifier
#+header: :tangle i3/config
#+begin_src conf-space
floating_modifier $mod
#+end_src

Move tiling windows via drag & drop by left-clicking into the title
bar, or left-clicking anywhere into the window while holding the
floating modifier.
#+header: :tangle i3/config :exports none
#+begin_src conf-space
# Move tiling windows via drag & drop by left-clicking into the title bar,
# or left-clicking anywhere into the window while holding the floating modifier.
#+end_src
#+name: i3-config-tiling_drag-modifier
#+header: :tangle i3/config
#+begin_src conf-space
tiling_drag modifier titlebar
#+end_src

#+name: i3-config-bindsym
#+header: :tangle i3/config
#+begin_src conf-space
# start a terminal
bindsym $mod+Return exec emacsclient -c

# kill focused window
bindsym $mod+Shift+q kill

# start dmenu (a program launcher)
bindsym $mod+d exec --no-startup-id i3-dmenu-desktop --dmenu='dmenu -i -fn 12'

# change focus
bindsym $mod+j focus left
bindsym $mod+k focus down
bindsym $mod+l focus up
bindsym $mod+semicolon focus right

# alternatively, you can use the cursor keys:
bindsym $mod+Left focus left
bindsym $mod+Down focus down
bindsym $mod+Up focus up
bindsym $mod+Right focus right

# move focused window
bindsym $mod+Shift+j move left
bindsym $mod+Shift+k move down
bindsym $mod+Shift+l move up
bindsym $mod+Shift+semicolon move right

# alternatively, you can use the cursor keys:
bindsym $mod+Shift+Left move left
bindsym $mod+Shift+Down move down
bindsym $mod+Shift+Up move up
bindsym $mod+Shift+Right move right

# split in horizontal orientation
bindsym $mod+h split h

# split in vertical orientation
bindsym $mod+v split v

# enter fullscreen mode for the focused container
bindsym $mod+f fullscreen toggle

# change container layout (stacked, tabbed, toggle split)
bindsym $mod+s layout stacking
bindsym $mod+w layout tabbed
bindsym $mod+e layout toggle split

# toggle tiling / floating
bindsym $mod+Shift+space floating toggle

# change focus between tiling / floating windows
bindsym $mod+space focus mode_toggle

# focus the parent container
bindsym $mod+a focus parent

# focus the child container
#bindsym $mod+d focus child

# Define names for default workspaces for which we configure key bindings later on.
# We use variables to avoid repeating the names in multiple places.
set $ws1 "1"
set $ws2 "2"
set $ws3 "3"
set $ws4 "4"
set $ws5 "5"
set $ws6 "6"
set $ws7 "7"
set $ws8 "8"
set $ws9 "9"
set $ws10 "10"

# switch to workspace
bindsym $mod+1 workspace number $ws1
bindsym $mod+2 workspace number $ws2
bindsym $mod+3 workspace number $ws3
bindsym $mod+4 workspace number $ws4
bindsym $mod+5 workspace number $ws5
bindsym $mod+6 workspace number $ws6
bindsym $mod+7 workspace number $ws7
bindsym $mod+8 workspace number $ws8
bindsym $mod+9 workspace number $ws9
bindsym $mod+0 workspace number $ws10

# move focused container to workspace
bindsym $mod+Shift+1 move container to workspace number $ws1
bindsym $mod+Shift+2 move container to workspace number $ws2
bindsym $mod+Shift+3 move container to workspace number $ws3
bindsym $mod+Shift+4 move container to workspace number $ws4
bindsym $mod+Shift+5 move container to workspace number $ws5
bindsym $mod+Shift+6 move container to workspace number $ws6
bindsym $mod+Shift+7 move container to workspace number $ws7
bindsym $mod+Shift+8 move container to workspace number $ws8
bindsym $mod+Shift+9 move container to workspace number $ws9
bindsym $mod+Shift+0 move container to workspace number $ws10

# reload the configuration file
bindsym $mod+Shift+c reload
# restart i3 inplace (preserves your layout/session, can be used to upgrade i3)
bindsym $mod+Shift+r restart
# exit i3 (logs you out of your X session)
bindsym $mod+Shift+e exec i3-nagbar -t warning -m \
'You pressed the exit shortcut. Do you really want to exit i3? This will end your X session.' \
-B 'Yes, exit i3' 'i3-msg exit'

# resize window (you can also use the mouse for that)
mode "resize" {
# These bindings trigger as soon as you enter the resize mode

# Pressing left will shrink the window’s width.
# Pressing right will grow the window’s width.
# Pressing up will shrink the window’s height.
# Pressing down will grow the window’s height.
bindsym Left resize shrink width 10 px or 10 ppt
bindsym Down resize grow height 10 px or 10 ppt
bindsym Up resize shrink height 10 px or 10 ppt
bindsym Right resize grow width 10 px or 10 ppt

# back to normal: Enter or Escape or $mod+r
bindsym Return mode "default"
bindsym Escape mode "default"
bindsym $mod+r mode "default"
}

bindsym $mod+r mode "resize"
#+end_src

#+name: i3-config-bar
#+header: :tangle i3/config
#+begin_src conf-space
# Start i3bar to display a workspace bar (plus the system information i3status
# finds out, if available)
bar {
status_command i3status
}
#+end_src

#+name: i3-config-print-screen
#+header: :tangle i3/config
#+begin_src conf-space
# Print screen
bindsym --release Print exec "maim $HOME/multimedia/screenshots/$(date '+%y%m%d-%H%M-%S').png"
bindsym --release Shift+Print exec "maim --hidecursor --select $HOME/multimedia/screenshots/$(date '+%y%m%d-%H%M-%S').png"
bindsym --release Ctrl+Print exec "maim | xclip -sel clip -t image/png"
bindsym --release Shift+Ctrl+Print exec "maim --hidecursor --select | xclip -sel clip -t image/png"
#+end_src

- ~startx~
- =s-RET=