From d0070d81ee8ff43f39fe3103897ec4afd8d0382e Mon Sep 17 00:00:00 2001 From: SqrtMinusOne Date: Fri, 26 Nov 2021 17:10:55 +0300 Subject: [PATCH] upd --- .gitignore | 3 +- .gitmodules | 3 + content/configs/Desktop.md~ | 1056 ++++++++++++++++++----------- content/configs/Emacs.md~ | 193 +++++- content/configs/README.md | 6 +- org/configs/publish.el | 14 +- public/configs/readme/index.html | 6 +- public/stats/all.png | Bin 0 -> 121252 bytes public/stats/emacs-vim.png | Bin 0 -> 59052 bytes public/stats/literate-config.png | Bin 0 -> 63859 bytes repos/dotfiles | 1 + scripts/dot-stats-get-lengths.sh | 58 ++ scripts/dot-stats-plot-history.py | 191 ++++++ scripts/dot-stats-plot-lengths.py | 87 +++ scripts/palenight.mplstyle | 24 + static/stats/all.png | Bin 0 -> 121252 bytes static/stats/emacs-vim.png | Bin 0 -> 59052 bytes static/stats/literate-config.png | Bin 0 -> 63859 bytes update-configs.sh | 3 - 19 files changed, 1218 insertions(+), 427 deletions(-) create mode 100644 public/stats/all.png create mode 100644 public/stats/emacs-vim.png create mode 100644 public/stats/literate-config.png create mode 160000 repos/dotfiles create mode 100644 scripts/dot-stats-get-lengths.sh create mode 100644 scripts/dot-stats-plot-history.py create mode 100644 scripts/dot-stats-plot-lengths.py create mode 100644 scripts/palenight.mplstyle create mode 100644 static/stats/all.png create mode 100644 static/stats/emacs-vim.png create mode 100644 static/stats/literate-config.png delete mode 100755 update-configs.sh diff --git a/.gitignore b/.gitignore index c2114aa..e480265 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ org/configs/** -!org/configs/publish.el \ No newline at end of file +!org/configs/publish.el +/_data/ diff --git a/.gitmodules b/.gitmodules index e69de29..30b4152 100644 --- a/.gitmodules +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "repos/dotfiles"] + path = repos/dotfiles + url = git@github.com:SqrtMinusOne/dotfiles.git diff --git a/content/configs/Desktop.md~ b/content/configs/Desktop.md~ index f9c636b..ce17c59 100644 --- a/content/configs/Desktop.md~ +++ b/content/configs/Desktop.md~ @@ -58,28 +58,31 @@ Parts prefixed with (OFF) are not used, but kept for historic purposes. For some - [Keyboard Layout](#keyboard-layout) - [Autostart](#autostart) - [Polybar](#polybar) - - [Launching](#launching) - [General settings](#general-settings) - [Colors](#colors) - - [Bar config](#bar-config) - - [Modules](#modules) - - [ipstack-vpn](#ipstack-vpn) - - [weather](#weather) - - [aw-afk](#aw-afk) - - [pomm](#pomm) - - [sun](#sun) - - [SEP](#sep) - - [TSEP](#tsep) - - [i3](#i3) - - [xkeyboard](#xkeyboard) - - [mpd](#mpd) + - [Glyphs](#glyphs) + - [Modules](#modules) + - [Global bar config](#global-bar-config) + - [Launch script](#launch-script) + - [Individual modules](#individual-modules) - [pulseaudio](#pulseaudio) + - [mpd](#mpd) - [cpu](#cpu) - [ram-memory](#ram-memory) - [swap-memory](#swap-memory) - [network](#network) - - [date](#date) + - [ipstack-vpn](#ipstack-vpn) + - [openvpn](#openvpn) + - [xkeyboard](#xkeyboard) - [battery](#battery) + - [weather](#weather) + - [sun](#sun) + - [aw-afk](#aw-afk) + - [date](#date) + - [pomm](#pomm) + - [SEP](#sep) + - [TSEP](#tsep) + - [i3](#i3) - [Rofi](#rofi) - [Theme](#theme) - [Scripts](#scripts) @@ -228,11 +231,13 @@ Xft.dpi: <> A few programs I use to customize the apperance are listed below. -| Guix dependency | Description | -|--------------------|-------------------------| -| matcha-theme | My preferred GTK theme | -| papirus-icon-theme | My preferred Icon theme | -| xsettingsd | X11 settings daemon | +| Guix dependency | Description | +|-----------------------|-------------------------| +| matcha-theme | My preferred GTK theme | +| papirus-icon-theme | My preferred Icon theme | +| gnome-themes-standard | | +| xsettingsd | X11 settings daemon | +| gnome-themes-extra | | [xsettingsd](https://github.com/derat/xsettingsd) is a lightweight daemon which configures X11 applications. It is launched with shepherd in the [Services](#services) section. @@ -281,9 +286,9 @@ References: ### Xsession {#xsession} -First things first, Emacs has to be launched as a window manager. On a more conventional system, I'd create a .desktop file in some system folder that can be seen by a login manager, but in the case of Guix, it's a bit more complicated, because all such folders are not meant to be changed manually. +First things first, Emacs has to be launched as a window manager. On a more conventional system I'd create a .desktop file in some system folder that can be seen by a login manager, but in the case of Guix it's a bit more complicated, because all such folders are not meant to be changed manually. -However, GDM, the login manager that seems to default on Guix, launches `~/.xsession` on the startup if it's present, which is just fine for my purposes. +However, GDM, the login manager that seems to be the default on Guix, launches `~/.xsession` on the startup if it's present, which is just fine for my purposes. ```sh # Source .profile @@ -385,9 +390,6 @@ And a function to move windows with the following behavior: Something like this also goes for resizing windows. I'm used to the i3 "mode" for this functionality, and this seems to be a sensible approach. ```emacs-lisp -(use-package transient - :straight t) - (setq my/exwm-resize-value 5) (defun my/exwm-resize-window (dir kind &optional value) @@ -429,6 +431,9 @@ Also, a transient for shortcuts for the most frequent apps. I wanted to make the interactive lambda a macro, but this doesn't seem to work the way I expect, so the code has a bit of duplication. ```emacs-lisp +(use-package transient + :straight t) + (defun my/run-in-background (command) (let ((command-parts (split-string command "[ ]+"))) (apply #'call-process `(,(car command-parts) nil 0 nil ,@(cdr command-parts))))) @@ -470,9 +475,8 @@ Store the information about which workspace is available on which monitor. (setq my/exwm-monitor-workspace '()) (defun my/exwm-get-current-monitor () - (let* ((info (shell-command-to-string "xdotool getmouselocation --shell | head -n 1")) - (coord (string-to-number (substring info 2)))) - (if (> coord 1920) 1 0))) + (if (plist-get exwm-randr-workspace-monitor-plist exwm-workspace-current-index) + 1 0)) (defun my/exwm-update-current-monitor () (setf (alist-get (my/exwm-get-current-monitor) my/exwm-monitor-workspace) @@ -482,7 +486,7 @@ Store the information about which workspace is available on which monitor. #'my/exwm-update-current-monitor) ``` -Switch to the opposite monitor. +Switch to the opposite monitor. For now, this works only for two monitors because I don't have more. ```emacs-lisp (defun my/exwm-switch-to-other-monitor () @@ -491,7 +495,9 @@ Switch to the opposite monitor. (other (seq-some (lambda (m) (and (not (= (car m) current)) (cdr m))) - my/exwm-monitor-workspace))) + my/exwm-monitor-workspace)) + (focus-follows-mouse nil) + (mouse-autoselect-window nil)) (exwm-workspace-switch other))) ``` @@ -682,6 +688,8 @@ And keybindings that are available in both `char-mode` and `line-mode`: ;; Basic controls (,(kbd "") . ,(my/app-command "ponymix increase 5 --max-volume 150")) (,(kbd "") . ,(my/app-command "ponymix decrease 5 --max-volume 150")) + (,(kbd "") . ,(my/app-command "light -A 5")) + (,(kbd "") . ,(my/app-command "light -U 5")) (,(kbd "") . ,(my/app-command "ponymix toggle")) (,(kbd "") . ,(my/app-command "mpc toggle")) @@ -756,6 +764,7 @@ Show current workspace in the modeline. 'face `(foreground-color . ,(doom-color 'yellow))) "]")) + (setq my/exwm-mode-line-info-no-props (funcall exwm-workspace-index-map exwm-workspace-current-index)) (force-mode-line-update)) (add-hook 'exwm-workspace-switch-hook #'my/exwm-mode-line-info-update) @@ -1468,7 +1477,312 @@ References: - [polybar docs](https://github.com/polybar/polybar/wiki) -### Launching {#launching} +### General settings {#general-settings} + + +#### Colors {#colors} + +First, let's use xrdb colors in polybar. To avoid code duplication, I generate them via noweb. + + +```emacs-lisp +(mapconcat + (lambda (elem) + (format "%s = ${xrdb:%s}" (nth 0 elem) (nth 1 elem))) + (seq-filter + (lambda (elem) (nth 1 elem)) + table) + "\n") +``` + +```ini +[colors] +<> + +background = ${xrdb:background} +; foreground = ${xrdb:foreground} +``` + + +#### Glyphs {#glyphs} + +Also, let's try to use some glyphs. The [polybar-themes](https://github.com/adi1090x/polybar-themes) repository can give some inspiration on what is possible, here I am replicating a powerline-ish look. + +Although polybar makes it a bit more awkward than it could've been. The approach is to put a glyph between two blocks like this: + +```text +block1  block2 +``` + +And set the colors like that: + +| | block1 | glyph | block 2 | +|------------|--------|-------|---------| +| foreground | F1 | B2 | F2 | +| background | B1 | B1 | B2 | + +So, let's define the glyph symbols: + +```ini +[glyph] +gleft =  +gright =  +``` + + +#### Modules {#modules} + +To make life a bit easier, I'll define a single source of truth for modules and their colors here. + +So, here is a table with all modules. + + + +| Index | Module | Color | Glyph | +|-------|-------------|---------------|-------| +| 1 | pulseaudio | light-magenta | + | +| 2 | mpd | magenta | + | +| 3 | cpu | cyan | + | +| 4 | ram-memory | light-green | + | +| 5 | swap-memory | green | + | +| 6 | network | light-red | + | +| 7 | openvpn | light-red | | +| 8 | xkeyboard | red | + | +| 9 | battery | green | + | +| 10 | weather | light-yellow | + | +| 12 | sun | yellow | + | +| 13 | aw-afk | light-blue | + | +| 14 | date | blue | + | + +Some functions to use colors in the individual modules: + + +```emacs-lisp +(format + "${colors.%s}" + (nth + 2 + (seq-find + (lambda (el) (string-equal (nth 1 el) module)) + table))) +``` + + +```emacs-lisp +"${colors.black}" +``` + +Also, I want to exclude some modules from certain monitors and machines. For now this concerns just the battery module, so I exclude it from the monitors of my desktop PC. In future I may need to rework this to include hostname, but as long as all my machines have separate monitor names, it works fine. + + + +| Monitor | Exclude | +|----------|---------| +| DVI-D-0 | battery | +| HDMI-A-0 | battery | + +Now, we need to generate a set of glyphs. The code below generates all the required glyhps so that every combination of neighoring colors in the bar had one. + + + +| Color 1 | Color 2 | +|------------|---------------| +| background | white | +| background | light-magenta | +| blue | background | + + +```emacs-lisp +(let* ((monitors + (thread-last + exclude-table + (seq-map (lambda (el) (nth 0 el))) + (seq-uniq))) + (exclude-combinations + (seq-map + (lambda (monitor) + (seq-map + (lambda (el) (nth 1 el)) + (seq-filter + (lambda (el) (and (string-equal (nth 0 el) monitor) + (nth 1 el))) + exclude-table))) + `(,@monitors ""))) + (module-glyph-combinations + (thread-last + exclude-combinations + (seq-map + (lambda (exclude) + (thread-last + table + (seq-filter + (lambda (elt) + (not (or + (member (nth 1 elt) exclude) + (not (string-equal (nth 3 elt) "+")))))) + ;; (seq-map (lambda (elt) (nth 1 elt))) + ))) + (seq-uniq))) + (color-changes nil)) + (dolist (e extra) + (add-to-list + 'color-changes + (concat (nth 0 e) "--" (nth 1 e)))) + (dolist (comb module-glyph-combinations) + (dotimes (i (1- (length comb))) + (add-to-list + 'color-changes + (concat (nth 2 (nth i comb)) + "--" + (nth 2 (nth (1+ i) comb)))))) + (mapconcat + (lambda (el) + (let ((colors (split-string el "--"))) + (format " +[module/glyph-%s--%s] +type = custom/text +content-background = ${colors.%s} +content-foreground = ${colors.%s} +content = ${glyph.gright} +content-font = 5" + (nth 0 colors) + (nth 1 colors) + (nth 0 colors) + (nth 1 colors)))) + color-changes + "\n")) +``` + +```ini +<> +``` + +And a set of modules interweaved with corresponding glyphs for each monitor: + + +```emacs-lisp +(let* ((exclude-modules + (thread-last + exclude-table + (seq-filter (lambda (el) (string-equal (nth 0 el) monitor))) + (seq-map (lambda (el) (nth 1 el))))) + (modules + (thread-last + table + (seq-filter (lambda (el) (not (member (nth 1 el) exclude-modules)))))) + (prev-color first-color) + (ret nil)) + (concat + (mapconcat + (lambda (el) + (apply + #'concat + (list + (when (string-equal (nth 3 el) "+") + (setq ret (format "glyph-%s--%s " prev-color (nth 2 el))) + (setq prev-color (nth 2 el)) + ret) + (nth 1 el)))) + modules + " ") + (unless (string-empty-p last-color) (format " glyph-%s--%s " prev-color last-color)))) +``` + + +#### Global bar config {#global-bar-config} + +Global bar configuration. + +Monitor config and base colors. + +```ini +[bar/mybar] +monitor = ${env:MONITOR:} +width = 100% +height = ${env:HEIGHT:27} +fixed-center = false +bottom=true + +background = ${colors.background} +foreground = ${colors.black} +``` + +Some geometry settings. These are set this way to make glyphs look the way they should + +```ini +; line-size = 3 +line-color = #f00 + +padding = 0 + +module-margin-left = 0 +module-margin-right = 0 +margin-bottom = 0 +margin-top = 0 + +; underline-size = 0 +border-size = 0 + +offset-x = 0 +offset-y = 0 +radius = 0.0 +``` + +Fonts + +```ini +; font-0 = ${env:FONT0:pango:monospace:size=10;1} +; font-1 = ${env:FONT1:NotoEmoji:scale=10:antialias=false;0} +; font-2 = ${env:FONT2:fontawesome:pixelsize=10;1} +; font-3 = ${env:FONT3:JetBrains Mono Nerd Font:monospace:size=10;1} + +font-0 = pango:monospace:size=13;2 +font-1 = NotoEmoji:scale=10:antialias=false;1 +font-2 = fontawesome:pixelsize=13;3 +font-3 = JetBrains Mono Nerd Font:monospace:size=13;4 +font-4 = JetBrains Mono Nerd Font:monospace:size=17;4 +``` + +Modules. Because I sometimes set up different blocks on different monitors, they are set via environment variables. + +```ini +; modules-left = i3 +; modules-center = test +modules-right = ${env:RIGHT_BLOCKS} + +tray-position = ${env:TRAY:right} +tray-padding = 0 +tray-maxsize = 16 +tray-background = ${colors.background} + +wm-restack = i3 +; override-redirect = true + +scroll-up = i3wm-wsnext +scroll-down = i3wm-wsprev + +; cursor-click = pointer +; cursor-scroll = ns-resize +``` + +Misc settings. + +```ini +[settings] +screenchange-reload = true +compositing-background = source +compositing-foreground = over +compositing-overline = over +compositing-underline = over +compositing-border = over + +[global/wm] +margin-top = 0 +margin-bottom = 0 +``` + + +#### Launch script {#launch-script} The script below allows me to: @@ -1512,10 +1826,10 @@ declare -A BAR_HEIGHT=( ["HDMI-A-0"]="29" ) declare -A BLOCKS=( - ["eDP"]="pulseaudio mpd SEP cpu ram-memory swap-memory SEP network ipstack-vpn SEP xkeyboard SEP battery SEP sun aw-afk date TSEP" - ["eDP-1"]="pulseaudio mpd SEP cpu ram-memory swap-memory SEP network ipstack-vpn SEP xkeyboard SEP battery SEP sun aw-afk date TSEP" - ["DVI-D-0"]="pulseaudio mpd SEP cpu ram-memory swap-memory SEP network ipstack-vpn SEP xkeyboard SEP weather SEP sun aw-afk date TSEP" - ["HDMI-A-0"]="pulseaudio mpd SEP cpu ram-memory swap-memory SEP network ipstack-vpn SEP xkeyboard SEP weather SEP pomm sun aw-afk date TSEP" + ["eDP"]="<>" + ["eDP-1"]="<>" + ["DVI-D-0"]="<>" + ["HDMI-A-0"]="<>" ) # Geolocation for some modules @@ -1536,10 +1850,10 @@ for m in $(xrandr --query | grep " connected" | cut -d" " -f1); do if [[ -z "$SCALE" ]]; then continue fi - export FONT0="pango:monospace:size=$SIZE;1" - export FONT1="NotoEmoji:scale=$SCALE:antialias=false;1" - export FONT2="fontawesome:pixelsize=$SIZE;1" - export FONT3="JetBrains Mono Nerd Font:monospace:size=$SIZE;1" + # export FONT0="pango:monospace:size=$SIZE;1" + # export FONT1="NotoEmoji:scale=$SCALE:antialias=false;1" + # export FONT2="fontawesome:pixelsize=$SIZE;1" + # export FONT3="JetBrains Mono Nerd Font:monospace:size=15;1" export HEIGHT=${BAR_HEIGHT[$MONITOR]} export RIGHT_BLOCKS=${BLOCKS[$MONITOR]} polybar mybar & @@ -1547,106 +1861,181 @@ done ``` -### General settings {#general-settings} - - -#### Colors {#colors} - -```ini -[colors] -; Palenight colorscheme https://github.com/JonathanSpeek/palenight-iterm2 -black = ${xrdb:color0} -red = ${xrdb:color1} -green = ${xrdb:color2} -yellow = ${xrdb:color3} -blue = ${xrdb:color4} -magenta = ${xrdb:color5} -cyan = ${xrdb:color6} -white = ${xrdb:color7} - -black-lighter = ${xrdb:color8} -red-lighter = ${xrdb:color9} -green-lighter = ${xrdb:color10} -yellow-lighter = ${xrdb:color11} -blue-lighter = ${xrdb:color12} -magenta-lighter = ${xrdb:color13} -cyan-lighter = ${xrdb:color14} -white-lighter = ${xrdb:color15} - -background = ${xrdb:background} -foreground = ${xrdb:foreground} -``` - - -#### Bar config {#bar-config} - -```ini -[bar/mybar] -monitor = ${env:MONITOR:} -width = 100% -height = ${env:HEIGHT:27} -offset-x = 0 -offset-y = 0 -radius = 0.0 -fixed-center = false -bottom=true - -background = ${colors.background} -foreground = ${colors.foreground} - -line-size = 3 -line-color = #f00 - -padding-left = 0 -padding-right = 0 - -module-margin-left = 1 -module-margin-right = 1 - -font-0 = ${env:FONT0:pango:monospace:size=10;1} -font-1 = ${env:FONT1:NotoEmoji:scale=10:antialias=false;0} -font-2 = ${env:FONT2:fontawesome:pixelsize=10;1} -font-3 = ${env:FONT3:JetBrains Mono Nerd Font:monospace:size=10;1} - -modules-left = i3 -; modules-center = test -modules-right = ${env:RIGHT_BLOCKS} - -tray-position = ${env:TRAY:right} -tray-padding = 0 -tray-maxsize = 16 -;tray-background = #0063ff - -wm-restack = i3 -; override-redirect = true - -scroll-up = i3wm-wsnext -scroll-down = i3wm-wsprev - -; cursor-click = pointer -; cursor-scroll = ns-resize - -[settings] -screenchange-reload = true -;compositing-background = xor -;compositing-background = screen -;compositing-foreground = source -;compositing-border = over -;pseudo-transparency = false - -[global/wm] -margin-top = 0 -margin-bottom = 0 -``` - - -### Modules {#modules} +### Individual modules {#individual-modules} Some of the custom modules below use Org mode noweb to evaluate colors, because it's faster than querying `xrdb` at runtime. I wish I could reference polybar values there, but [it looks like this is impossible](https://github.com/polybar/polybar/issues/615). If you want to copy something, you can go to the [bin/polybar](bin/polybar/) folder. +#### pulseaudio {#pulseaudio} + +PulseAudio status + +```ini +[module/pulseaudio] +type = internal/pulseaudio +use-ui-max = true + +bar-volume-width = 7 +; bar-volume-foreground-0 = ${colors.white} +; bar-volume-foreground-1 = ${colors.yellow} +; bar-volume-foreground-2 = ${colors.yellow} +; bar-volume-foreground-3 = ${colors.blue} +; bar-volume-foreground-4 = ${colors.blue} +; bar-volume-foreground-5 = ${colors.green} +; bar-volume-foreground-6 = ${colors.green} +bar-volume-gradient = false +bar-volume-indicator = | +bar-volume-indicator-font = 2 +bar-volume-fill = ─ +bar-volume-fill-font = 2 +bar-volume-empty = ─ +bar-volume-empty-font = 2 +; bar-volume-empty-foreground = ${colors.light-white} + +format-volume = ♪ +label-volume = %percentage%% + +ramp-volume-0 = ▁ +ramp-volume-1 = ▂ +ramp-volume-2 = ▃ +ramp-volume-3 = ▄ +ramp-volume-4 = ▅ +ramp-volume-5 = ▆ +ramp-volume-6 = ▇ +ramp-volume-7 = █ + +format-muted = ♪ +label-muted = MUTE + +format-volume-background = <> +format-muted-background = <> + +; format-volume-underline = ${colors.white} +; format-muted-underline = ${colors.light-black} +``` + + +#### mpd {#mpd} + +[Music Player Daemon](https://www.musicpd.org/) status + +```ini +[module/mpd] +type = internal/mpd + +format-playing = +format-paused = +format-stopped = " " +label-song = [%album-artist%] %title% +label-time = %elapsed%/%total% + +label-song-maxlen = 30 +label-song-ellipsis = true + +; format-playing-underline = ${colors.yellow} +; format-paused-underline = ${colors.yellow} +; format-stopped-underline = ${colors.yellow} + +format-playing-background = <> +format-paused-background = <> +format-stopped-background = <> + +label-separator = 0 +separator-foreground = ${colors.red} + +icon-pause =  +icon-play =  +icon-stop =  +icon-prev = 1 +icon-next = 2 +``` + + +#### cpu {#cpu} + +CPU usage + +```ini +[module/cpu] +type = internal/cpu +format = "