Skip to content

Latest commit

 

History

History
1629 lines (1224 loc) · 47.6 KB

Desktop.org

File metadata and controls

1629 lines (1224 loc) · 47.6 KB

Desktop Environment

This file contains configuration for my overall desktop environment. My workflow is driven by Emacs but there are still a number of applications, tools, themes, and fonts that I must install to have a complete desktop experience.

Table of Contents

System Settings

Load system-specific settings from .emacs.d/per-system-settings.el and unpack relevant values into blocks so that they can be used in configuration file blocks. These settings are configured in Systems.org.

(load-file ".emacs.d/per-system-settings.el")
(dw/system-settings-get (intern name))

Fonts and Themes

I use xsettingsd as a minimal settings daemon for Xorg applications. It replaces similar daemons from desktop environments like GNOME and XFCE and enables me to use a simple configuration file like the following:

.config/xsettingsd/xsettingsd.conf:

Net/ThemeName "Matcha-dark-azul"
Net/IconThemeName "Papirus-Dark"
Gtk/DecorationLayout "menu:minimize,maximize,close"
Gtk/FontName "Cantarell 11"
Gtk/MonospaceFontName "Fira Mono 10"
Gtk/CursorThemeName "Adwaita"
Xft/Antialias 1
Xft/Hinting 0
Xft/HintStyle "hintnone"
Xft/DPI <<dpi()>> # 1024 * DPI

I also have to do an extra step to make sure Emacs can find the font path from the “desktop” profile.

.config/fontconfig/fonts.conf:

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
  <dir>~/.dotfiles/fonts</dir>
  <dir>~/.guix-extra-profiles/desktop/desktop/share/fonts</dir>
  <alias>
    <family>Apple Color Emoji</family>
    <prefer>
      <family>Noto Color Emoji</family>
    </prefer>
  </alias>
</fontconfig>

DPI

(* 1024 (alist-get 'desktop/dpi dw/system-settings))

Guix Packages

;; Window Manager
;; "stumpwm"
;; "stumpwm:lib"
;; "sbcl-stumpwm-swm-gaps"
;; "sbcl-stumpwm-ttf-fonts"
;; "sbcl"

;; Settin gs Manager
"xsettingsd"

;; GTK Themes
"arc-icon-theme"
"matcha-theme"
"hicolor-icon-theme"
"gnome-icon-theme"
"gnome-backgrounds"
"papirus-icon-theme"
"breeze-icons"

;; Fonts
"font-fira-code"
"font-jetbrains-mono"
"font-iosevka"
"font-iosevka-aile"
"font-abattis-cantarell"
"font-dejavu"
"font-google-noto"
"font-gnu-freefont"
"font-liberation"
"font-awesome"
"font-google-material-design-icons"
"gs-fonts"

Window Management

I use Emacs as the desktop window manager thanks to the excellent EXWM. This configuration gets loaded relatively early in Emacs startup if running on a Linux machine.

(setup (:pkg exwm)
  (setq mouse-autoselect-window nil
        focus-follows-mouse t
        exwm-workspace-warp-cursor t
        exwm-workspace-number 5)
        ;exwm-workspace-display-echo-area-timeout 5
        ;exwm-workspace-minibuffer-position 'bottom) ;; Annoying focus issues

  ;; Make class name the buffer name
  (add-hook 'exwm-update-class-hook
      (lambda ()
        (exwm-workspace-rename-buffer exwm-class-name)))
  (add-hook 'exwm-update-title-hook
      (lambda ()
        (pcase exwm-class-name
          ("Vimb" (exwm-workspace-rename-buffer (format "vimb: %s" exwm-title)))
          ("qutebrowser" (exwm-workspace-rename-buffer (format "Qutebrowser: %s" exwm-title))))))

  ;; Enable exwm-randr before exwm-init gets called
  (require 'exwm-randr)
  (exwm-randr-enable)
  (setq exwm-randr-workspace-monitor-plist '(0 "DP-3-3" 1 "DP-3-3" 2 "DP-3-3" 3 "eDP-1" 4 "eDP-1"))

  (exwm-enable))

Helper Functions

(defun exwm/run-in-background (command)
  (let ((command-parts (split-string command "[ ]+")))
    (apply #'call-process `(,(car command-parts) nil 0 nil ,@(cdr command-parts)))))

(defun exwm/bind-function (key invocation &rest bindings)
  "Bind KEYs to FUNCTIONs globally"
  (while key
    (exwm-input-set-key (kbd key)
                        `(lambda ()
                           (interactive)
                           (funcall ',invocation)))
    (setq key (pop bindings)
          invocation (pop bindings))))

(defun exwm/bind-command (key command &rest bindings)
  "Bind KEYs to COMMANDs globally"
  (while key
    (exwm-input-set-key (kbd key)
                        `(lambda ()
                           (interactive)
                           (exwm/run-in-background ,command)))
    (setq key (pop bindings)
          command (pop bindings))))

Configuration

(defun dw/exwm-init-hook ()
  (with-eval-after-load 'perspective
    ;; Set up perspective names on initial workspaces
    (exwm-workspace-switch-create 0)
    (persp-switch "Chat")

    ;; Launch Telega in workspace 0 if we've logged in before
    (when (file-exists-p "~/.telega/db.sqlite")
      (telega nil))

    (persp-kill "Main")
    (exwm-workspace-switch-create 1)
    (exwm-workspace-switch-create 2)
    (persp-switch "Browsers")
    (persp-kill "Main")
    (exwm-workspace-switch-create 3)
    (persp-switch "Comms")
    (persp-kill "Main")
    (exwm-workspace-switch-create 4)
    (persp-switch "Media")
    (persp-kill "Main")

    ;; Make workspace 1 be the one where we land at startup
    (exwm-workspace-switch-create 1)

    ;; Open eshell by default
    (eshell))

  ;; Launch apps that will run in the background
  (exwm/run-in-background "dunst")
  (exwm/run-in-background "nm-applet")
  (exwm/run-in-background "syncthing-gtk --minimized")
  (exwm/run-in-background "udiskie -t")
  (exwm/run-in-background "redshift -l 47.675510:-122.203362 -t 6500:3500"))
  ;; Athens
  ;(exwm/run-in-background "redshift -l 37.983810:23.727539 -t 6500:3500"))

(defun dw/setup-window-by-class ()
  (interactive)
  (pcase exwm-class-name
    ("Emacs" (call-interactively #'exwm-input-toggle-keyboard))
    ("Xephyr" (call-interactively #'exwm-input-toggle-keyboard))
    ("discord" (exwm-workspace-move-window 3))
    ("Microsoft Teams - Preview" (exwm-workspace-move-window 3))
    ("Spotify" (exwm-workspace-move-window 4))
    ("Vimb" (exwm-workspace-move-window 2))
    ("qutebrowser" (exwm-workspace-move-window 2))
    ("qjackctl" (exwm-floating-toggle-floating))
    ("mpv" (exwm-floating-toggle-floating)
            (dw/exwm-floating-toggle-pinned))
    ("gsi" (exwm-input-toggle-keyboard))))

(setup exwm
  (add-hook 'exwm-mode-hook
            (lambda ()
              (evil-local-set-key 'motion (kbd "C-u") nil)))

  ;; Do some post-init setup
  (add-hook 'exwm-init-hook #'dw/exwm-init-hook)

  ;; Manipulate windows as they're created
  (add-hook 'exwm-manage-finish-hook
            (lambda ()
              ;; Send the window where it belongs
              (dw/setup-window-by-class)))

              ;; Hide the modeline on all X windows
              ;(exwm-layout-hide-mode-line)))

  ;; Hide the modeline on all floating windows
  (add-hook 'exwm-floating-setup-hook
            (lambda ()
              (exwm-layout-hide-mode-line))))

Desktop Configuration

(defun dw/run-xmodmap ()
  (interactive)
  (start-process-shell-command "xmodmap" nil "xmodmap ~/.dotfiles/.config/i3/Xmodmap"))

(defun dw/update-wallpapers ()
  (interactive)
  (start-process-shell-command
   "feh" nil
   (format "feh --bg-scale ~/.dotfiles/backgrounds/%s" (alist-get 'desktop/background dw/system-settings))))

(setq dw/panel-process nil)
(defun dw/kill-panel ()
  (interactive)
  (when dw/panel-process
    (ignore-errors
      (kill-process dw/panel-process)))
  (setq dw/panel-process nil))

(defun dw/start-panel ()
  (interactive)
  (dw/kill-panel)
  (setq dw/panel-process (start-process-shell-command "polybar" nil "polybar panel")))

(defun dw/update-screen-layout ()
  (interactive)
  (let ((layout-script "~/.bin/update-screens"))
     (message "Running screen layout script: %s" layout-script)
     (start-process-shell-command "xrandr" nil layout-script)))

(defun dw/configure-desktop ()
  (interactive)
    (dw/run-xmodmap)
    (dw/update-screen-layout)
    (run-at-time "2 sec" nil (lambda () (dw/update-wallpapers))))

(defun dw/on-exwm-init ()
  (dw/configure-desktop)
  (dw/start-panel))

(when dw/exwm-enabled
  ;; Configure the desktop for first load
  (add-hook 'exwm-init-hook #'dw/on-exwm-init))

Panel

(defun dw/send-polybar-hook (name number)
  (start-process-shell-command "polybar-msg" nil (format "polybar-msg hook %s %s" name number)))

(defun dw/update-polybar-exwm (&optional path)
  (dw/send-polybar-hook "exwm" 1)
  (dw/send-polybar-hook "exwm-path" 1))

(defun dw/update-polybar-telegram ()
  (dw/send-polybar-hook "telegram" 1))

(defun dw/polybar-exwm-workspace ()
  (pcase exwm-workspace-current-index
    (0 "")
    (1 "")
    (2 "")
    (3 "")
    (4 "")))

(defun dw/polybar-exwm-workspace-path ()
  (let ((workspace-path (frame-parameter nil 'bufler-workspace-path-formatted)))
    (if workspace-path
        (substring-no-properties workspace-path)
      "")))

(defun dw/polybar-mail-count (max-count)
  (if (and dw/mail-enabled dw/mu4e-inbox-query)
    (let* ((mail-count (shell-command-to-string
                         (format "mu find --nocolor -n %s \"%s\" | wc -l" max-count dw/mu4e-inbox-query))))
      (format "%s" (string-trim mail-count)))
    ""))

(defun dw/telega-normalize-name (chat-name)
  (let* ((trimmed-name (string-trim-left (string-trim-right chat-name "}") "◀{"))
         (first-name (nth 0 (split-string trimmed-name " "))))
    first-name))

(defun dw/propertized-to-polybar (buffer-name)
  (if-let* ((text (substring-no-properties buffer-name))
            (fg-face (get-text-property 0 'face buffer-name))
            (fg-color (face-attribute fg-face :foreground)))
    (format "%%{F%s}%s%%{F-}" fg-color (dw/telega-normalize-name text))
    text))

(defun dw/polybar-telegram-chats ()
  (if (> (length tracking-buffers) 0)
    (format "%s" (string-join (mapcar 'dw/propertized-to-polybar tracking-buffers) ", "))
    ""))

(add-hook 'exwm-workspace-switch-hook #'dw/update-polybar-exwm)
(add-hook 'bufler-workspace-set-hook #'dw/update-polybar-exwm)

Keybindings

(when dw/exwm-enabled
  ;; These keys should always pass through to Emacs
  (setq exwm-input-prefix-keys
    '(?\C-x
      ?\C-h
      ?\M-x
      ?\M-`
      ?\M-&
      ?\M-:
      ?\C-\M-j  ;; Buffer list
      ?\C-\M-k  ;; Browser list
      ?\C-\M-n  ;; Next workspace
      ?\C-\M-'  ;; Popper toggle
      ?\C-\     ;; Ctrl+Space
      ?\C-\;))

  ;; Ctrl+Q will enable the next key to be sent directly
  (define-key exwm-mode-map [?\C-q] 'exwm-input-send-next-key)

  (defun exwm/run-vimb ()
    (exwm/run-in-background "vimb")
    (exwm-workspace-switch-create 2))

  (defun exwm/run-qute ()
    (exwm/run-in-background "qutebrowser")
    (exwm-workspace-switch-create 2))

  (exwm/bind-function
    "s-o" 'exwm/run-qute
    "s-q" 'kill-buffer)

  (exwm/bind-command
    "s-p" "playerctl play-pause"
    "s-[" "playerctl previous"
    "s-]" "playerctl next")

  (setup (:pkg desktop-environment)
    (desktop-environment-mode)
    (:option desktop-environment-brightness-small-increment "2%+"
             desktop-environment-brightness-small-decrement "2%-"
             desktop-environment-brightness-normal-increment "5%+"
             desktop-environment-brightness-normal-decrement "5%-"
             desktop-environment-screenshot-command "flameshot gui"))

  ;; This needs a more elegant ASCII banner
  (defhydra hydra-exwm-move-resize (:timeout 4)
    "Move/Resize Window (Shift is bigger steps, Ctrl moves window)"
    ("j" (lambda () (interactive) (exwm-layout-enlarge-window 10)) "V 10")
    ("J" (lambda () (interactive) (exwm-layout-enlarge-window 30)) "V 30")
    ("k" (lambda () (interactive) (exwm-layout-shrink-window 10)) "^ 10")
    ("K" (lambda () (interactive) (exwm-layout-shrink-window 30)) "^ 30")
    ("h" (lambda () (interactive) (exwm-layout-shrink-window-horizontally 10)) "< 10")
    ("H" (lambda () (interactive) (exwm-layout-shrink-window-horizontally 30)) "< 30")
    ("l" (lambda () (interactive) (exwm-layout-enlarge-window-horizontally 10)) "> 10")
    ("L" (lambda () (interactive) (exwm-layout-enlarge-window-horizontally 30)) "> 30")
    ("C-j" (lambda () (interactive) (exwm-floating-move 0 10)) "V 10")
    ("C-S-j" (lambda () (interactive) (exwm-floating-move 0 30)) "V 30")
    ("C-k" (lambda () (interactive) (exwm-floating-move 0 -10)) "^ 10")
    ("C-S-k" (lambda () (interactive) (exwm-floating-move 0 -30)) "^ 30")
    ("C-h" (lambda () (interactive) (exwm-floating-move -10 0)) "< 10")
    ("C-S-h" (lambda () (interactive) (exwm-floating-move -30 0)) "< 30")
    ("C-l" (lambda () (interactive) (exwm-floating-move 10 0)) "> 10")
    ("C-S-l" (lambda () (interactive) (exwm-floating-move 30 0)) "> 30")
    ("f" nil "finished" :exit t))

  ;; Workspace switching
  (setq exwm-input-global-keys
         `(([?\s-\C-r] . exwm-reset)
           ([?\s-w] . exwm-workspace-switch)
           ([?\s-i] . exwm-input-toggle-keyboard)
           ([?\s-r] . hydra-exwm-move-resize/body)
           ([?\s-e] . dired-jump)
           ([?\s-E] . (lambda () (interactive) (dired "~")))
           ([?\s-Q] . (lambda () (interactive) (kill-buffer)))
           ([?\s-`] . (lambda () (interactive) (exwm-workspace-switch-create 0)))
           ,@(mapcar (lambda (i)
                       `(,(kbd (format "s-%d" i)) .
                          (lambda ()
                           (interactive)
                           (exwm-workspace-switch-create ,i))))
                      (number-sequence 0 9))))

  (exwm-input-set-key (kbd "<s-return>") 'vterm)
  (exwm-input-set-key (kbd "s-SPC") 'app-launcher-run-app)
  (exwm-input-set-key (kbd "s-f") 'exwm-layout-toggle-fullscreen))

Useful Links

Panel via Polybar

I use Polybar to display a panel at the top of the primary screen to display my current EXWM workspace, CPU usage and temperature, battery status, time, and system tray. It uses some custom hooks back into Emacs via emacsclient.

.config/polybar/config:

; Docs: https://github.com/polybar/polybar
;==========================================================

[settings]
screenchange-reload = true

[global/wm]
margin-top = 0
margin-bottom = 0

[colors]
background = #f0232635
background-alt = #576075
foreground = #A6Accd
foreground-alt = #555
primary = #ffb52a
secondary = #e60053
alert = #bd2c40
underline-1 = #c792ea

[bar/panel]
width = 100%
height = <<get-setting(name="polybar/height")>>
offset-x = 0
offset-y = 0
fixed-center = true
enable-ipc = true

background = ${colors.background}
foreground = ${colors.foreground}

line-size = 2
line-color = #f00

border-size = 0
border-color = #00000000

padding-top = 5
padding-left = 1
padding-right = 1

module-margin = 1

font-0 = "Cantarell:size=<<get-setting(name="polybar/font-0-size")>>:weight=bold;2"
font-1 = "Font Awesome:size=<<get-setting(name="polybar/font-1-size")>>;2"
font-2 = "Material Icons:size=<<get-setting(name="polybar/font-2-size")>>;5"
font-3 = "Fira Mono:size=<<get-setting(name="polybar/font-3-size")>>;-3"

modules-left = exwm exwm-path
modules-center = spotify
modules-right = telegram mu4e cpu temperature battery date

tray-position = right
tray-padding = 2
tray-maxsize = 28

cursor-click = pointer
cursor-scroll = ns-resize

[module/exwm]
type = custom/ipc
hook-0 = emacsclient -e "(dw/polybar-exwm-workspace)" | sed -e 's/^"//' -e 's/"$//'
initial = 1
format-underline = ${colors.underline-1}
format-background = ${colors.background-alt}
format-padding = 1

[module/exwm-path]
type = custom/ipc
hook-0 = emacsclient -e "(dw/polybar-exwm-workspace-path)" | sed -e 's/^"//' -e 's/"$//'
format-foreground = #f78c6c
initial = 1

[module/spotify]
type = custom/script
exec = ~/.config/polybar/player-status.sh
interval = 3

[module/mu4e]
type = custom/ipc
hook-0 = emacsclient -e '(dw/polybar-mail-count 500)' | sed -e 's/^"//' -e 's/"$//'
initial = 1
format-underline = ${colors.underline-1}
click-left = emacsclient -e '(dw/go-to-inbox)'

[module/telegram]
type = custom/ipc
hook-0 = emacsclient -e '(dw/polybar-telegram-chats)' | sed -e 's/^"//' -e 's/"$//'
format-padding = 3
initial = 1

[module/xkeyboard]
type = internal/xkeyboard
blacklist-0 = num lock

format-prefix-font = 1
format-prefix-foreground = ${colors.foreground-alt}
format-prefix-underline = ${colors.underline-1}

label-layout = %layout%
label-layout-underline = ${colors.underline-1}

label-indicator-padding = 2
label-indicator-margin = 1
label-indicator-underline = ${colors.underline-1}

[module/cpu]
type = internal/cpu
interval = 2
format = <label> <ramp-coreload>
format-underline = ${colors.underline-1}
click-left = emacsclient -e "(proced)"
label = %percentage:2%%
ramp-coreload-spacing = 0
ramp-coreload-0 = ▁
ramp-coreload-0-foreground = ${colors.foreground-alt}
ramp-coreload-1 = ▂
ramp-coreload-2 = ▃
ramp-coreload-3 = ▄
ramp-coreload-4 = ▅
ramp-coreload-5 = ▆
ramp-coreload-6 = ▇

[module/memory]
type = internal/memory
interval = 2
format-prefix = "M:"
format-prefix-foreground = ${colors.foreground-alt}
format-underline = ${colors.underline-1}
label = %percentage_used%%

[module/date]
type = internal/date
interval = 5

date = "W%U: %a %b %e"
date-alt = "%A %B %d %Y"

time = %l:%M %p
time-alt = %H:%M:%S

format-prefix-foreground = ${colors.foreground-alt}
format-underline = ${colors.underline-1}

label = %date% %time%

[module/battery]
type = internal/battery
battery = BAT0
adapter = ADP1
full-at = 98
time-format = %-l:%M

label-charging = %percentage%% / %time%
format-charging = <animation-charging> <label-charging>
format-charging-underline = ${colors.underline-1}

label-discharging = %percentage%% / %time%
format-discharging = <ramp-capacity> <label-discharging>
format-discharging-underline = ${self.format-charging-underline}

format-full = <ramp-capacity> <label-full>
format-full-underline = ${self.format-charging-underline}

ramp-capacity-0 = 
ramp-capacity-1 = 
ramp-capacity-2 = 
ramp-capacity-3 = 
ramp-capacity-4 = 

animation-charging-0 = 
animation-charging-1 = 
animation-charging-2 = 
animation-charging-3 = 
animation-charging-4 = 
animation-charging-framerate = 750

[module/temperature]
type = internal/temperature
thermal-zone = 0
warn-temperature = 60

format = <label>
format-underline = ${colors.underline-1}
format-warn = <label-warn>
format-warn-underline = ${self.format-underline}

label = %temperature-c%
label-warn = %temperature-c%!
label-warn-foreground = ${colors.secondary}

I created a simple script to grab Spotify player information using playerctl:

.config/polybar/player-status.sh:

status="$(playerctl -p spotify status 2>&1)"
if [ "$status" != "No players found" ]
then
  artist="$(playerctl -p spotify metadata artist)"
  if [ "$artist" != "" ]
  then
    echo "$(playerctl -p spotify metadata artist) - $(playerctl -p spotify metadata title)"
  else
    # Clear any string that was previously displayed
    echo ""
  fi
else
  # Clear any string that was previously displayed
  echo ""
fi

Guix Packages

"polybar"

Desktop Notifications via Dunst

Dunst is a minimal interface for displaying desktop notifications. It is quite hackable but I’m not currently taking much advantage of its power. One useful feature is the ability to recall notification history; the keybinding is C-` in my configuration (though I’d prefer if I could invoke it from an Emacs keybinding somehow).

.config/dunst/dunstrc:

[global]
    ### Display ###
    monitor = 0

    # The geometry of the window:
    #   [{width}]x{height}[+/-{x}+/-{y}]
    geometry = "500x10-10+50"

    # Show how many messages are currently hidden (because of geometry).
    indicate_hidden = yes

    # Shrink window if it's smaller than the width.  Will be ignored if
    # width is 0.
    shrink = no

    # The transparency of the window.  Range: [0; 100].
    transparency = 10

    # The height of the entire notification.  If the height is smaller
    # than the font height and padding combined, it will be raised
    # to the font height and padding.
    notification_height = 0

    # Draw a line of "separator_height" pixel height between two
    # notifications.
    # Set to 0 to disable.
    separator_height = 1
    separator_color = frame

    # Padding between text and separator.
    padding = 8

    # Horizontal padding.
    horizontal_padding = 8

    # Defines width in pixels of frame around the notification window.
    # Set to 0 to disable.
    frame_width = 2

    # Defines color of the frame around the notification window.
    frame_color = "#89AAEB"

    # Sort messages by urgency.
    sort = yes

    # Don't remove messages, if the user is idle (no mouse or keyboard input)
    # for longer than idle_threshold seconds.
    idle_threshold = 120

    ### Text ###

    font = Cantarell <<get-setting(name="dunst/font-size")>>

    # The spacing between lines.  If the height is smaller than the
    # font height, it will get raised to the font height.
    line_height = 0
    markup = full

    # The format of the message.  Possible variables are:
    #   %a  appname
    #   %s  summary
    #   %b  body
    #   %i  iconname (including its path)
    #   %I  iconname (without its path)
    #   %p  progress value if set ([  0%] to [100%]) or nothing
    #   %n  progress value if set without any extra characters
    #   %%  Literal %
    # Markup is allowed
    format = "<b>%s</b>\n%b"

    # Alignment of message text.
    # Possible values are "left", "center" and "right".
    alignment = left

    # Show age of message if message is older than show_age_threshold
    # seconds.
    # Set to -1 to disable.
    show_age_threshold = 60

    # Split notifications into multiple lines if they don't fit into
    # geometry.
    word_wrap = yes

    # When word_wrap is set to no, specify where to make an ellipsis in long lines.
    # Possible values are "start", "middle" and "end".
    ellipsize = middle

    # Ignore newlines '\n' in notifications.
    ignore_newline = no

    # Stack together notifications with the same content
    stack_duplicates = true

    # Hide the count of stacked notifications with the same content
    hide_duplicate_count = false

    # Display indicators for URLs (U) and actions (A).
    show_indicators = yes

    ### Icons ###

    # Align icons left/right/off
    icon_position = left

    # Scale larger icons down to this size, set to 0 to disable
    max_icon_size = <<get-setting(name="dunst/max-icon-size")>>

    # Paths to default icons.
    icon_path = /home/daviwil/.guix-extra-profiles/desktop/desktop/share/icons/gnome/256x256/status/:/home/daviwil/.guix-extra-profiles/desktop/desktop/share/icons/gnome/256x256/devices/:/home/daviwil/.guix-extra-profiles/desktop/desktop/share/icons/gnome/256x256/emblems/

    ### History ###

    # Should a notification popped up from history be sticky or timeout
    # as if it would normally do.
    sticky_history = no

    # Maximum amount of notifications kept in history
    history_length = 20

    ### Misc/Advanced ###

    # Browser for opening urls in context menu.
    browser = qutebrowser

    # Always run rule-defined scripts, even if the notification is suppressed
    always_run_script = true

    # Define the title of the windows spawned by dunst
    title = Dunst

    # Define the class of the windows spawned by dunst
    class = Dunst

    startup_notification = false
    verbosity = mesg

    # Define the corner radius of the notification window
    # in pixel size. If the radius is 0, you have no rounded
    # corners.
    # The radius will be automatically lowered if it exceeds half of the
    # notification height to avoid clipping text and/or icons.
    corner_radius = 4

    mouse_left_click = close_current
    mouse_middle_click = do_action
    mouse_right_click = close_all

# Experimental features that may or may not work correctly. Do not expect them
# to have a consistent behaviour across releases.
[experimental]
    # Calculate the dpi to use on a per-monitor basis.
    # If this setting is enabled the Xft.dpi value will be ignored and instead
    # dunst will attempt to calculate an appropriate dpi value for each monitor
    # using the resolution and physical size. This might be useful in setups
    # where there are multiple screens with very different dpi values.
    per_monitor_dpi = false

[shortcuts]

    # Shortcuts are specified as [modifier+][modifier+]...key
    # Available modifiers are "ctrl", "mod1" (the alt-key), "mod2",
    # "mod3" and "mod4" (windows-key).
    # Xev might be helpful to find names for keys.

    # Close notification.
    #close = ctrl+space

    # Close all notifications.
    #close_all = ctrl+shift+space

    # Redisplay last message(s).
    # On the US keyboard layout "grave" is normally above TAB and left
    # of "1". Make sure this key actually exists on your keyboard layout,
    # e.g. check output of 'xmodmap -pke'
    history = ctrl+grave

    # Context menu.
    context = ctrl+shift+period

[urgency_low]
    # IMPORTANT: colors have to be defined in quotation marks.
    # Otherwise the "#" and following would be interpreted as a comment.
    background = "#222222"
    foreground = "#888888"
    timeout = 10
    # Icon for notifications with low urgency, uncomment to enable
    #icon = /path/to/icon

[urgency_normal]
    background = "#1c1f26"
    foreground = "#ffffff"
    timeout = 10
    # Icon for notifications with normal urgency, uncomment to enable
    #icon = /path/to/icon

[urgency_critical]
    background = "#900000"
    foreground = "#ffffff"
    frame_color = "#ff0000"
    timeout = 0
    # Icon for notifications with critical urgency, uncomment to enable
    #icon = /path/to/icon

Guix Packages

"dunst"
"libnotify"  ; For notify-send

Automatic Disk Mounting with Udiskie

Guix Packages

"udiskie"

Display Management

I use a script to automatically configure multiple displays with xrandr when I dock my laptops. This script invokes xrandr differently based on the hostname of the machine.

case $(hostname) in

    zerocool)
        xrandr --output VIRTUAL1 --off --output eDP1 --mode 2560x1440 --pos 3840x416 --rotate normal --output DP1 --off --output HDMI1 --off --output DP1-3 --off --output DP1-2 --off --output DP1-1 --primary --mode 3840x2160 --pos 0x0 --rotate normal --output DP2 --off
        ;;

    acidburn)
        xrandr --output eDP-1 --mode 2160x1350 --pos 2560x45 --rotate normal --output HDMI-1 --off --output DP-1 --off --output DP-2 --off --output DP-3 --off --output DP-4 --off --output DP-3-1 --off --output DP-3-2 --off --output DP-3-3 --off --output DP-3-1 --off --output DP-3-2 --off --output DP-3-3 --primary --mode 2560x1440 --pos 0x0 --rotate normal
        ;;

    davinci)
        # Temporary: this is for docking my laptop at home with HDMI!
        #xrandr --output HDMI-2 --mode 3840x2160 --pos 0x0 --scale 0.6x0.6 --primary --rotate normal --output HDMI-1 --off --output DP-1 --off --output eDP-1 --mode 1920x1080 --pos 2304x216 --rotate normal --output DP-2 --off
        xrandr --output eDP-1 --mode 1920x1080 --pos 2560x360 --rotate normal --output DP-1-2 --primary --mode 2560x1440 --pos 0x0 --rotate normal --output HDMI-2 --off --output HDMI-1 --off --output DP-1 --off --output DP-1-3 --off --output DP-2 --off --output DP-1-1 --off
        ;;

    phantom)
        # On a new install, run this command first to ensure HDMI works!
        # xrandr --setprovideroutputsource nouveau modesetting
        xrandr --output eDP-1 --primary --mode 3840x2160 --pos 0x0 --rotate normal --output eDP-1-2 --off --output HDMI-1-1 --mode 3840x2160 --pos 3840x0 --rotate normal --output DP-1-1 --off --output DP-1-2 --off
        ;;

esac

Default Applications

The file .config/mimeapps.list configures default applications for various content types. Right now I’m using it to control which browser opens URLs from other applications.

[Default Applications]
text/html=qutebrowser.desktop
x-scheme-handler/http=qutebrowser.desktop
x-scheme-handler/https=qutebrowser.desktop
x-scheme-handler/about=qutebrowser.desktop
x-scheme-handler/unknown=qutebrowser.desktop

User Services

I use GNU Shepherd to manage services that run in the background when I log in.

(define gpg-agent
  (make <service>
    #:provides '(gpg-agent)
    #:respawn? #t
    #:start (make-system-constructor "gpg-connect-agent /bye")
    #:stop (make-system-destructor "gpgconf --kill gpg-agent")))

(define mcron
  (make <service>
    #:provides '(mcron)
    #:respawn? #t
    #:start (make-forkexec-constructor '("mcron"))
    #:stop  (make-kill-destructor)))

(define syncthing
  (make <service>
    #:provides '(syncthing)
    #:respawn? #t
    #:start (make-forkexec-constructor '("syncthing" "-no-browser"))
    #:stop  (make-kill-destructor)))

(define pulseaudio
  (make <service>
    #:provides '(pulseaudio)
    #:respawn? #t
    #:start (make-forkexec-constructor '("pulseaudio"))
    #:stop  (make-kill-destructor)))

(register-services gpg-agent mcron syncthing pulseaudio)
(action 'shepherd 'daemonize)

;; Start user services
(for-each start '(gpg-agent mcron syncthing pulseaudio))

Scheduled Tasks

I use GNU mcron for scheduling tasks to run periodically in the background.

Syncing Passwords

(job
   '(next-hour (range 0 24 4))
   "~/.bin/sync-passwords")

Guix Packages

"mcron"

Applications

Browsers

Guix Packages

"vimb"
"qutebrowser"

Qutebrowser

Qutebrowser is a great keyboard-centric browser which uses the Chromium rendering engine via QT 5’s WebEngine component. I’ve configured it to act more like Vimb for window-per-tab behavior that integrates well into Emacs. One thing I like about this browser is that it does a much better job of remembering what windows you had open when it exits so that you can maintain your session more easily. I also like that when you reopen a tab/window, the history of that window is still present.

# Open every tab as a new window, Vimb style
c.tabs.tabs_are_windows = True
c.tabs.show = "multiple"
c.tabs.last_close = "close"

c.auto_save.session = True
c.scrolling.smooth = True
c.session.lazy_restore = True
c.content.autoplay = False

# Scale pages and UI better for hidpi
c.zoom.default = "<<get-setting(name="qutebrowser/default-zoom")>>%"
c.fonts.hints = "bold 20pt monospace"

# Better default fonts
c.fonts.web.family.standard = "Bitstream Vera Sans"
c.fonts.web.family.serif = "Bitstream Vera Serif"
c.fonts.web.family.sans_serif = "Bitstream Vera Sans"
c.fonts.web.family.fixed = "Fira Mono"
c.fonts.statusbar = "18pt Cantarell"

# Use dark mode where possible
c.colors.webpage.darkmode.enabled = True
c.colors.webpage.darkmode.policy.images = "never"
c.colors.webpage.bg = "black"

# Automatically turn on insert mode when a loaded page focuses a text field
c.input.insert_mode.auto_load = True

# Edit fields in Emacs with Ctrl+E
c.editor.command = ["emacsclient", "+{line}:{column}", "{file}"]

# Make Ctrl+g quit everything like in Emacs
config.bind('<Ctrl-g>', 'leave-mode', mode='insert')
config.bind('<Ctrl-g>', 'leave-mode', mode='command')
config.bind('<Ctrl-g>', 'leave-mode', mode='prompt')
config.bind('<Ctrl-g>', 'leave-mode', mode='hint')
config.bind('v', 'spawn ~/.dotfiles/bin/umpv {url}')
config.bind('V', 'hint links spawn ~/.dotfiles/bin/umpv {hint-url}')

# Tweak some keybindings
config.unbind('d') # Don't close window on lower-case 'd'
config.bind('yy', 'yank')

# Vim-style movement keys in command mode
config.bind('<Ctrl-j>', 'completion-item-focus --history next', mode='command')
config.bind('<Ctrl-k>', 'completion-item-focus --history prev', mode='command')

# More binding hints here: https://gitlab.com/Kaligule/qutebrowser-emacs-config/blob/master/config.py

# Load the autoconfig file (quteconfig.py)
config.load_autoconfig()
1p https://my.1password.com/vaults/kyxq62du37adb3lpjh2sphdq4i/allitems/tkr5tuo4gqyuco4x25upt6iaia
gn https://github.com/notifications
dot https://github.com/daviwil/dotfiles
efs https://github.com/daviwil/emacs-from-scratch
sc https://github.com/SystemCrafters
scv https://github.com/SystemCrafters/video-planning
ddg https://duckduckgo.com/?q $0
gh https://github.com/$0
gm https://www.iro.umontreal.ca/~gambit/doc/gambit.html
gam https://github.com/gambit/gambit
zig https://github.com/ziglang/zig
zigd https://ziglang.org/documentation/master/
zigl https://ziglang.org/documentation/master/std
sub https://github.com/substratic/
sube https://github.com/substratic/engine
subb https://github.com/substratic/build
subf https://github.com/substratic/forge
subc https://github.com/substratic/crash-the-stack
tspl https://scheme.com/tspl4/
mail https://fastmail.com
cups http://localhost:631
az https://portal.azure.com
azdo https://dev.azure.com/azure-sdk/
ajs https://github.com/Azure/azure-sdk-for-js
adl https://github.com/Azure/adl
dajs https://github.com/daviwil/azure-sdk-for-js
anet https://github.com/Azure/azure-sdk-for-net
aja https://github.com/Azure/azure-sdk-for-java
apy https://github.com/Azure/azure-sdk-for-python
ats https://github.com/Azure/autorest.typescript
ats3 https://github.com/Azure/autorest.typescript.v3
atest https://github.com/Azure/autorest.testserver
amf https://github.com/Azure/autorest.modelerfour
ar https://github.com/Azure/autorest
arpy https://github.com/Azure/autorest.python
arc https://github.com/Azure/autorest.csharp
are https://github.com/Azure/autorest/tree/master/docs/extensions
arp https://github.com/orgs/Azure/projects/48
ac https://github.com/Azure/autorest.compare
ap https://github.com/Azure/perks
specs https://github.com/Azure/azure-rest-api-specs
oai2 https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md
oai3 https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.3.md
npm https://www.npmjs.com/search?q $0
oms https://outlook.com/microsoft.com
msw https://microsoft.sharepoint.com

vimb

I used Vimb for a while because the latest Qutebrowser wasn’t available in Guix’s package repository, but since that problem has since been solved I’ve switched back to Qutebrowser as primary. Keeping this configuration around in case I need it again.

# Set the home page to a local file
set home-page=file:///home/daviwil/.config/vimb/home.html

# Use home-row keys for hints
set hint-keys=asdfg;lkjh
set hint-match-element=false
set hint-keys-same-length=true
set hint-timeout=0

# Enable smooth scrolling
set smooth-scrolling=true

# Fake a Chromium User-Agent header
#set user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36
set user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.87 Safari/537.36

# Set download directory
set download-path=~/Downloads

# If enabled the inputbox will be hidden whenever it contains no text
set input-autohide=true

# Set the default zoom
set default-zoom=<<get-setting(name="vimb/default-zoom")>>

# Hint sites to use dark themes
set dark-mode=on

# Use Emacs as the external editor
set editor-command=emacsclient

# Enable support for WebGL
set webgl=true

# While typing a search command, show where the pattern typed so far matches.
set incsearch=true

# Enable developer tools (binding is gF)
set webinspector=true

# Turn off dark mode on some sites
au LoadCommitted https://outlook.office.com/* set dark-mode=off

# Keybindings
# - 'e' edits URL in current window
# - 'E' edits URL in new window
# - 'O' opens URL in new window
# - 'H' navigates back
# - 'L' navigates forward
# - 'D' closes the window
# - 'C-g' exits command and input mode
# - 'C-j' and 'C-k' move down and up command selections
nn e O
nn E T
nm O :tabopen<Space>
nn H <C-O>
nn L <C-I>
nm D :q<CR>
ino <C-G> <Esc>
cno <C-J> <Tab>
cno <C-K> <S-Tab>

# Zoom keys
nmap + zI
nmap - zO
nmap = zz

# Shortcuts
shortcut-add gn=https://github.com/notifications
shortcut-add dot=https://github.com/daviwil/dotfiles
shortcut-add ddg=https://duckduckgo.com/?q=$0
shortcut-add gh=https://github.com/$0
shortcut-add gm=https://www.iro.umontreal.ca/~gambit/doc/gambit.html
shortcut-add gam=https://github.com/gambit/gambit
shortcut-add zig=https://github.com/ziglang/zig
shortcut-add zigd=https://ziglang.org/documentation/master/
shortcut-add zigl=https://ziglang.org/documentation/master/std
shortcut-add sub=https://github.com/substratic/
shortcut-add sube=https://github.com/substratic/engine
shortcut-add subb=https://github.com/substratic/build
shortcut-add subf=https://github.com/substratic/forge
shortcut-add subc=https://github.com/substratic/crash-the-stack
shortcut-add tspl=https://scheme.com/tspl4/
shortcut-add mail=https://fastmail.com
shortcut-add cups=http://localhost:631
shortcut-add az=https://portal.azure.com
shortcut-add azdo=https://dev.azure.com/azure-sdk/
shortcut-add ajs=https://github.com/Azure/azure-sdk-for-js
shortcut-add dajs=https://github.com/daviwil/azure-sdk-for-js
shortcut-add anet=https://github.com/Azure/azure-sdk-for-net
shortcut-add aja=https://github.com/Azure/azure-sdk-for-java
shortcut-add apy=https://github.com/Azure/azure-sdk-for-python
shortcut-add ats=https://github.com/Azure/autorest.typescript
shortcut-add ats3=https://github.com/Azure/autorest.typescript.v3
shortcut-add atest=https://github.com/Azure/autorest.testserver
shortcut-add amf=https://github.com/Azure/autorest.modelerfour
shortcut-add ar=https://github.com/Azure/autorest
shortcut-add arpy=https://github.com/Azure/autorest.python
shortcut-add arc=https://github.com/Azure/autorest.csharp
shortcut-add are=https://github.com/Azure/autorest/tree/master/docs/extensions
shortcut-add arp=https://github.com/orgs/Azure/projects/48
shortcut-add ac=https://github.com/Azure/autorest.compare
shortcut-add ap=https://github.com/Azure/perks
shortcut-add specs=https://github.com/Azure/azure-rest-api-specs
shortcut-add oai2=https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md
shortcut-add oai3=https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.3.md
shortcut-add npm=https://www.npmjs.com/search?q=$0
shortcut-add oms=https://outlook.com/microsoft.com
shortcut-add msw=https://microsoft.sharepoint.com
shortcut-add man=https://fanglingsu.github.io/vimb/man.html

# A newline is needed at EOF because each line is executed like a command as if the user typed it and pressed Enter.

Mail

Password Management

Guix Packages

"password-store"

Syncing Passwords

pass git pull
pass git push

notify-send -i "emblem-synchronizing" "Passwords synced!"

Audio Device Control

Guix Packages

"alsa-utils"
"pavucontrol"

Media Players

mpv

mpv is a simple yet powerful video player. Paired with youtube-dl it can even stream YouTube videos. mpv-mpris allows playback control via playerctl.

.config/mpv/mpv.conf

# Configure playback quality
vo=gpu
hwdec=vaapi
profile=gpu-hq
scale=ewa_lanczossharp
cscale=ewa_lanczossharp

# Start the window in the upper right screen corner
geometry=22%-30+20

# Save video position on quit
save-position-on-quit

# Enable control by MPRIS
script=~/.guix-extra-profiles/desktop/desktop/lib/mpris.so

# Limit the resolution of YouTube videos
ytdl=yes
ytdl-format=bestvideo[height<=?720]+bestaudio/best

# When playing audio files, display the album art
audio-display=attachment

# Keep the player open after the file finishes
keep-open

Guix Packages

"mpv"
"mpv-mpris"
"youtube-dl"
"playerctl"

Codecs and Drivers

These packages are needed to enable many video formats to be played in browsers and video players. VAAPI drivers are also used to enable hardware-accelerated video decoding.

Guix Packages

"gstreamer"
"gst-plugins-base"
"gst-plugins-good"
"gst-plugins-bad"
"gst-plugins-ugly"
"gst-libav"
"intel-vaapi-driver"
"libva-utils"

Image Viewers and Editors

Guix Packages

"feh"
"gimp"
"scrot"

Games

Glorious time wasters! I keep these in a separate Guix profile so that I don’t have them installed automatically on every machine. To opt in, I have to run activate-profiles games.

.config/guix/manifests/desktop.scm:

(specifications->manifest
 '("aisleriot"
   "gnome-mahjongg"))

Document Readers

# Automatically adjust the document to full width
set adjust-open width

# Set the title to the filename
set window-title-basename true

# Larger scroll steps with j/k
set scroll-step 150

# Adjusting the document
map [normal] E adjust_window best-fit
map [fullscreen] E adjust_window best-fit
map [normal] e adjust_window width
map [fullscreen] e adjust_window width

# Toggling the inverted colours
map <C-i> recolor
map <C-g> abort

Guix Packages

"zathura"
"zathura-pdf-mupdf"

Syncthing

Guix Packages

"syncthing"
"syncthing-gtk"

Flatpak

I use Flatpak and the Flathub repository to install applications that are otherwise difficult to install in Guix because of application frameworks, etc.

Applications to Install

flatpak remote-add --user --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
flatpak remote-add --user --if-not-exists flathub-beta https://flathub.org/beta-repo/flathub-beta.flatpakrepo
flatpak install --user flathub com.spotify.Client
flatpak install --user flathub com.valvesoftware.Steam
flatpak install --user flathub com.microsoft.Teams
flatpak install --user flathub com.discordapp.Discord
flatpak install --user flathub-beta com.obsproject.Studio

Guix Packages

"flatpak"

Printing

Guix Packages

"system-config-printer"

Desktop Tools

Guix Packages

"compton"
"redshift"
"gucharmap"
"fontmanager"
"brightnessctl"
"xdg-utils"      ;; For xdg-open, etc
"xdg-dbus-proxy" ;; For Flatpak
"gtk+:bin"       ;; For gtk-launch
"glib:bin"       ;; For gio-launch-desktop
"shared-mime-info"

System Tools

Guix Packages

"openssh"
"zip"
"unzip"
"trash-cli"

Xorg Tools

Guix Packages

"xev"
"xset"
"xrdb"
"xhost"
"xmodmap"
"setxkbmap"
"xrandr"
"arandr"
"xss-lock"
"libinput"
"xinput"

Desktop Profile

The desktop.scm manifest holds the list of packages that I use to configure my desktop environment. The package names are pulled from the relevant sections titled Guix Packages in this file (Desktop.org).

.config/guix/manifests/desktop.scm:

(specifications->manifest
 '(
   <<packages>>
))

Notes

Bluetooth Setup

If you need to manually connect to Bluetooth audio devices using bluetoothctl, as I currently do in Guix, you’ll need to enter these commands at the bluetoothctl prompt:

system-alias "my-hostname" # To configure your laptop's device name
default-agent
power on
scan on
# Wait for your device to appear
pair 04:52:C7:5E:5C:A8
trust 04:52:C7:5E:5C:A8 # To enable auto-connect
connect 04:52:C7:5E:5C:A8

Provide the dw-desktop package

(provide 'dw-desktop)