#+title: Desktop settings
#+setupfile: headers
#+options: auto-id:t
#+html_head: <meta name="description" content="Phundrak’s Emacs Configuration" />
#+html_head: <meta property="og:title" content="Phundrak’s Emacs Configuration" />
#+html_head: <meta property="og:description" content="Phundrak’s Emacs Configuration Detailed" />
#+property: header-args:emacs-lisp  :mkdirp yes :lexical t :exports code
#+property: header-args:emacs-lisp+ :tangle ~/.emacs.d/desktop.el
#+property: header-args:emacs-lisp+ :mkdirp yes :noweb no-export
#+property: header-args:lisp :mkdirp :tangle ~/.stumpwm.d/desktop.lisp :noweb yes

* Introduction
:PROPERTIES:
:CUSTOM_ID: Introduction-w831x4a0l9j0
:END:
Many settings formerly present in this website’s index are related to
my desktop settings, while some others are not.

# Also, since I switched to StumpWM, many of my keybinds from Emacs need
# to be kept up to date with my StumpWM keybinds, and /vice versa/. This
# document aims to regroup all settings related to the desktop in order
# to have an easier time managing them.

* Common Emacs and StumpWM settings                                :noexport:
:PROPERTIES:
:CUSTOM_ID: Common-Emacs-and-StumpWM-settings-neseiaa0l9j0
:END:
Both Emacs and StumpWM work on the same principle of keychords
powering a function or command. With both of them I have a prefix key,
~SPC~ in the case of Emacs (or ~C-SPC~ when in insert-mode, see the
relevant config) and ~s-SPC~ in the case of StumpWM. That means I can
give them the same keychord following this, for instance ~w/~ to create
a new vertically split frame to the right of the current one.

All the keybinds will be presented in the form of tables, with on the
first column the keychord following the leader key, on the second
column the EmacsLisp function to be called, and on the third the
StumpWM command. If one of the ELisp or StumpWM case’s is empty, it
means there is no equivalence. If it’s ~nil~, then it means it is a
prefix key. The fourth column is for now reserved for Emacs’ which-key
so I can give it a better name. If its value is ~nil~, then it should
not show up. Hopefully this can be implemented someday in StumpWM.

** Generating Code                                                :noexport:
:PROPERTIES:
:CUSTOM_ID: Common-Emacs-and-StumpWM-settings-Generating-Code-ngnclyk0l9j0
:END:
*** Elisp
:PROPERTIES:
:CUSTOM_ID: Common-Emacs-and-StumpWM-settings-Generating-Code-Elisp-oeqclyk0l9j0
:END:
#+name: emacs-keybinds-gen
#+header: :var keymap=emacs-stumpwm-media-control
#+begin_src emacs-lisp :exports none :tangle no :wrap "src emacs-lisp :tangle no"
(mapconcat (lambda (keybind)
             (let* ((keychord (replace-regexp-in-string (rx (or (seq line-start "~")
                                                                (seq "~" line-end)))
                                                        ""
                                                        (car keybind)))
                    (function (replace-regexp-in-string (rx (or (seq line-start "~")
                                                                (seq "~" line-end)))
                                                        ""
                                                        (nth 1 keybind)))
                    (which    (nth 3 keybind)))
               (format "\"%s\" %s"
                       keychord
                       (if (string= "nil" function)
                           (format "%S"
                                   `(:ignore :which-key ,which))
                         (if (string= "" which)
                             (concat "#'" function)
                           (format "%S"
                                   `'(,(intern function) :which-key ,which)))))))
           (seq-filter (lambda (elem)
                         (not (string= "" (nth 1 elem))))
                       keymap)
           "\n")
#+end_src

#+RESULTS: emacs-keybinds-gen
#+begin_src emacs-lisp :tangle no
"m" (:ignore :which-key "media")
"m«" #'emms-player-mpd-previous
"m»" #'emms-player-mpd-next
"ma" '(hydra-media/body :which-key "MPD add")
"mb" (:ignore :which-key "browse")
"mba" #'emms-browse-by-artist
"mbA" #'emms-browse-by-album
"mbg" #'emms-browse-by-genre
"mbp" #'emms-playlists-mode-go
"mbs" #'emms-smart-browse
"mby" #'emms-browse-by-year
"mc" #'emms-player-mpd-clear
"mp" #'emms-player-toggle-pause
"ms" #'emms-player-mpd-show
"mu" (:ignore :which-key "update")
"mum" #'emms-player-mpd-update-all
"muc" #'emms-cache-set-from-mpd-all
#+end_src

#+name: emacs-hydra-keybinds-gen
#+header: :var keymap=emacs-stumpwm-resize-frame
#+begin_src emacs-lisp :exports none :tangle no :wrap "src emacs-lisp :tangle no"
(mapconcat (lambda (keybind)
             (let ((keychord (replace-regexp-in-string "^~\\|~$"
                                                       ""
                                                       (car keybind)))
                   (function (replace-regexp-in-string "^~\\|~$"
                                                       ""
                                                       (nth 1 keybind)))
                   (which (nth 3 keybind)))
               (format "%S" (if (string= "" which)
                                `(,keychord ,(intern function))
                              `(,keychord ,(intern function) ,which)))))
           keymap
           "\n")
#+end_src

#+RESULTS: emacs-hydra-keybinds-gen
#+begin_src emacs-lisp :tangle no
("c" shrink-window-horizontally)
("t" enlarge-window)
("s" shrink-window)
("r" enlarge-window-horizontally)
#+end_src

*** Lisp
:PROPERTIES:
:CUSTOM_ID: Common-Emacs-and-StumpWM-settings-Generating-Code-Lisp-qntclyk0l9j0
:END:
#+name: stumpwm-filter-keybinds
#+begin_src emacs-lisp :exports none :tangle no
(let ((no-tilde (lambda (string)
                  (replace-regexp-in-string "^~\\|~$" "" string))))
  (seq-filter (lambda (elem)
                (= 1 (length (car elem))))
              (mapcar (lambda (elem)
                        `(,(replace-regexp-in-string (format "^%s" prefix) "" (car elem))
                          .
                          ,(cdr elem)))
                      (seq-filter (lambda (elem)
                                    (and (not (string= "" (cdr elem)))
                                         (not (string= prefix (car elem)))
                                         (string-prefix-p prefix (car elem))))
                                  (mapcar (lambda (elem)
                                            (let ((keychord (apply no-tilde (list (car elem))))
                                                  (function (apply no-tilde (list (nth 2 elem)))))
                                              `(,keychord . ,function)))
                                          keymap)))))
#+end_src

#+name: stumpwm-keybinds-gen
#+header: :var keymap=emacs-stumpwm-media-control keymap-name="my-mpd-add-map" prefix="m"
#+begin_src emacs-lisp :exports none :tangle no :wrap "src lisp :tangle no" :noweb yes
(require 'seq)
(format "(defvar *%s*
  (let %S
    %s
    m))"
        keymap-name
        `((m (make-sparse-keymap)))
        (mapconcat (lambda (keybind)
                     (let ((keychord (replace-regexp-in-string (format "^%s" prefix)
                                                               ""
                                                               (car keybind)))
                           (function (cdr keybind)))
                       (format "%S" `(define-key m (kbd ,keychord) ,function))))
                   <<stumpwm-filter-keybinds>>
                   "\n    "))
#+end_src

#+RESULTS: stumpwm-keybinds-gen
#+begin_src lisp :tangle no
(defvar *my-mpd-add-map*
  (let ((m (make-sparse-keymap)))
    (define-key m (kbd ".") "media-interactive")
    (define-key m (kbd "«") "mpd-prev")
    (define-key m (kbd "»") "mpd-next")
    (define-key m (kbd "a") "'*my-mpd-add-keymap*")
    (define-key m (kbd "b") "'*my-mpd-browse-keymap*")
    (define-key m (kbd "c") "mpd-clear")
    (define-key m (kbd "p") "mpd-toggle-pause")
    m))
#+end_src

#+name: stumpwm-interactive-keybinds-gen
#+header: :var keymap=emacs-stumpwm-resize-frame prefix=""
#+header: :wrap "src lisp :exports none"
#+begin_src emacs-lisp :noweb yes
(format "(%s)"
        (mapconcat (lambda (keybind)
                     (let ((keychord (car keybind))
                           (function (cdr keybind)))
                       (format "%S" `((kbd ,keychord) ,function))))
                   <<stumpwm-filter-keybinds>>
                   "\n "))
#+end_src

#+RESULTS: stumpwm-interactive-keybinds-gen
#+begin_src lisp :exports none
(((kbd "c") "resize-direction left")
 ((kbd "t") "resize-direction down")
 ((kbd "s") "resize-direction up")
 ((kbd "r") "resize-direction right"))
#+end_src

#+name: stumpwm-interactive-gen
#+header: :var keymap=emacs-stumpwm-resize-frame keymap-name="my-mpd-add-map" prefix=""
#+begin_src emacs-lisp :exports none :tangle no :wrap "src lisp :tangle no"
(format "%S"
        `(define-interactive-keymap ,(intern keymap-name)
           (:exit-on '((kbd "RET")
                       (kbd "ESC")
                       (kbd "C-g")
                       (kbd "q")))
           ,@
           <<stumpwm-interactive-keybinds-gen>>
           ))
#+end_src

#+RESULTS: stumpwm-interactive-gen
#+begin_src lisp :tangle no
(define-interactive-keymap my-mpd-add-map (:exit-on '((kbd "RET") (kbd "ESC") (kbd "C-g") (kbd "q"))) ((kbd "c") "resize-direction left" (kbd "t") "resize-direction down" (kbd "s") "resize-direction up" (kbd "r") "resize-direction right"))
#+end_src

** Frames Management
:PROPERTIES:
:CUSTOM_ID: Common-Emacs-and-StumpWM-settings-Frames-Management-5zhea5c0l9j0
:END:
In StumpWM, I’ll consider my various windows the same as Emacs’
buffers.
#+name: emacs-stumpwm-frames-management
| Keychord | Emacs                     | StumpWM                 | which-key |
|----------+---------------------------+-------------------------+-----------|
| ~b~        | ~nil~                       | ~'*my-buffers-keymap*~    | buffers   |
| ~bb~       | ~buflers-switch-buffer~     | ~windowlist~              |           |
| ~bB~       | ~bury-buffer~               |                         |           |
| ~bd~       | ~kill-this-buffer~          | ~delete-window~           |           |
| ~bD~       | ~kill-buffer~               | ~window-window-and-frame~ |           |
| ~bh~       | ~dashboard-refresh-buffer~  |                         |           |
| ~bk~       |                           | ~kill-window~             |           |
| ~bl~       | ~bufler~                    |                         |           |
| ~bm~       | ~switch-to-messages-buffer~ |                         |           |
| ~bn~       | ~evil-next-buffer~          | ~next~                    |           |
| ~bp~       | ~evil-prev-buffer~          | ~prev~                    |           |
| ~br~       | ~counsel-buffer-or-recentf~ |                         |           |
| ~bs~       | ~switch-to-scratch-buffer~  |                         |           |

EmacsLisp code:
#+begin_src emacs-lisp
(phundrak/leader-key
  <<emacs-keybinds-gen(keymap=emacs-stumpwm-frames-management)>>
  )
#+end_src

StumpWM’s Lisp code:
#+begin_src lisp
<<stumpwm-keybinds-gen(keymap=emacs-stumpwm-frames-management, keymap-name="my-buffers-keymap", prefix="b")>>
(define-key *root-map (kbd "b") '*my-buffers-keymap*)
#+end_src

** Window Management
:PROPERTIES:
:CUSTOM_ID: Common-Emacs-and-StumpWM-settings-Window-Management-8kt59fa0l9j0
:END:
The following allows to have an interactive keymap for resizing the
current frame. In Emacs, it will be translated as a hydra while in
StumpWM it will be an interactive keymap.
#+name: emacs-stumpwm-resize-frame
| Keychord | Emacs                       | StumpWM                | which-key |
|----------+-----------------------------+------------------------+-----------|
| ~c~        | ~shrink-window-horizontally~  | ~resize-direction left~  |           |
| ~t~        | ~enlarge-window~              | ~resize-direction down~  |           |
| ~s~        | ~shrink-window~               | ~resize-direction up~    |           |
| ~r~        | ~enlarge-window-horizontally~ | ~resize-direction right~ |           |

This translates into the following hydra in EmacsLisp:
#+begin_src emacs-lisp
(defhydra windows-adjust-size ()
  "
^Zoom^                                ^Other
^^^^^^^-----------------------------------------
[_t_/_s_] shrink/enlarge vertically   [_q_] quit
[_c_/_r_] shrink/enlarge horizontally
"
  <<emacs-hydra-keybinds-gen(keymap=emacs-stumpwm-resize-frame)>>
  ("q" nil :exit t))
#+end_src

While the following Lisp code is used with StumpWM.
#+begin_src lisp
(define-interactive-keymap (iresize tile-group) (:on-enter #'setup-iresize
                                                           :on-exit #'resize-unhide
                                                           :abort-if #'abort-resize-p
                                                           :exit-on '((kbd "RET")
                                                                      (kbd "ESC")
                                                                      (kbd "C-g")
                                                                      (kbd "q")))
  <<stumpwm-interactive-keybinds-gen(keymap=emacs-stumpwm-resize-frame)>>
  )
#+end_src

Below you will find my window management keybinds.
#+name: emacs-stump-window-management
| Keychord | Emacs                         | StumpWM                  | which-key        |
|----------+-------------------------------+--------------------------+------------------|
| ~w~        | ~nil~                           | ~'*my-windows-keymap*~     | windows          |
| ~w.~       | ~windows-adjust-size/body~      | ~iresize~                  | resize windows   |
| ~w-~       | ~split-window-below-and-focus~  | ~vsplit-and-focus~         |                  |
| ~w+~       |                               | ~balance-frames~           |                  |
| ~wv~       | ~split-window-below~            | ~vsplit~                   |                  |
| ~wV~       |                               | ~vsplit-equally~           |                  |
| ~w/~       | ~split-window-right-and-focus~  | ~hsplit-and-focus~         |                  |
| ~wh~       | ~split-window-right~            | ~hsplit~                   |                  |
| ~wH~       |                               | ~hsplit-equally~           |                  |
| ~wc~       | ~evil-window-left~              | ~move-focus left~          |                  |
| ~wt~       | ~evil-window-down~              | ~move-focus down~          |                  |
| ~ws~       | ~evil-window-up~                | ~move-focus up~            |                  |
| ~wr~       | ~evil-window-right~             | ~move-focus right~         |                  |
| ~wC~       |                               | ~move-window left~         |                  |
| ~wT~       |                               | ~move-window down~         |                  |
| ~wS~       |                               | ~move-window up~           |                  |
| ~wR~       |                               | ~move-window right~        |                  |
| ~w C-c~    |                               | ~exchange-direction right~ |                  |
| ~w C-s~    |                               | ~exchange-direction down~  |                  |
| ~w C-t~    |                               | ~exchange-direction up~    |                  |
| ~w C-r~    |                               | ~exchange-direction right~ |                  |
| ~wb~       | ~kill-buffer-and-delete-window~ |                          |                  |
| ~we~       | ~winum-select-window-by-number~ | ~expose~                   |                  |
| ~wf~       |                               | ~fullscreen~               |                  |
| ~wF~       |                               | ~'*my-floating-keymap*~    | floating windows |
| ~wFf~      |                               | ~float-this~               |                  |
| ~wFF~      |                               | ~flatten-floats~           |                  |
| ~wFu~      |                               | ~unfloat-this~             |                  |
| ~wi~       |                               | ~info~                     |                  |
| ~wd~       | ~delete-window~                 | ~remove-split~             |                  |
| ~wD~       | ~delete-other-windows~          | ~only~                     |                  |
| ~wm~       |                               | ~meta~                     |                  |
| ~wo~       | ~other-window~                  | ~other-window~             |                  |
| ~ws~       |                               | ~sibling~                  |                  |
| ~wu~       |                               | ~next-urgent~              |                  |
| ~wU~       |                               | ~unmaximize~               |                  |
| ~ww~       | ~nil~                           |                          | writeroom        |
| ~ww.~      | ~writeroom-buffer-width/body~   |                          |                  |
| ~www~      | ~writeroom-mode~                |                          |                  |

** Media Control
:PROPERTIES:
:CUSTOM_ID: Common-Emacs-and-StumpWM-settings-Media-Control-r56g2hc0l9j0
:END:
#+name: emacs-stumpwm-media-interactive
| Keychord | Emacs                                                       | StumpWM         | which-key |
|----------+-------------------------------------------------------------+-----------------+-----------|
| ~c~        | ~emms-player-mpd-previous~                                    | ~mpd-prev~        |           |
| ~t~        | ~(shell-command-and-echo "mpc volume -2" "mpc volume" "mpc")~ | ~mpd-volume-down~ |           |
| ~s~        | ~(shell-command-and-echo "mpc volume +2" "mpc volume" "mpc")~ | ~mpd-volume-up~   |           |
| ~r~        | ~emms-player-mpd-next~                                        | ~mpd-next~        |           |
| ~s~        | ~emms-player-mpd-stop~                                        | ~mpd-stop~        |           |

#+name: emacs-stumpwm-general-media
| Keychord | Emacs | StumpWM                              | which-key      |
|----------+-------+--------------------------------------+----------------|
| ~c~        |       | ~exec xbacklight -dec 2~               | backlight down |
| ~t~        |       | ~exec amixer -q set Master 2%- unmute~ | volume down    |
| ~s~        |       | ~exec amixer -q set Master 2%+ unmute~ | volume up      |
| ~r~        |       | ~exec xbacklight -inc 2~               | backlight up   |
| ~m~        |       | ~exec amixer -q set Master 1+ toggle~  | toggle mute    |

#+name: emacs-stumpwm-media-control
| Keychord | Emacs                       | StumpWM                   | which-key |
|----------+-----------------------------+---------------------------+-----------|
| ~m~        | ~nil~                         | ~'*my-media-keymap*~        | media     |
| ~m.~       |                             | ~media-interactive~         |           |
| ~m«~       | ~emms-player-mpd-previous~    | ~mpd-prev~                  |           |
| ~m»~       | ~emms-player-mpd-next~        | ~mpd-next~                  |           |
| ~ma~       | ~hydra-media/body~            | ~'*my-mpd-add-keymap*~      | MPD add   |
| ~maa~      |                             | ~mpd-serach-and-add-artist~ |           |
| ~maA~      |                             | ~mpd-serach-and-add-album~  |           |
| ~maf~      |                             | ~mpd-search-and-add-file~   |           |
| ~maF~      |                             | ~mpd-add-file~              |           |
| ~mag~      |                             | ~mpd-search-and-add-genre~  |           |
| ~mat~      |                             | ~mpd-search-and-add-title~  |           |
| ~mb~       | ~nil~                         | ~'*my-mpd-browse-keymap*~   | browse    |
| ~mba~      | ~emms-browse-by-artist~       | ~mpd-browse-artists~        |           |
| ~mbA~      | ~emms-browse-by-album~        | ~mpd-browse-albums~         |           |
| ~mbg~      | ~emms-browse-by-genre~        | ~mpd-browse-genres~         |           |
| ~mbp~      | ~emms-playlists-mode-go~      | ~mpd-browse-playlist~       |           |
| ~mbs~      | ~emms-smart-browse~           |                           |           |
| ~mbt~      |                             | ~mpd-browse-tracks~         |           |
| ~mby~      | ~emms-browse-by-year~         |                           |           |
| ~mc~       | ~emms-player-mpd-clear~       | ~mpd-clear~                 |           |
| ~mp~       | ~emms-player-toggle-pause~    | ~mpd-toggle-pause~          |           |
| ~ms~       | ~emms-player-mpd-show~        |                           |           |
| ~mu~       | ~nil~                         |                           | update    |
| ~mum~      | ~emms-player-mpd-update-all~  |                           |           |
| ~muc~      | ~emms-cache-set-from-mpd-all~ |                           |           |

* Theme and graphical tweaks
:PROPERTIES:
:CUSTOM_ID: Theme-and-graphical-tweaks-ukp6gbc0l9j0
:END:
** GTK Settings
:PROPERTIES:
:CUSTOM_ID: Theme-and-graphical-tweaks-GTK-Settings-2307gbc0l9j0
:END:
*** GTK2
:PROPERTIES:
:CUSTOM_ID: Theme-and-graphical-tweaks-GTK-Settings-GTK2-fq77gbc0l9j0
:END:
**** General configuration
:PROPERTIES:
:HEADER-ARGS: :mkdirp yes :tangle ~/.gtkrc-2.0
:CUSTOM_ID: Theme-and-graphical-tweaks-GTK-Settings-GTK2-General-configuration-xod7gbc0l9j0
:END:
This file is tangled at ~$HOME/.gtkrc-2.0~. This is an equivalent for the GTK3
configuration file you will see below, and it shares most of its settings.
First, let’s select the Nordic theme for GTK2. Let’s also set the icon theme.
#+BEGIN_SRC conf-unix
# -*- mode: unix-config -*-
gtk-theme-name="Nordic"
gtk-icon-theme-name="Flat-Remix-Dark"
#+END_SRC

#+BEGIN_SRC conf-unix
gtk-xft-antialias=1
gtk-xft-hinting=1
gtk-xft-hintstyle="hintslight"
#+END_SRC

This changes the shortcuts in menu, let’s also make the menus snappier.
#+BEGIN_SRC conf-unix
gtk-can-change-accels=1
gtk-menu-bar-popup-delay=0
gtk-menu-popdown-delay=0
gtk-menu-popup-delay=0
#+END_SRC

**** Filechooser
:PROPERTIES:
:HEADER-ARGS: :mkdirp yes :tangle ~/.config/gtk-2.0/gtkfilechooser.ini
:CUSTOM_ID: Theme-and-graphical-tweaks-GTK-Settings-GTK2-Filechooser-nmh7gbc0l9j0
:END:
#+BEGIN_SRC conf-unix
[Filechooser Settings]
#+END_SRC

The first option alows me to open the file chooser in the current working
directory:
#+BEGIN_SRC conf-unix
StartupMode=cwd
#+END_SRC

Next, setting the location mode to ~path-bar~ will show the path as buttons that
can be clicked rather than the full path.
#+BEGIN_SRC conf-unix
LocationMode=path-bar
#+END_SRC

With this configuration, by default we won’t see hidden files.
#+BEGIN_SRC conf-unix
ShowHidden=true
#+END_SRC

And we'll also see the size of the visible files.
#+BEGIN_SRC conf-unix
ShowSizeColumn=true
#+END_SRC

Now, let’s choose the geometry of our file picker. These two first lines set
where the file picker appears:
#+BEGIN_SRC conf-unix
GeometryX=566
GeometryY=202
#+END_SRC

And these two describe the size of the window:
#+BEGIN_SRC conf-unix
GeometryWidth=800
GeometryHeight=400
#+END_SRC

With these two lines, we set how our files are sorted: by name, and in the
ascending order.
#+BEGIN_SRC conf-unix
SortColumn=name
SortOrder=ascending
#+END_SRC

Our default view mode is a list of files:
#+BEGIN_SRC conf-unix
ViewMode=list-view
#+END_SRC

And finally, setting our icon view scale to ~-1~ sets the icon view to the max
size.
#+BEGIN_SRC conf-unix
IconViewScale=-1
#+END_SRC

*** GTK3
:PROPERTIES:
:HEADER-ARGS: :mkdirp yes :tangle ~/.config/gtk-3.0/settings.ini
:CUSTOM_ID: Theme-and-graphical-tweaks-GTK-Settings-GTK3-ojl7gbc0l9j0
:END:
The following file helps me choosing the aspect of various GTK+ 3 software,
including their theme and icons. First, let’s declare the header:
#+BEGIN_SRC conf-unix
[Settings]
#+END_SRC

Now, let’s hint to GTK that I prefer dark themes. This can have an influence
also on some websites that can detect this preference and therefore set their
own theme to dark by themselves.
#+BEGIN_SRC conf-unix
gtk-application-prefer-dark-theme = true
#+END_SRC

Next, the icon theme is the Flat Remix Dark icon theme:
#+BEGIN_SRC conf-unix
gtk-icon-theme-name = Flat-Remix-Dark
#+END_SRC

Now, the general theme for GTK3 is Nordic.
#+BEGIN_SRC conf-unix
gtk-theme-name = Nordic
#+END_SRC

#+BEGIN_SRC conf-unix
gtk-can-change-accels=1
gtk-menu-bar-popup-delay=0
gtk-menu-popdown-delay=0
gtk-menu-popup-delay=0
#+END_SRC

#+BEGIN_SRC conf-unix
gtk-xft-antialias=1
gtk-xft-hinting=1
gtk-xft-hintstyle=hintslight
# gtk-xft-rgba=rgb
#+END_SRC

Since window decorations are handled by my WMs, I will leave this variable
empty.
#+BEGIN_SRC conf-unix
gtk-decoration-layout=
#+END_SRC

** Picom (Compton)
:PROPERTIES:
:CUSTOM_ID: Theme-and-graphical-tweaks-Picom-Compton-uko7gbc0l9j0
:END:
Picom is a standalone compositor for Xorg, and the successor to
Compton, itself successor to xcompmgr-dana, itself a fork of xcompmgr.
You can find my Picom configuration [[file:picom.org][here]].

** Xresources
:PROPERTIES:
:HEADER-ARGS: :mkdirp yes :tangle ~/.Xresources :exports code
:CUSTOM_ID: Theme-and-graphical-tweaks-Xresources-4dr7gbc0l9j0
:END:
The main body in my Xresources declaration is the declaration of my
color theme. It is based on the [[https://www.nordtheme.com/][Nord]] theme, from their [[https://github.com/arcticicestudio/nord-xresources/][Git repository]].
#+BEGIN_SRC conf
#define nord0 #2E3440
#define nord1 #3B4252
#define nord2 #434C5E
#define nord3 #4C566A
#define nord4 #D8DEE9
#define nord5 #E5E9F0
#define nord6 #ECEFF4
#define nord7 #8FBCBB
#define nord8 #88C0D0
#define nord9 #81A1C1
#define nord10 #5E81AC
#define nord11 #BF616A
#define nord12 #D08770
#define nord13 #EBCB8B
#define nord14 #A3BE8C
#define nord15 #B48EAD

,*.foreground:   nord4
,*.background:   nord0
,*.cursorColor:  nord4
,*fading: 35
,*fadeColor: nord3

,*.color0: nord1
,*.color1: nord11
,*.color2: nord14
,*.color3: nord13
,*.color4: nord9
,*.color5: nord15
,*.color6: nord8
,*.color7: nord5
,*.color8: nord3
,*.color9: nord11
,*.color10: nord14
,*.color11: nord13
,*.color12: nord9
,*.color13: nord15
,*.color14: nord7
,*.color15: nord6
#+END_SRC

* Gpg configuration
:PROPERTIES:
:CUSTOM_ID: Gpg-configuration-6i2ip6l0m9j0
:END:
#+begin_src conf :tangle ~/.gnupg/gpg.conf
keyserver hkp://keys.gnupg.net
keyserver-options auto-key-retrieve
keyserver hkp://pgp.mit.edu:11371
#+end_src

* Email signature
:PROPERTIES:
:HEADER-ARGS: :mkdirp yes :tangle ~/.signature
:CUSTOM_ID: Email-signature-jnn75ac0l9j0
:END:
This file gets inserted automatically at the end of my emails.
#+BEGIN_SRC text
Lucien “Phundrak” Cartier-Tilet
https://phundrak.com (Français)
https://phundrak.com/en (English)
Sent from GNU/Emacs
#+END_SRC

* ~.desktop~ files for custom applications
:PROPERTIES:
:CUSTOM_ID: -desktop-files-for-custom-applications-cksiyhg0m9j0
:END:
Some software I use are not packaged (yet) on my system. Therefore, in
order to make them available in ~rofi~, I need to write a ~.desktop~ file
so I can launch them.

** Emacs
:PROPERTIES:
:CUSTOM_ID: -desktop-files-for-custom-applications-Emacs-6e9actg0m9j0
:END:
Emacs does have a default ~.desktop~ file, but I want to override it so
I can just “open with Emacs” from other software (such as Nemo) and it
will instead open with ~emacsclient~.
#+begin_src conf-desktop :tangle ~/.local/share/applications/emacs.desktop
[Desktop Entry]
Name=Emacs
GenericName=Text Editor
Comment=Edit text
MimeType=text/english;text/plain;text/x-makefile;text/x-c++hdr;text/x-c++src;text/x-chdr;text/x-csrc;text/x-java;text/x-moc;text/x-pascal;text/x-tcl;text/x-tex;application/x-shellscript;text/x-c;text/x-c++;
Exec=emacsclient -c %F
Icon=emacs
Type=Application
Terminal=false
Categories=Development;TextEditor;
StartupWMClass=Emacs
Keywords=Text;Editor;
#+end_src

I also have ~mu4e.desktop~ which is used to set my default email client.
It relies on ~emacsmail~ defined in [[file:bin.org::#Emacsmail-afffb7cd][this document]].
#+begin_src conf-desktop :tangle ~/.local/share/applications/mu4e.desktop
[Desktop Entry]
Name=Mu4e
GenericName=Mu4e
Comment=Maildir Utils for Emacs
MimeType=x-scheme-handler/mailto;
Exec=/home/phundrak/.local/bin/emacsmail %U
Icon=emacs
Type=Application
Terminal=false
Categories=Network;Email;TextEditor
StartupWMClass=Gnus
Keywords=Text;Editor;
#+end_src

Then I also have ~org-protocol.desktop~ so I can capture elements from
other software, mainly web pages from Firefox through the [[https://github.com/sprig/org-capture-extension][org-capture
extension]].
#+begin_src conf-desktop :tangle ~/.local/share/applications/org-protocol.desktop
[Desktop Entry]
Name=org-protocol
Exec=emacsclient %u
Type=Application
Terminal=false
Categories=System;
MimeType=x-scheme-handler/org-protocol;
#+end_src

** FlowScape
:PROPERTIES:
:CUSTOM_ID: -desktop-files-for-custom-applications-FlowScape-7zelglg0m9j0
:END:
[[https://pixelforest.itch.io/flowscape][FlowScape]] is a nice 3D compositing software I sometimes use to create
landscapes. I always install it in =~/.local/opt/Flowscape=, so the
~.desktop~ file is relatively straightforward.
#+begin_src conf-desktop :tangle ~/.local/share/applications/FlowScape.desktop
[Desktop Entry]
Version=1.5
Name=FlowScape
Comment=Create gorgeous 3D landscapes with ease.
Exec=/usr/bin/prime-run /home/phundrak/.local/opt/FlowScape/FlowScape.x86_64
Path=/home/phundrak/.local/opt/FlowScape
Icon=/home/phundrak/.local/opt/FlowScape/icon.jpg
Terminal=false
Type=Application
Categories=Graphics
#+end_src

** macOS
:PROPERTIES:
:CUSTOM_ID: -desktop-files-for-custom-applications-macOS-yb1dmyg0m9j0
:END:
You did not read wrong! Yes I have an entry for macOS, but this is for
a virtual machine located in ~~/VMs/macOS~.
#+begin_src conf-desktop :tangle ~/.local/share/applications/macos.desktop
[Desktop Entry]
Version=1
Name=macOS
Comment=macOS in a virtual machine
Exec=/usr/bin/prime-run /home/phundrak/VMs/macOS/basic.sh
Path=/home/phundrak/VMs/macOS
Icon=/home/phundrak/VMs/macOS/macOS.png
Terminal=false
Type=Application
Categories=Development
#+end_src

** Minecraft
:PROPERTIES:
:CUSTOM_ID: -desktop-files-for-custom-applications-Minecraft-tds7ddh0m9j0
:END:
Yup, I play Minecraft. And yes, it does have a default ~.desktop~ file,
but this one overrides it so it launches automatically Minecraft with
[[https://wiki.archlinux.org/title/PRIME][prime-run]] so my GPU is used.
#+begin_src conf-desktop :tangle ~/.local/share/applications/minecraft-launcher.desktop
[Desktop Entry]
Type=Application
Version=1.0
Name=Minecraft Launcher (Nvidia)
Comment=Official Minecraft Launcher
Exec=/usr/bin/prime-run /usr/bin/minecraft-launcher
Path=/usr/bin/
Icon=minecraft-launcher
Terminal=false
Categories=Game;Application;
#+end_src

** OtherWorldMapper
:PROPERTIES:
:CUSTOM_ID: -desktop-files-for-custom-applications-OtherWorldMapper-rnh4omg0m9j0
:END:
OtherWorldMapper is a map creation software. It is always installed in
~~/.local/opt/OtherWorldMapper~.
#+begin_src conf-desktop :tangle ~/.local/share/applications/OWM.desktop
[Desktop Entry]
Version=1.0.4
Name=OtherWorldMapper
Comment=OtherWorldMapper is a powerful yet intuitive fantasy map creation tool.
Exec=/usr/bin/prime-run /home/phundrak/.local/opt/OtherWorldMapper/OWM
Path=/home/phundrak/.local/opt/OtherWorldMapper
Icon=/home/phundrak/.local/opt/OtherWorldMapper/owm.ico
Terminal=false
Type=Application
Categories=Graphics
#+end_src

** YouTube ~.desktop~ files
:PROPERTIES:
:CUSTOM_ID: -desktop-files-for-custom-applications-YouTube-desktop-files-0pw918h0m9j0
:END:
The first ~.desktop~ file related to YouTube is ~ytdl.desktop~ which runs
~ytdl~ defined in [[file:bin.org::#ytdl-a-youtube-dl-wrapper-03bd63e0][this document]].
#+begin_src conf-desktop :tangle ~/.local/share/applications/ytdl.desktop
[Desktop Entry]
Version=0.3
Name=YTDL
Comment=YouTube (and more) video downloader
Exec=/home/phundrak/.local/bin/rofi-ytdl
Path=/home/phundrak/.local/bin
Terminal=false
Type=Application
Categories=Network;Video
#+end_src

There is also ~ytplay.desktop~ for ~ytplay~ defined in [[file:bin.org::#Media-youtube-dl-wrappers-ytplay-z6ka39h0m9j0][this document]].
#+begin_src conf-desktop
[Desktop Entry]
Type=Application
Version=1.0
Name=ytplay (YouTube in mpv)
Comment=Play YouTube videos in mpv
Exec=/home/phundrak/.local/bin/ytplay
Path=/home/phundrak/.local/bin
Terminal=false
Categories=Media
#+end_src
