Last active
June 11, 2022 00:55
-
-
Save rmb122/4ddd34323c3360ce880a5e960d1e968a to your computer and use it in GitHub Desktop.
hook_vte.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define _GNU_SOURCE | |
#include <stdlib.h> | |
#include <dlfcn.h> | |
typedef unsigned int gsize; | |
typedef double gdouble; | |
typedef struct { | |
gdouble red; | |
gdouble green; | |
gdouble blue; | |
gdouble alpha; | |
} GdkRGBA; | |
#define PALETTE_SIZE 16 | |
const GdkRGBA snazzy_palette[PALETTE_SIZE] = { | |
{0.15625, 0.1640625, 0.2109375, 1.0}, | |
{0.99609375, 0.359375, 0.33984375, 1.0}, | |
{0.3515625, 0.96484375, 0.5546875, 1.0}, | |
{0.94921875, 0.97265625, 0.61328125, 1.0}, | |
{0.33984375, 0.77734375, 0.99609375, 1.0}, | |
{0.99609375, 0.4140625, 0.75390625, 1.0}, | |
{0.6015625, 0.92578125, 0.9921875, 1.0}, | |
{0.8828125, 0.890625, 0.89453125, 1.0}, | |
{0.46875, 0.46875, 0.4921875, 1.0}, | |
{0.99609375, 0.359375, 0.33984375, 1.0}, | |
{0.3515625, 0.96484375, 0.5546875, 1.0}, | |
{0.94921875, 0.97265625, 0.61328125, 1.0}, | |
{0.33984375, 0.77734375, 0.99609375, 1.0}, | |
{0.99609375, 0.4140625, 0.75390625, 1.0}, | |
{0.6015625, 0.92578125, 0.9921875, 1.0}, | |
{0.94140625, 0.94140625, 0.9375, 1.0}, | |
}; | |
static __attribute__((constructor)) void init(void) | |
{ | |
unsetenv("LD_PRELOAD"); | |
} | |
// Hook vte set color for https://github.com/dabisu/sakura, set ourselves' color palette | |
void vte_terminal_set_colors(void *terminal, const void *foreground, const void *background, const GdkRGBA *palette, gsize palette_size) { | |
void (*original_vte_terminal_set_colors)(void *, const void *, const void *, const GdkRGBA *palette, gsize palette_size); | |
original_vte_terminal_set_colors = dlsym(RTLD_NEXT, "vte_terminal_set_colors"); | |
(*original_vte_terminal_set_colors)(terminal, foreground, background, snazzy_palette, palette_size); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment