openbsd-dotfiles

Base configurations for my Openbsd desktop
git clone https://git.kausban.com/openbsd-dotfiles/raw/.git
Log | Files | Refs

commit 54db43891fa9e18af0d6d877523d15ba272b32b7
parent a462df7d46a89183c2c0ac5c15464c8176baa8ed
Author: KB <mail@kausban.com>
Date:   Wed, 13 Dec 2023 19:01:37 +0100

st 0.9 and misc other changes

Diffstat:
M.bin/dvol | 33+++++++++++++++++++++------------
M.config/sxhkd/sxhkdrc.openbsd | 2+-
M.xsession | 2+-
Mports/st/config.h | 65++++++++++++++++++++++++++++++++++++++++++++++++++++-------------
Mports/st/openbsd_make.diff | 20+++++---------------
Mports/st/patch_script.sh | 10++++++----
Mports/st/patchlist.md | 17+++++++++--------
Aports/st/st-clipboard-0.8.3.diff | 12++++++++++++
Aports/st/st-font2-0.8.5.diff | 163+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Dports/st/st-font2-20190416-ba72400_edit.diff | 149-------------------------------------------------------------------------------
Dports/st/st-ligatures-boxdraw-20210824-0.8.4_edit.diff | 318-------------------------------------------------------------------------------
Aports/st/st-scrollback-mouse-altscreen-20220127-2c5edf2.diff | 78++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aports/st/st-xresources-20200604-9ba7ecf.diff | 184+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Dports/st/st-xresources-signal-reloading-20220407-ef05519.diff | 153-------------------------------------------------------------------------------
14 files changed, 532 insertions(+), 674 deletions(-)

diff --git a/.bin/dvol b/.bin/dvol @@ -18,18 +18,27 @@ function send_notification { case $1 in up) - # Set the volume on (if it was muted) - sndioctl output.mute=0 - # sndioctl output.level=+0.01 # Up the volume (+ 1%) - send_notification - ;; + # Set the volume on (if it was muted) + # sndioctl output.mute=0 + sndioctl output.level=+0.01 # Up the volume (+ 1%) + send_notification + ;; down) - sndioctl output.mute=0 - # sndioctl output.level=-0.01 - send_notification - ;; + # sndioctl output.mute=0 + sndioctl output.level=-0.01 + send_notification + ;; mute) - [ "$(sndioctl -n output.mute)" = "1" ] && dunstify -i audio-volume-muted -t 800 -r 2593 -u normal "Muted" \ - || send_notification - ;; + # dont actually run mute commands for server 0. Seems to work any way. + [ "$(sndioctl -n server.device)" = "0" ] || { [ "$(sndioctl -n output.mute)" = "1" ] && sndioctl -q output.mute=0 || sndioctl -q output.mute=1; } + + [ "$(sndioctl -n output.mute)" = "1" ] && dunstify -i audio-volume-muted -t 800 -r 2593 -u normal "Muted" \ + || send_notification + ;; + mic-mute) + [ "$(sndioctl -n input.mute)" = "1" ] && sndioctl input.mute=0 \ + || sndioctl input.mute=1 + [ "$(sndioctl -n input.mute)" = "1" ] && dunstify -i mic -t 800 -r 2593 -u normal "Mic Muted" \ + || dunstify -i mic -t 800 -r 2593 -u normal "Mic Open" + ;; esac diff --git a/.config/sxhkd/sxhkdrc.openbsd b/.config/sxhkd/sxhkdrc.openbsd @@ -58,7 +58,7 @@ XF86AudioMute XF86Audio{Raise,Lower}Volume dvol {up,down}; XF86AudioMicMute - amixer set Capture toggle; + dvol mic-mute; XF86Display displayselect XF86MonBrightness{Up,Down} diff --git a/.xsession b/.xsession @@ -17,7 +17,7 @@ xrandr --dpi 96 xsetroot -solid dimgray # ulimit for nextcloud -ulimit -n 7030 +ulimit -n 32768 # xidle will lock your display after a period of inactivity xidle -delay 5 -sw -program "/usr/local/bin/slock" -timeout 180 & diff --git a/ports/st/config.h b/ports/st/config.h @@ -5,13 +5,8 @@ * * font: see http://freedesktop.org/software/fontconfig/fontconfig-user.html */ -static char *font = "Liberation Mono:pixelsize=12:antialias=true:autohint=true"; -/* Spare fonts */ -static char *font2[] = { "JoyPixels:pixelsize=10:antialias=true:autohint=true" -/* "Inconsolata for Powerline:pixelsize=12:antialias=true:autohint=true", */ -/* "Hack Nerd Font Mono:pixelsize=11:antialias=true:autohint=true", */ -}; - +static char *font = "mono:pixelsize=14:antialias=true:autohint=true"; +static char *font2[] = { "JoyPixels:pixelsize=10:antialias=true:autohint=true" }; static int borderpx = 2; /* @@ -121,7 +116,7 @@ static const char *colorname[] = { "blue2", "magenta3", "cyan3", - "gray", + "gray90", /* 8 bright colors */ "gray50", @@ -147,10 +142,11 @@ static const char *colorname[] = { * Default colors (colorname index) * foreground, background, cursor, reverse cursor */ -unsigned int defaultfg = 258; -unsigned int defaultbg = 259; +unsigned int defaultfg = 259; +unsigned int defaultbg = 258; unsigned int defaultcs = 256; static unsigned int defaultrcs = 257; +unsigned int background = 258; /* * Default shape of cursor @@ -189,13 +185,50 @@ static unsigned int defaultattr = 11; static uint forcemousemod = ShiftMask; /* + * Xresources preferences to load at startup + */ +ResourcePref resources[] = { + { "font", STRING, &font }, + { "fontalt0", STRING, &font2[0] }, + { "color0", STRING, &colorname[0] }, + { "color1", STRING, &colorname[1] }, + { "color2", STRING, &colorname[2] }, + { "color3", STRING, &colorname[3] }, + { "color4", STRING, &colorname[4] }, + { "color5", STRING, &colorname[5] }, + { "color6", STRING, &colorname[6] }, + { "color7", STRING, &colorname[7] }, + { "color8", STRING, &colorname[8] }, + { "color9", STRING, &colorname[9] }, + { "color10", STRING, &colorname[10] }, + { "color11", STRING, &colorname[11] }, + { "color12", STRING, &colorname[12] }, + { "color13", STRING, &colorname[13] }, + { "color14", STRING, &colorname[14] }, + { "color15", STRING, &colorname[15] }, + { "background", STRING, &colorname[258] }, + { "foreground", STRING, &colorname[259] }, + { "cursorColor", STRING, &colorname[256] }, + { "termname", STRING, &termname }, + { "shell", STRING, &shell }, + { "minlatency", INTEGER, &minlatency }, + { "maxlatency", INTEGER, &maxlatency }, + { "blinktimeout", INTEGER, &blinktimeout }, + { "bellvolume", INTEGER, &bellvolume }, + { "tabspaces", INTEGER, &tabspaces }, + { "borderpx", INTEGER, &borderpx }, + { "cwscale", FLOAT, &cwscale }, + { "chscale", FLOAT, &chscale }, +}; + +/* * Internal mouse shortcuts. * Beware that overloading Button1 will disable the selection. */ static MouseShortcut mshortcuts[] = { /* mask button function argument release */ - { ShiftMask, Button4, kscrollup, {.i = 1} }, - { ShiftMask, Button5, kscrolldown, {.i = 1} }, + { XK_ANY_MOD, Button4, kscrollup, {.i = 1}, 0, /* !alt */ -1 }, + { XK_ANY_MOD, Button5, kscrolldown, {.i = 1}, 0, /* !alt */ -1 }, { XK_ANY_MOD, Button2, selpaste, {.i = 0}, 1 }, { ShiftMask, Button4, ttysend, {.s = "\033[5;2~"} }, { XK_ANY_MOD, Button4, ttysend, {.s = "\031"} }, @@ -205,7 +238,7 @@ static MouseShortcut mshortcuts[] = { /* Internal keyboard shortcuts. */ #define MODKEY Mod1Mask -#define TERMMOD (ControlMask|ShiftMask) +#define TERMMOD (Mod1Mask|ShiftMask) static Shortcut shortcuts[] = { /* mask keysym function argument */ @@ -216,8 +249,14 @@ static Shortcut shortcuts[] = { { TERMMOD, XK_Prior, zoom, {.f = +1} }, { TERMMOD, XK_Next, zoom, {.f = -1} }, { TERMMOD, XK_Home, zoomreset, {.f = 0} }, + { TERMMOD, XK_Up, zoom, {.f = +1} }, + { TERMMOD, XK_Down, zoom, {.f = -1} }, + { TERMMOD, XK_K, zoom, {.f = +1} }, + { TERMMOD, XK_J, zoom, {.f = -1} }, { TERMMOD, XK_C, clipcopy, {.i = 0} }, + { MODKEY, XK_c, clipcopy, {.i = 0} }, { TERMMOD, XK_V, clippaste, {.i = 0} }, + { MODKEY, XK_v, clippaste, {.i = 0} }, { TERMMOD, XK_Y, selpaste, {.i = 0} }, { ShiftMask, XK_Insert, selpaste, {.i = 0} }, { TERMMOD, XK_Num_Lock, numlock, {.i = 0} }, diff --git a/ports/st/openbsd_make.diff b/ports/st/openbsd_make.diff @@ -1,16 +1,6 @@ -diff -up a/config.mk b/config.mk ---- a/config.mk Fri Jan 7 12:41:35 2022 -+++ b/config.mk Fri Apr 29 23:13:28 2022 -@@ -5,7 +5,7 @@ VERSION = 0.8.5 - - # paths - PREFIX = /usr/local --MANPREFIX = $(PREFIX)/share/man -+MANPREFIX = $(PREFIX)/man - - X11INC = /usr/X11R6/include - X11LIB = /usr/X11R6/lib -@@ -26,10 +26,10 @@ STCFLAGS = $(INCS) $(STCPPFLAGS) $(CPPFLAGS) $(CFLAGS) +--- a/config.mk Tue Oct 4 19:41:26 2022 ++++ b/config.mk Wed Dec 13 18:38:47 2023 +@@ -26,11 +26,11 @@ STCFLAGS = $(INCS) $(STCPPFLAGS) $(CPPFLAGS) $(CFLAGS) STLDFLAGS = $(LIBS) $(LDFLAGS) # OpenBSD: @@ -18,12 +8,12 @@ diff -up a/config.mk b/config.mk -#LIBS = -L$(X11LIB) -lm -lX11 -lutil -lXft \ -# `$(PKG_CONFIG) --libs fontconfig` \ -# `$(PKG_CONFIG) --libs freetype2` +-#MANPREFIX = ${PREFIX}/man +CPPFLAGS = -DVERSION=\"$(VERSION)\" -D_XOPEN_SOURCE=600 -D_BSD_SOURCE +LIBS = -L$(X11LIB) -lm -lX11 -lutil -lXft \ + `$(PKG_CONFIG) --libs fontconfig` \ + `$(PKG_CONFIG) --libs freetype2` ++MANPREFIX = ${PREFIX}/man # compiler and linker # CC = c99 - -Diff finished. Fri Apr 29 23:14:49 2022 diff --git a/ports/st/patch_script.sh b/ports/st/patch_script.sh @@ -1,11 +1,13 @@ #!/usr/bin/env bash -srcdir="st-0.8.5" +srcdir="st-0.9" cp config.h "${srcdir}/config.h" patch -p1 -d ${srcdir} -i "../openbsd_make.diff" patch -p1 -d ${srcdir} -i "../st-scrollback-0.8.5.diff" patch -p1 -d ${srcdir} -i "../st-scrollback-mouse-20220127-2c5edf2.diff" -patch -p1 -d ${srcdir} -i "../st-xresources-signal-reloading-20220407-ef05519.diff" -patch -p1 -d ${srcdir} -i "../st-font2-20190416-ba72400_edit.diff" +patch -p1 -d ${srcdir} -i "../st-scrollback-mouse-altscreen-20220127-2c5edf2.diff" patch -p1 -d ${srcdir} -i "../st-boxdraw_v2-0.8.5.diff" -patch -p1 -d ${srcdir} -i "../st-ligatures-boxdraw-20210824-0.8.4_edit.diff" +patch -p1 -d ${srcdir} -i "../st-font2-0.8.5.diff" +patch -p1 -d ${srcdir} -i "../st-xresources-20200604-9ba7ecf.diff" +patch -p1 -d ${srcdir} -i "../st-clipboard-0.8.3.diff" + diff --git a/ports/st/patchlist.md b/ports/st/patchlist.md @@ -2,15 +2,16 @@ st ([suckless.org](https://st.suckless.org/)) 0.8.5 with following patches: -Source: https://dl.suckless.org/st/st-0.8.5.tar.gz +Source: https://dl.suckless.org/st/st-0.9.tar.gz patch_script.sh for patching all the diffs. 0. Changes to config.mk for openbsd. [openbsd_make.diff] -1. [scrollback](https://st.suckless.org/patches/scrollback/st-scrollback-0.8.5.diff) -2. [scrollback mouse](https://st.suckless.org/patches/scrollback/st-scrollback-mouse-20220127-2c5edf2.diff) -3. [xresources with signal reloading](https://st.suckless.org/patches/xresources-with-reload-signal/st-xresources-signal-reloading-20220407-ef05519.diff) -4. Editted font2 patch. [font2](https://st.suckless.org/patches/font2/st-font2-20190416-ba72400.diff) -5. [boxdraw](https://st.suckless.org/patches/boxdraw/st-boxdraw_v2-0.8.5.diff) -6. Editted ligatures patch. [ligatures](https://st.suckless.org/patches/ligatures/0.8.4/st-ligatures-boxdraw-20210824-0.8.4.diff) - +1. [scrollback](https://st.suckless.org/patches/scrollback/) + - [scrollback-0.8.5](https://st.suckless.org/patches/scrollback/st-scrollback-0.8.5.diff) + - [scrollback-mouse-20220127-2c5edf2](https://st.suckless.org/patches/scrollback/st-scrollback-mouse-20220127-2c5edf2.diff) + - [scrollback-mouse-altscreen-20220127-2c5edf2](https://st.suckless.org/patches/scrollback/st-scrollback-mouse-altscreen-20220127-2c5edf2.diff) +2. [boxdraw_v2-0.8.5](https://st.suckless.org/patches/boxdraw/) +3. [font2-0.8.5](https://st.suckless.org/patches/font2/) +4. [xresources-20200604-9ba7ecf](https://st.suckless.org/patches/xresources/) +5. [clipboard-0.8.3](https://st.suckless.org/patches/clipboard/) diff --git a/ports/st/st-clipboard-0.8.3.diff b/ports/st/st-clipboard-0.8.3.diff @@ -0,0 +1,12 @@ +diff --git a/x.c b/x.c +index e5f1737..5cabd60 100644 +--- a/x.c ++++ b/x.c +@@ -673,6 +673,7 @@ setsel(char *str, Time t) + XSetSelectionOwner(xw.dpy, XA_PRIMARY, xw.win, t); + if (XGetSelectionOwner(xw.dpy, XA_PRIMARY) != xw.win) + selclear(); ++ clipcopy(NULL); + } + + void diff --git a/ports/st/st-font2-0.8.5.diff b/ports/st/st-font2-0.8.5.diff @@ -0,0 +1,163 @@ +From 1635e04d3643dd4caa0c7c2043b585c6d7e4705f Mon Sep 17 00:00:00 2001 +From: Rizqi Nur Assyaufi <bandithijo@gmail.com> +Date: Mon, 18 Jul 2022 01:15:45 +0800 +Subject: [PATCH] [st][patch][font2] Add patch for st-0.8.5 + +--- + config.def.h | 6 +++ + x.c | 101 +++++++++++++++++++++++++++++++++++++++++++++++++++ + 2 files changed, 107 insertions(+) + +diff --git a/config.def.h b/config.def.h +index 91ab8ca..717b2f0 100644 +--- a/config.def.h ++++ b/config.def.h +@@ -6,6 +6,12 @@ + * font: see http://freedesktop.org/software/fontconfig/fontconfig-user.html + */ + static char *font = "Liberation Mono:pixelsize=12:antialias=true:autohint=true"; ++/* Spare fonts */ ++static char *font2[] = { ++/* "Inconsolata for Powerline:pixelsize=12:antialias=true:autohint=true", */ ++/* "Hack Nerd Font Mono:pixelsize=11:antialias=true:autohint=true", */ ++}; ++ + static int borderpx = 2; + + /* +diff --git a/x.c b/x.c +index 8a16faa..220fc4f 100644 +--- a/x.c ++++ b/x.c +@@ -157,6 +157,8 @@ static void xhints(void); + static int xloadcolor(int, const char *, Color *); + static int xloadfont(Font *, FcPattern *); + static void xloadfonts(const char *, double); ++static int xloadsparefont(FcPattern *, int); ++static void xloadsparefonts(void); + static void xunloadfont(Font *); + static void xunloadfonts(void); + static void xsetenv(void); +@@ -306,6 +308,7 @@ zoomabs(const Arg *arg) + { + xunloadfonts(); + xloadfonts(usedfont, arg->f); ++ xloadsparefonts(); + cresize(0, 0); + redraw(); + xhints(); +@@ -1034,6 +1037,101 @@ xloadfonts(const char *fontstr, double fontsize) + FcPatternDestroy(pattern); + } + ++int ++xloadsparefont(FcPattern *pattern, int flags) ++{ ++ FcPattern *match; ++ FcResult result; ++ ++ match = FcFontMatch(NULL, pattern, &result); ++ if (!match) { ++ return 1; ++ } ++ ++ if (!(frc[frclen].font = XftFontOpenPattern(xw.dpy, match))) { ++ FcPatternDestroy(match); ++ return 1; ++ } ++ ++ frc[frclen].flags = flags; ++ /* Believe U+0000 glyph will present in each default font */ ++ frc[frclen].unicodep = 0; ++ frclen++; ++ ++ return 0; ++} ++ ++void ++xloadsparefonts(void) ++{ ++ FcPattern *pattern; ++ double sizeshift, fontval; ++ int fc; ++ char **fp; ++ ++ if (frclen != 0) ++ die("can't embed spare fonts. cache isn't empty"); ++ ++ /* Calculate count of spare fonts */ ++ fc = sizeof(font2) / sizeof(*font2); ++ if (fc == 0) ++ return; ++ ++ /* Allocate memory for cache entries. */ ++ if (frccap < 4 * fc) { ++ frccap += 4 * fc - frccap; ++ frc = xrealloc(frc, frccap * sizeof(Fontcache)); ++ } ++ ++ for (fp = font2; fp - font2 < fc; ++fp) { ++ ++ if (**fp == '-') ++ pattern = XftXlfdParse(*fp, False, False); ++ else ++ pattern = FcNameParse((FcChar8 *)*fp); ++ ++ if (!pattern) ++ die("can't open spare font %s\n", *fp); ++ ++ if (defaultfontsize > 0) { ++ sizeshift = usedfontsize - defaultfontsize; ++ if (sizeshift != 0 && ++ FcPatternGetDouble(pattern, FC_PIXEL_SIZE, 0, &fontval) == ++ FcResultMatch) { ++ fontval += sizeshift; ++ FcPatternDel(pattern, FC_PIXEL_SIZE); ++ FcPatternDel(pattern, FC_SIZE); ++ FcPatternAddDouble(pattern, FC_PIXEL_SIZE, fontval); ++ } ++ } ++ ++ FcPatternAddBool(pattern, FC_SCALABLE, 1); ++ ++ FcConfigSubstitute(NULL, pattern, FcMatchPattern); ++ XftDefaultSubstitute(xw.dpy, xw.scr, pattern); ++ ++ if (xloadsparefont(pattern, FRC_NORMAL)) ++ die("can't open spare font %s\n", *fp); ++ ++ FcPatternDel(pattern, FC_SLANT); ++ FcPatternAddInteger(pattern, FC_SLANT, FC_SLANT_ITALIC); ++ if (xloadsparefont(pattern, FRC_ITALIC)) ++ die("can't open spare font %s\n", *fp); ++ ++ FcPatternDel(pattern, FC_WEIGHT); ++ FcPatternAddInteger(pattern, FC_WEIGHT, FC_WEIGHT_BOLD); ++ if (xloadsparefont(pattern, FRC_ITALICBOLD)) ++ die("can't open spare font %s\n", *fp); ++ ++ FcPatternDel(pattern, FC_SLANT); ++ FcPatternAddInteger(pattern, FC_SLANT, FC_SLANT_ROMAN); ++ if (xloadsparefont(pattern, FRC_BOLD)) ++ die("can't open spare font %s\n", *fp); ++ ++ FcPatternDestroy(pattern); ++ } ++} ++ + void + xunloadfont(Font *f) + { +@@ -1131,6 +1229,9 @@ xinit(int cols, int rows) + usedfont = (opt_font == NULL)? font : opt_font; + xloadfonts(usedfont, 0); + ++ /* spare fonts */ ++ xloadsparefonts(); ++ + /* colors */ + xw.cmap = XDefaultColormap(xw.dpy, xw.scr); + xloadcols(); +-- +2.37.1 + diff --git a/ports/st/st-font2-20190416-ba72400_edit.diff b/ports/st/st-font2-20190416-ba72400_edit.diff @@ -1,149 +0,0 @@ -diff -up a/config.def.h b/config.def.h ---- a/config.def.h Sat Apr 30 00:24:42 2022 -+++ b/config.def.h Sat Apr 30 00:24:42 2022 -@@ -6,6 +6,12 @@ - * font: see http://freedesktop.org/software/fontconfig/fontconfig-user.html - */ - static char *font = "Liberation Mono:pixelsize=12:antialias=true:autohint=true"; -+/* Spare fonts */ -+static char *font2[] = { -+/* "Inconsolata for Powerline:pixelsize=12:antialias=true:autohint=true", */ -+/* "Hack Nerd Font Mono:pixelsize=11:antialias=true:autohint=true", */ -+}; -+ - static int borderpx = 2; - - /* -diff -up a/x.c b/x.c ---- a/x.c Sat Apr 30 00:24:42 2022 -+++ b/x.c Sat Apr 30 00:29:09 2022 -@@ -160,6 +160,8 @@ static void xhints(void); - static int xloadcolor(int, const char *, Color *); - static int xloadfont(Font *, FcPattern *); - static void xloadfonts(const char *, double); -+static int xloadsparefont(FcPattern *, int); -+static void xloadsparefonts(void); - static void xunloadfont(Font *); - static void xunloadfonts(void); - static void xsetenv(void); -@@ -309,6 +311,7 @@ zoomabs(const Arg *arg) - { - xunloadfonts(); - xloadfonts(usedfont, arg->f); -+ xloadsparefonts(); - cresize(0, 0); - redraw(); - xhints(); -@@ -1037,7 +1040,102 @@ xloadfonts(const char *fontstr, double fontsize) - FcPatternDestroy(pattern); - } - -+int -+xloadsparefont(FcPattern *pattern, int flags) -+{ -+ FcPattern *match; -+ FcResult result; -+ -+ match = FcFontMatch(NULL, pattern, &result); -+ if (!match) { -+ return 1; -+ } -+ -+ if (!(frc[frclen].font = XftFontOpenPattern(xw.dpy, match))) { -+ FcPatternDestroy(match); -+ return 1; -+ } -+ -+ frc[frclen].flags = flags; -+ /* Believe U+0000 glyph will present in each default font */ -+ frc[frclen].unicodep = 0; -+ frclen++; -+ -+ return 0; -+} -+ - void -+xloadsparefonts(void) -+{ -+ FcPattern *pattern; -+ double sizeshift, fontval; -+ int fc; -+ char **fp; -+ -+ if (frclen != 0) -+ die("can't embed spare fonts. cache isn't empty"); -+ -+ /* Calculate count of spare fonts */ -+ fc = sizeof(font2) / sizeof(*font2); -+ if (fc == 0) -+ return; -+ -+ /* Allocate memory for cache entries. */ -+ if (frccap < 4 * fc) { -+ frccap += 4 * fc - frccap; -+ frc = xrealloc(frc, frccap * sizeof(Fontcache)); -+ } -+ -+ for (fp = font2; fp - font2 < fc; ++fp) { -+ -+ if (**fp == '-') -+ pattern = XftXlfdParse(*fp, False, False); -+ else -+ pattern = FcNameParse((FcChar8 *)*fp); -+ -+ if (!pattern) -+ die("can't open spare font %s\n", *fp); -+ -+ if (defaultfontsize > 0) { -+ sizeshift = usedfontsize - defaultfontsize; -+ if (sizeshift != 0 && -+ FcPatternGetDouble(pattern, FC_PIXEL_SIZE, 0, &fontval) == -+ FcResultMatch) { -+ fontval += sizeshift; -+ FcPatternDel(pattern, FC_PIXEL_SIZE); -+ FcPatternDel(pattern, FC_SIZE); -+ FcPatternAddDouble(pattern, FC_PIXEL_SIZE, fontval); -+ } -+ } -+ -+ FcPatternAddBool(pattern, FC_SCALABLE, 1); -+ -+ FcConfigSubstitute(NULL, pattern, FcMatchPattern); -+ XftDefaultSubstitute(xw.dpy, xw.scr, pattern); -+ -+ if (xloadsparefont(pattern, FRC_NORMAL)) -+ die("can't open spare font %s\n", *fp); -+ -+ FcPatternDel(pattern, FC_SLANT); -+ FcPatternAddInteger(pattern, FC_SLANT, FC_SLANT_ITALIC); -+ if (xloadsparefont(pattern, FRC_ITALIC)) -+ die("can't open spare font %s\n", *fp); -+ -+ FcPatternDel(pattern, FC_WEIGHT); -+ FcPatternAddInteger(pattern, FC_WEIGHT, FC_WEIGHT_BOLD); -+ if (xloadsparefont(pattern, FRC_ITALICBOLD)) -+ die("can't open spare font %s\n", *fp); -+ -+ FcPatternDel(pattern, FC_SLANT); -+ FcPatternAddInteger(pattern, FC_SLANT, FC_SLANT_ROMAN); -+ if (xloadsparefont(pattern, FRC_BOLD)) -+ die("can't open spare font %s\n", *fp); -+ -+ FcPatternDestroy(pattern); -+ } -+} -+ -+void - xunloadfont(Font *f) - { - XftFontClose(xw.dpy, f->match); -@@ -1133,6 +1231,9 @@ xinit(int cols, int rows) - - usedfont = (opt_font == NULL)? font : opt_font; - xloadfonts(usedfont, 0); -+ -+ /* spare fonts */ -+ xloadsparefonts(); - - /* colors */ - xw.cmap = XDefaultColormap(xw.dpy, xw.scr); diff --git a/ports/st/st-ligatures-boxdraw-20210824-0.8.4_edit.diff b/ports/st/st-ligatures-boxdraw-20210824-0.8.4_edit.diff @@ -1,318 +0,0 @@ -diff -up a/Makefile b/Makefile ---- a/Makefile Sat Apr 30 02:20:35 2022 -+++ b/Makefile Sat Apr 30 02:20:35 2022 -@@ -4,7 +4,7 @@ - - include config.mk - --SRC = st.c x.c boxdraw.c -+SRC = st.c x.c boxdraw.c hb.c - OBJ = $(SRC:.c=.o) - - all: options st -@@ -22,7 +22,8 @@ config.h: - $(CC) $(STCFLAGS) -c $< - - st.o: config.h st.h win.h --x.o: arg.h config.h st.h win.h -+x.o: arg.h config.h st.h win.h hb.h -+hb.o: st.h - boxdraw.o: config.h st.h boxdraw_data.h - - $(OBJ): config.h config.mk -diff -up a/config.mk b/config.mk ---- a/config.mk Sat Apr 30 02:20:35 2022 -+++ b/config.mk Sat Apr 30 02:21:14 2022 -@@ -15,10 +15,12 @@ PKG_CONFIG = pkg-config - # includes and libs - INCS = -I$(X11INC) \ - `$(PKG_CONFIG) --cflags fontconfig` \ -- `$(PKG_CONFIG) --cflags freetype2` -+ `$(PKG_CONFIG) --cflags freetype2` \ -+ `$(PKG_CONFIG) --cflags harfbuzz` - LIBS = -L$(X11LIB) -lm -lrt -lX11 -lutil -lXft \ - `$(PKG_CONFIG) --libs fontconfig` \ -- `$(PKG_CONFIG) --libs freetype2` -+ `$(PKG_CONFIG) --libs freetype2` \ -+ `$(PKG_CONFIG) --libs harfbuzz` - - # flags - STCPPFLAGS = -DVERSION=\"$(VERSION)\" -D_XOPEN_SOURCE=600 -@@ -29,7 +31,8 @@ STLDFLAGS = $(LIBS) $(LDFLAGS) - CPPFLAGS = -DVERSION=\"$(VERSION)\" -D_XOPEN_SOURCE=600 -D_BSD_SOURCE - LIBS = -L$(X11LIB) -lm -lX11 -lutil -lXft \ - `$(PKG_CONFIG) --libs fontconfig` \ -- `$(PKG_CONFIG) --libs freetype2` -+ `$(PKG_CONFIG) --libs freetype2` \ -+ `$(PKG_CONFIG) --libs harfbuzz` - - # compiler and linker - # CC = c99 -diff -up a/hb.c b/hb.c ---- a/hb.c Sat Apr 30 02:20:35 2022 -+++ b/hb.c Sat Apr 30 02:20:35 2022 -@@ -0,0 +1,148 @@ -+#include <stdlib.h> -+#include <stdio.h> -+#include <math.h> -+#include <X11/Xft/Xft.h> -+#include <hb.h> -+#include <hb-ft.h> -+ -+#include "st.h" -+ -+#define FEATURE(c1,c2,c3,c4) { .tag = HB_TAG(c1,c2,c3,c4), .value = 1, .start = HB_FEATURE_GLOBAL_START, .end = HB_FEATURE_GLOBAL_END } -+ -+void hbtransformsegment(XftFont *xfont, const Glyph *string, hb_codepoint_t *codepoints, int start, int length); -+hb_font_t *hbfindfont(XftFont *match); -+ -+typedef struct { -+ XftFont *match; -+ hb_font_t *font; -+} HbFontMatch; -+ -+static int hbfontslen = 0; -+static HbFontMatch *hbfontcache = NULL; -+ -+/* -+ * Replace 0 with a list of font features, wrapped in FEATURE macro, e.g. -+ * FEATURE('c', 'a', 'l', 't'), FEATURE('d', 'l', 'i', 'g') -+ */ -+hb_feature_t features[] = { 0 }; -+ -+void -+hbunloadfonts() -+{ -+ for (int i = 0; i < hbfontslen; i++) { -+ hb_font_destroy(hbfontcache[i].font); -+ XftUnlockFace(hbfontcache[i].match); -+ } -+ -+ if (hbfontcache != NULL) { -+ free(hbfontcache); -+ hbfontcache = NULL; -+ } -+ hbfontslen = 0; -+} -+ -+hb_font_t * -+hbfindfont(XftFont *match) -+{ -+ for (int i = 0; i < hbfontslen; i++) { -+ if (hbfontcache[i].match == match) -+ return hbfontcache[i].font; -+ } -+ -+ /* Font not found in cache, caching it now. */ -+ hbfontcache = realloc(hbfontcache, sizeof(HbFontMatch) * (hbfontslen + 1)); -+ FT_Face face = XftLockFace(match); -+ hb_font_t *font = hb_ft_font_create(face, NULL); -+ if (font == NULL) -+ die("Failed to load Harfbuzz font."); -+ -+ hbfontcache[hbfontslen].match = match; -+ hbfontcache[hbfontslen].font = font; -+ hbfontslen += 1; -+ -+ return font; -+} -+ -+void -+hbtransform(XftGlyphFontSpec *specs, const Glyph *glyphs, size_t len, int x, int y) -+{ -+ int start = 0, length = 1, gstart = 0; -+ hb_codepoint_t *codepoints = calloc((unsigned int)len, sizeof(hb_codepoint_t)); -+ -+ for (int idx = 1, specidx = 1; idx < len; idx++) { -+ if (glyphs[idx].mode & ATTR_WDUMMY) { -+ length += 1; -+ continue; -+ } -+ -+ if (specs[specidx].font != specs[start].font || ATTRCMP(glyphs[gstart], glyphs[idx]) || selected(x + idx, y) != selected(x + gstart, y)) { -+ hbtransformsegment(specs[start].font, glyphs, codepoints, gstart, length); -+ -+ /* Reset the sequence. */ -+ length = 1; -+ start = specidx; -+ gstart = idx; -+ } else { -+ length += 1; -+ } -+ -+ specidx++; -+ } -+ -+ /* EOL. */ -+ hbtransformsegment(specs[start].font, glyphs, codepoints, gstart, length); -+ -+ /* Apply the transformation to glyph specs. */ -+ for (int i = 0, specidx = 0; i < len; i++) { -+ if (glyphs[i].mode & ATTR_WDUMMY) -+ continue; -+ if (glyphs[i].mode & ATTR_BOXDRAW) { -+ specidx++; -+ continue; -+ } -+ -+ if (codepoints[i] != specs[specidx].glyph) -+ ((Glyph *)glyphs)[i].mode |= ATTR_LIGA; -+ -+ specs[specidx++].glyph = codepoints[i]; -+ } -+ -+ free(codepoints); -+} -+ -+void -+hbtransformsegment(XftFont *xfont, const Glyph *string, hb_codepoint_t *codepoints, int start, int length) -+{ -+ hb_font_t *font = hbfindfont(xfont); -+ if (font == NULL) -+ return; -+ -+ Rune rune; -+ ushort mode = USHRT_MAX; -+ hb_buffer_t *buffer = hb_buffer_create(); -+ hb_buffer_set_direction(buffer, HB_DIRECTION_LTR); -+ -+ /* Fill buffer with codepoints. */ -+ for (int i = start; i < (start+length); i++) { -+ rune = string[i].u; -+ mode = string[i].mode; -+ if (mode & ATTR_WDUMMY) -+ rune = 0x0020; -+ hb_buffer_add_codepoints(buffer, &rune, 1, 0, 1); -+ } -+ -+ /* Shape the segment. */ -+ hb_shape(font, buffer, features, sizeof(features)); -+ -+ /* Get new glyph info. */ -+ hb_glyph_info_t *info = hb_buffer_get_glyph_infos(buffer, NULL); -+ -+ /* Write new codepoints. */ -+ for (int i = 0; i < length; i++) { -+ hb_codepoint_t gid = info[i].codepoint; -+ codepoints[start+i] = gid; -+ } -+ -+ /* Cleanup. */ -+ hb_buffer_destroy(buffer); -+} -diff -up a/hb.h b/hb.h ---- a/hb.h Sat Apr 30 02:20:35 2022 -+++ b/hb.h Sat Apr 30 02:20:35 2022 -@@ -0,0 +1,6 @@ -+#include <X11/Xft/Xft.h> -+#include <hb.h> -+#include <hb-ft.h> -+ -+void hbunloadfonts(); -+void hbtransform(XftGlyphFontSpec *, const Glyph *, size_t, int, int); -diff -up a/st.c b/st.c ---- a/st.c Sat Apr 30 02:20:35 2022 -+++ b/st.c Sat Apr 30 02:20:35 2022 -@@ -2748,7 +2748,8 @@ draw(void) - drawregion(0, 0, term.col, term.row); - if (term.scr == 0) - xdrawcursor(cx, term.c.y, term.line[term.c.y][cx], -- term.ocx, term.ocy, term.line[term.ocy][term.ocx]); -+ term.ocx, term.ocy, term.line[term.ocy][term.ocx], -+ term.line[term.ocy], term.col); - term.ocx = cx; - term.ocy = term.c.y; - xfinishdraw(); -diff -up a/st.h b/st.h ---- a/st.h Sat Apr 30 02:20:35 2022 -+++ b/st.h Sat Apr 30 02:20:35 2022 -@@ -11,7 +11,8 @@ - #define DIVCEIL(n, d) (((n) + ((d) - 1)) / (d)) - #define DEFAULT(a, b) (a) = (a) ? (a) : (b) - #define LIMIT(x, a, b) (x) = (x) < (a) ? (a) : (x) > (b) ? (b) : (x) --#define ATTRCMP(a, b) ((a).mode != (b).mode || (a).fg != (b).fg || \ -+#define ATTRCMP(a, b) (((a).mode & (~ATTR_WRAP) & (~ATTR_LIGA)) != ((b).mode & (~ATTR_WRAP) & (~ATTR_LIGA)) || \ -+ (a).fg != (b).fg || \ - (a).bg != (b).bg) - #define TIMEDIFF(t1, t2) ((t1.tv_sec-t2.tv_sec)*1000 + \ - (t1.tv_nsec-t2.tv_nsec)/1E6) -@@ -34,6 +35,7 @@ enum glyph_attribute { - ATTR_WIDE = 1 << 9, - ATTR_WDUMMY = 1 << 10, - ATTR_BOXDRAW = 1 << 11, -+ ATTR_LIGA = 1 << 12, - ATTR_BOLD_FAINT = ATTR_BOLD | ATTR_FAINT, - }; - -diff -up a/win.h b/win.h ---- a/win.h Fri Jan 7 12:41:35 2022 -+++ b/win.h Sat Apr 30 02:20:35 2022 -@@ -25,7 +25,7 @@ enum win_mode { - - void xbell(void); - void xclipcopy(void); --void xdrawcursor(int, int, Glyph, int, int, Glyph); -+void xdrawcursor(int, int, Glyph, int, int, Glyph, Line, int); - void xdrawline(Line, int, int, int); - void xfinishdraw(void); - void xloadcols(void); -diff -up a/x.c b/x.c ---- a/x.c Sat Apr 30 02:20:35 2022 -+++ b/x.c Sat Apr 30 02:20:35 2022 -@@ -20,6 +20,7 @@ char *argv0; - #include "arg.h" - #include "st.h" - #include "win.h" -+#include "hb.h" - - /* types used in config.h */ - typedef struct { -@@ -1145,6 +1146,9 @@ xunloadfont(Font *f) - void - xunloadfonts(void) - { -+ /* Clear Harfbuzz font cache. */ -+ hbunloadfonts(); -+ - /* Free the loaded fonts in the font cache. */ - while (frclen > 0) - XftFontClose(xw.dpy, frc[--frclen].font); -@@ -1349,7 +1353,7 @@ xmakeglyphfontspecs(XftGlyphFontSpec *specs, const Gly - mode = glyphs[i].mode; - - /* Skip dummy wide-character spacing. */ -- if (mode == ATTR_WDUMMY) -+ if (mode & ATTR_WDUMMY) - continue; - - /* Determine font for glyph if different from previous glyph. */ -@@ -1461,6 +1465,9 @@ xmakeglyphfontspecs(XftGlyphFontSpec *specs, const Gly - numspecs++; - } - -+ /* Harfbuzz transformation for ligatures. */ -+ hbtransform(specs, glyphs, len, x, y); -+ - return numspecs; - } - -@@ -1614,14 +1621,17 @@ xdrawglyph(Glyph g, int x, int y) - } - - void --xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og) -+xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og, Line line, int len) - { - Color drawcol; - - /* remove the old cursor */ - if (selected(ox, oy)) - og.mode ^= ATTR_REVERSE; -- xdrawglyph(og, ox, oy); -+ -+ /* Redraw the line where cursor was previously. -+ * It will restore the ligatures broken by the cursor. */ -+ xdrawline(line, 0, oy, len); - - if (IS_SET(MODE_HIDE)) - return; diff --git a/ports/st/st-scrollback-mouse-altscreen-20220127-2c5edf2.diff b/ports/st/st-scrollback-mouse-altscreen-20220127-2c5edf2.diff @@ -0,0 +1,78 @@ +From 580e3f386e9215707100e9ba44797701943fd927 Mon Sep 17 00:00:00 2001 +From: asparagii <michele.lambertucci1@gmail.com> +Date: Thu, 27 Jan 2022 15:49:27 +0100 +Subject: [PATCH] st-scrollback-mouse-altscreen + +--- + config.def.h | 4 ++-- + st.c | 5 +++++ + st.h | 1 + + x.c | 2 ++ + 4 files changed, 10 insertions(+), 2 deletions(-) + +diff --git a/config.def.h b/config.def.h +index c217315..c223706 100644 +--- a/config.def.h ++++ b/config.def.h +@@ -176,8 +176,8 @@ static uint forcemousemod = ShiftMask; + */ + static MouseShortcut mshortcuts[] = { + /* mask button function argument release */ +- { ShiftMask, Button4, kscrollup, {.i = 1} }, +- { ShiftMask, Button5, kscrolldown, {.i = 1} }, ++ { XK_ANY_MOD, Button4, kscrollup, {.i = 1}, 0, /* !alt */ -1 }, ++ { XK_ANY_MOD, Button5, kscrolldown, {.i = 1}, 0, /* !alt */ -1 }, + { XK_ANY_MOD, Button2, selpaste, {.i = 0}, 1 }, + { ShiftMask, Button4, ttysend, {.s = "\033[5;2~"} }, + { XK_ANY_MOD, Button4, ttysend, {.s = "\031"} }, +diff --git a/st.c b/st.c +index f3af82b..876a6bf 100644 +--- a/st.c ++++ b/st.c +@@ -1060,6 +1060,11 @@ tnew(int col, int row) + treset(); + } + ++int tisaltscr(void) ++{ ++ return IS_SET(MODE_ALTSCREEN); ++} ++ + void + tswapscreen(void) + { +diff --git a/st.h b/st.h +index da36b34..e95c6f8 100644 +--- a/st.h ++++ b/st.h +@@ -89,6 +89,7 @@ void sendbreak(const Arg *); + void toggleprinter(const Arg *); + + int tattrset(int); ++int tisaltscr(void); + void tnew(int, int); + void tresize(int, int); + void tsetdirtattr(int); +diff --git a/x.c b/x.c +index cd96575..9274556 100644 +--- a/x.c ++++ b/x.c +@@ -34,6 +34,7 @@ typedef struct { + void (*func)(const Arg *); + const Arg arg; + uint release; ++ int altscrn; /* 0: don't care, -1: not alt screen, 1: alt screen */ + } MouseShortcut; + + typedef struct { +@@ -455,6 +456,7 @@ mouseaction(XEvent *e, uint release) + for (ms = mshortcuts; ms < mshortcuts + LEN(mshortcuts); ms++) { + if (ms->release == release && + ms->button == e->xbutton.button && ++ (!ms->altscrn || (ms->altscrn == (tisaltscr() ? 1 : -1))) && + (match(ms->mod, state) || /* exact or forced */ + match(ms->mod, state & ~forcemousemod))) { + ms->func(&(ms->arg)); +-- +2.34.1 + diff --git a/ports/st/st-xresources-20200604-9ba7ecf.diff b/ports/st/st-xresources-20200604-9ba7ecf.diff @@ -0,0 +1,184 @@ +From 2752a599ee01305a435729bfacf43b1dde7cf0ef Mon Sep 17 00:00:00 2001 +From: Benji Encalada Mora <benji@encalada.dev> +Date: Thu, 4 Jun 2020 00:41:10 -0500 +Subject: [PATCH] fix: replace xfps and actionfps variables + +--- + config.def.h | 36 ++++++++++++++++++++++++ + x.c | 78 +++++++++++++++++++++++++++++++++++++++++++++++++--- + 2 files changed, 110 insertions(+), 4 deletions(-) + +diff --git a/config.def.h b/config.def.h +index 6f05dce..9b99782 100644 +--- a/config.def.h ++++ b/config.def.h +@@ -168,6 +168,42 @@ static unsigned int defaultattr = 11; + */ + static uint forcemousemod = ShiftMask; + ++/* ++ * Xresources preferences to load at startup ++ */ ++ResourcePref resources[] = { ++ { "font", STRING, &font }, ++ { "color0", STRING, &colorname[0] }, ++ { "color1", STRING, &colorname[1] }, ++ { "color2", STRING, &colorname[2] }, ++ { "color3", STRING, &colorname[3] }, ++ { "color4", STRING, &colorname[4] }, ++ { "color5", STRING, &colorname[5] }, ++ { "color6", STRING, &colorname[6] }, ++ { "color7", STRING, &colorname[7] }, ++ { "color8", STRING, &colorname[8] }, ++ { "color9", STRING, &colorname[9] }, ++ { "color10", STRING, &colorname[10] }, ++ { "color11", STRING, &colorname[11] }, ++ { "color12", STRING, &colorname[12] }, ++ { "color13", STRING, &colorname[13] }, ++ { "color14", STRING, &colorname[14] }, ++ { "color15", STRING, &colorname[15] }, ++ { "background", STRING, &colorname[256] }, ++ { "foreground", STRING, &colorname[257] }, ++ { "cursorColor", STRING, &colorname[258] }, ++ { "termname", STRING, &termname }, ++ { "shell", STRING, &shell }, ++ { "minlatency", INTEGER, &minlatency }, ++ { "maxlatency", INTEGER, &maxlatency }, ++ { "blinktimeout", INTEGER, &blinktimeout }, ++ { "bellvolume", INTEGER, &bellvolume }, ++ { "tabspaces", INTEGER, &tabspaces }, ++ { "borderpx", INTEGER, &borderpx }, ++ { "cwscale", FLOAT, &cwscale }, ++ { "chscale", FLOAT, &chscale }, ++}; ++ + /* + * Internal mouse shortcuts. + * Beware that overloading Button1 will disable the selection. +diff --git a/x.c b/x.c +index 210f184..76f167f 100644 +--- a/x.c ++++ b/x.c +@@ -14,6 +14,7 @@ + #include <X11/keysym.h> + #include <X11/Xft/Xft.h> + #include <X11/XKBlib.h> ++#include <X11/Xresource.h> + + char *argv0; + #include "arg.h" +@@ -45,6 +46,19 @@ typedef struct { + signed char appcursor; /* application cursor */ + } Key; + ++/* Xresources preferences */ ++enum resource_type { ++ STRING = 0, ++ INTEGER = 1, ++ FLOAT = 2 ++}; ++ ++typedef struct { ++ char *name; ++ enum resource_type type; ++ void *dst; ++} ResourcePref; ++ + /* X modifiers */ + #define XK_ANY_MOD UINT_MAX + #define XK_NO_MOD 0 +@@ -828,8 +842,8 @@ xclear(int x1, int y1, int x2, int y2) + void + xhints(void) + { +- XClassHint class = {opt_name ? opt_name : termname, +- opt_class ? opt_class : termname}; ++ XClassHint class = {opt_name ? opt_name : "st", ++ opt_class ? opt_class : "St"}; + XWMHints wm = {.flags = InputHint, .input = 1}; + XSizeHints *sizeh; + +@@ -1104,8 +1118,6 @@ xinit(int cols, int rows) + pid_t thispid = getpid(); + XColor xmousefg, xmousebg; + +- if (!(xw.dpy = XOpenDisplay(NULL))) +- die("can't open display\n"); + xw.scr = XDefaultScreen(xw.dpy); + xw.vis = XDefaultVisual(xw.dpy, xw.scr); + +@@ -1964,6 +1976,59 @@ run(void) + } + } + ++int ++resource_load(XrmDatabase db, char *name, enum resource_type rtype, void *dst) ++{ ++ char **sdst = dst; ++ int *idst = dst; ++ float *fdst = dst; ++ ++ char fullname[256]; ++ char fullclass[256]; ++ char *type; ++ XrmValue ret; ++ ++ snprintf(fullname, sizeof(fullname), "%s.%s", ++ opt_name ? opt_name : "st", name); ++ snprintf(fullclass, sizeof(fullclass), "%s.%s", ++ opt_class ? opt_class : "St", name); ++ fullname[sizeof(fullname) - 1] = fullclass[sizeof(fullclass) - 1] = '\0'; ++ ++ XrmGetResource(db, fullname, fullclass, &type, &ret); ++ if (ret.addr == NULL || strncmp("String", type, 64)) ++ return 1; ++ ++ switch (rtype) { ++ case STRING: ++ *sdst = ret.addr; ++ break; ++ case INTEGER: ++ *idst = strtoul(ret.addr, NULL, 10); ++ break; ++ case FLOAT: ++ *fdst = strtof(ret.addr, NULL); ++ break; ++ } ++ return 0; ++} ++ ++void ++config_init(void) ++{ ++ char *resm; ++ XrmDatabase db; ++ ResourcePref *p; ++ ++ XrmInitialize(); ++ resm = XResourceManagerString(xw.dpy); ++ if (!resm) ++ return; ++ ++ db = XrmGetStringDatabase(resm); ++ for (p = resources; p < resources + LEN(resources); p++) ++ resource_load(db, p->name, p->type, p->dst); ++} ++ + void + usage(void) + { +@@ -2037,6 +2102,11 @@ run: + + setlocale(LC_CTYPE, ""); + XSetLocaleModifiers(""); ++ ++ if(!(xw.dpy = XOpenDisplay(NULL))) ++ die("Can't open display\n"); ++ ++ config_init(); + cols = MAX(cols, 1); + rows = MAX(rows, 1); + tnew(cols, rows); +-- +2.26.2 + diff --git a/ports/st/st-xresources-signal-reloading-20220407-ef05519.diff b/ports/st/st-xresources-signal-reloading-20220407-ef05519.diff @@ -1,153 +0,0 @@ -From b2a9c96cc3c9152c4e8188f341606c914741cb50 Mon Sep 17 00:00:00 2001 -From: wael <40663@protonmail.com> -Date: Thu, 7 Apr 2022 17:14:02 +0300 -Subject: [PATCH] fix xresources with signal reloading removing arg.h and st.h - & remove unneccesary xresources variables(?) - ---- - x.c | 115 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 115 insertions(+) - -diff --git a/x.c b/x.c -index 2a3bd38..e8fe7ad 100644 ---- a/x.c -+++ b/x.c -@@ -14,6 +14,7 @@ - #include <X11/keysym.h> - #include <X11/Xft/Xft.h> - #include <X11/XKBlib.h> -+#include <X11/Xresource.h> - - char *argv0; - #include "arg.h" -@@ -2011,6 +2012,118 @@ run(void) - } - } - -+ -+#define XRESOURCE_LOAD_META(NAME) \ -+ if(!XrmGetResource(xrdb, "st." NAME, "st." NAME, &type, &ret)) \ -+ XrmGetResource(xrdb, "*." NAME, "*." NAME, &type, &ret); \ -+ if (ret.addr != NULL && !strncmp("String", type, 64)) -+ -+#define XRESOURCE_LOAD_STRING(NAME, DST) \ -+ XRESOURCE_LOAD_META(NAME) \ -+ DST = ret.addr; -+ -+#define XRESOURCE_LOAD_CHAR(NAME, DST) \ -+ XRESOURCE_LOAD_META(NAME) \ -+ DST = ret.addr[0]; -+ -+#define XRESOURCE_LOAD_INTEGER(NAME, DST) \ -+ XRESOURCE_LOAD_META(NAME) \ -+ DST = strtoul(ret.addr, NULL, 10); -+ -+#define XRESOURCE_LOAD_FLOAT(NAME, DST) \ -+ XRESOURCE_LOAD_META(NAME) \ -+ DST = strtof(ret.addr, NULL); -+ -+void -+xrdb_load(void) -+{ -+ /* XXX */ -+ char *xrm; -+ char *type; -+ XrmDatabase xrdb; -+ XrmValue ret; -+ Display *dpy; -+ -+ if(!(dpy = XOpenDisplay(NULL))) -+ die("Can't open display\n"); -+ -+ XrmInitialize(); -+ xrm = XResourceManagerString(dpy); -+ -+ if (xrm != NULL) { -+ xrdb = XrmGetStringDatabase(xrm); -+ -+ /* handling colors here without macros to do via loop. */ -+ int i = 0; -+ char loadValue[12] = ""; -+ for (i = 0; i < 256; i++) -+ { -+ sprintf(loadValue, "%s%d", "st.color", i); -+ -+ if(!XrmGetResource(xrdb, loadValue, loadValue, &type, &ret)) -+ { -+ sprintf(loadValue, "%s%d", "*.color", i); -+ if (!XrmGetResource(xrdb, loadValue, loadValue, &type, &ret)) -+ /* reset if not found (unless in range for defaults). */ -+ if (i > 15) -+ colorname[i] = NULL; -+ } -+ -+ if (ret.addr != NULL && !strncmp("String", type, 64)) -+ colorname[i] = ret.addr; -+ } -+ -+ XRESOURCE_LOAD_STRING("foreground", colorname[defaultfg]); -+ XRESOURCE_LOAD_STRING("background", colorname[defaultbg]); -+ XRESOURCE_LOAD_STRING("cursorColor", colorname[defaultcs]) -+ else { -+ // this looks confusing because we are chaining off of the if -+ // in the macro. probably we should be wrapping everything blocks -+ // so this isn't possible... -+ defaultcs = defaultfg; -+ } -+ XRESOURCE_LOAD_STRING("reverse-cursor", colorname[defaultrcs]) -+ else { -+ // see above. -+ defaultrcs = defaultbg; -+ } -+ -+ XRESOURCE_LOAD_STRING("font", font); -+ XRESOURCE_LOAD_STRING("termname", termname); -+ -+ XRESOURCE_LOAD_INTEGER("blinktimeout", blinktimeout); -+ XRESOURCE_LOAD_INTEGER("bellvolume", bellvolume); -+ XRESOURCE_LOAD_INTEGER("borderpx", borderpx); -+ XRESOURCE_LOAD_INTEGER("cursorshape", cursorshape); -+ -+ XRESOURCE_LOAD_FLOAT("cwscale", cwscale); -+ XRESOURCE_LOAD_FLOAT("chscale", chscale); -+ } -+ XFlush(dpy); -+} -+ -+void -+reload(int sig) -+{ -+ xrdb_load(); -+ -+ /* colors, fonts */ -+ xloadcols(); -+ xunloadfonts(); -+ xloadfonts(font, 0); -+ -+ /* pretend the window just got resized */ -+ cresize(win.w, win.h); -+ -+ redraw(); -+ -+ /* triggers re-render if we're visible. */ -+ ttywrite("\033[O", 3, 1); -+ -+ signal(SIGUSR1, reload); -+} -+ -+ - void - usage(void) - { -@@ -2084,6 +2197,8 @@ run: - - setlocale(LC_CTYPE, ""); - XSetLocaleModifiers(""); -+ xrdb_load(); -+ signal(SIGUSR1, reload); - cols = MAX(cols, 1); - rows = MAX(rows, 1); - tnew(cols, rows); --- -2.35.1 -