xresources patch now default
This commit is contained in:
parent
195535facc
commit
7f231a6b54
56
README.md
56
README.md
|
@ -1,27 +1,21 @@
|
|||
# Luke's build of st - the simple (suckless) terminal
|
||||
Forked from [https://github.com/shiva/st](https://github.com/shiva/st) for simplicity's sake, which is the [suckless terminal (st)](https://st.suckless.org/) with some patches added:
|
||||
|
||||
+ transparency
|
||||
+ copy to clipboard (alt-shift-c)
|
||||
+ Optional compatibility with `Xresources` and `pywal` for dynamic colors
|
||||
+ Solarized colors (light and dark toggleable)
|
||||
+ vertcenter
|
||||
+ scrollback with keyboard
|
||||
+ scrollback with mouse
|
||||
+ updated to latest version 0.8.1
|
||||
|
||||
## My own additions
|
||||
Forked from [https://github.com/shiva/st](https://github.com/shiva/st) for simplicity's sake, which is the [suckless terminal (st)](https://st.suckless.org/) with some additional features:
|
||||
|
||||
+ Adjustable transparency/alpha
|
||||
+ Compatibility with `Xresources` and `pywal` for dynamic colors
|
||||
+ Copy to clipboard (alt-shift-c)
|
||||
+ Default font is system "mono" at 14pt, meaning the font will match your system font.
|
||||
+ Hold alt and press either ↑/↓ or the vim keys k/j to move up/down in the terminal.
|
||||
+ Shift+Mouse wheel will as well.
|
||||
+ Alt-u and Alt-d scroll back/forward in history a page at a time.
|
||||
+ Alt-PageUp and Alt-PageDown scroll back/forward in history a page at a time.
|
||||
+ Transparency with solarized colors by default.
|
||||
+ Alt-PageUp and Alt-PageDown will do the same.
|
||||
+ Zoom in/out with Alt+Shift+k/j or u/d for larger intervals.
|
||||
+ Vertcenter
|
||||
+ Optional solarized colors (light and dark toggleable)
|
||||
+ updated to latest version 0.8.1
|
||||
|
||||
## Terminal-specific mappings
|
||||
|
||||
(Additions before me.)
|
||||
The following additional bindings were added before I forked this:
|
||||
|
||||
+ Scroll through history -- Shift+PageUp/PageDown or Shift+Mouse wheel
|
||||
+ Increase/decrease font size -- Shift+Alt+PageUp/PageDown
|
||||
|
@ -39,29 +33,17 @@ Obviously, `make` is required to build. `fontconfig` is required for the default
|
|||
|
||||
## Custom changes (`config.def.h` or `config.h`)
|
||||
|
||||
### Solarized
|
||||
Now by default, the terminal is transparent and uses an Xresources patch that
|
||||
looks for your Xresources colors for the colors of st. You can disable the
|
||||
Xresources patch by reversing it as below:
|
||||
|
||||
By default, the terminal is transparent with a blackish background. There's a patch file `solarized-alpha-toggle.patch` which you can use to remove the transparency and give it a typical deep, dark blue solarized background. Just run:
|
||||
```
|
||||
patch -R < xresources.patch
|
||||
```
|
||||
|
||||
On top of that, you can disable alpha and enable fully solarized colors by
|
||||
running the following:
|
||||
|
||||
```
|
||||
patch < solarized-alpha-toggle.patch
|
||||
```
|
||||
|
||||
Then, run `make` & `sudo make install` again to install the new build. You make reverse the solarized background by running the same command as above, but giving `patch` the `-R` option as well.
|
||||
|
||||
### `Xresources` and `pywal`/`wal` compatibility
|
||||
|
||||
If you use `wal` to maintain color schemes across your programs, you can use the `xresources.patch`.
|
||||
|
||||
```
|
||||
patch < xresources.patch
|
||||
make && sudo make install
|
||||
```
|
||||
|
||||
## Explore `config.h`
|
||||
|
||||
+ Change `colorname[]` array values (88 LOC), default colours are solarized.
|
||||
+ Numbers of 0 - 15 are usual terminal colors. Change them to your liking.
|
||||
+ Change `bg` to your desired terminal background color.
|
||||
+ Change `fg` to your desired terminal foreground color.
|
||||
+ Change `cursor` to your desired terminal cursor color.
|
||||
|
|
37
config.h
37
config.h
|
@ -83,7 +83,7 @@ char *termname = "st-256color";
|
|||
unsigned int tabspaces = 8;
|
||||
|
||||
/* bg opacity */
|
||||
unsigned int alpha = 0xcd;
|
||||
unsigned int alpha = 0xed;
|
||||
|
||||
static const char *colorname[] = {
|
||||
"#073642", /* 0: black */
|
||||
|
@ -147,6 +147,41 @@ static unsigned int mousebg = 0;
|
|||
*/
|
||||
static unsigned int defaultattr = 11;
|
||||
|
||||
/*
|
||||
* 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 },
|
||||
{ "xfps", INTEGER, &xfps },
|
||||
{ "actionfps", INTEGER, &actionfps },
|
||||
{ "blinktimeout", INTEGER, &blinktimeout },
|
||||
{ "bellvolume", INTEGER, &bellvolume },
|
||||
{ "tabspaces", INTEGER, &tabspaces },
|
||||
{ "cwscale", FLOAT, &cwscale },
|
||||
{ "chscale", FLOAT, &chscale },
|
||||
};
|
||||
|
||||
/*
|
||||
* Internal mouse shortcuts.
|
||||
* Beware that overloading Button1 will disable the selection.
|
||||
|
|
78
x.c
78
x.c
|
@ -14,6 +14,7 @@
|
|||
#include <X11/keysym.h>
|
||||
#include <X11/Xft/Xft.h>
|
||||
#include <X11/XKBlib.h>
|
||||
#include <X11/Xresource.h>
|
||||
|
||||
static char *argv0;
|
||||
#include "arg.h"
|
||||
|
@ -43,6 +44,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
|
||||
|
@ -812,8 +826,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;
|
||||
|
||||
|
@ -1034,8 +1048,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.depth = (USE_ARGB) ? 32: XDefaultDepth(xw.dpy, xw.scr);
|
||||
if (!USE_ARGB)
|
||||
|
@ -1935,6 +1947,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)
|
||||
{
|
||||
|
@ -2008,6 +2073,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);
|
||||
|
|
Loading…
Reference in New Issue
Block a user