sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

dwm-flyschemes-6.6.diff (7256B)


      1 diff -up dwm-6.6-orig/config.def.h dwm-6.6-flyschemes/config.def.h
      2 --- dwm-6.6-orig/config.def.h	2025-12-18 12:11:49.852471883 +0300
      3 +++ dwm-6.6-flyschemes/config.def.h	2025-12-21 16:55:25.337197189 +0300
      4 @@ -7,15 +7,64 @@ static const int showbar            = 1;
      5  static const int topbar             = 1;        /* 0 means bottom bar */
      6  static const char *fonts[]          = { "monospace:size=10" };
      7  static const char dmenufont[]       = "monospace:size=10";
      8 -static const char col_gray1[]       = "#222222";
      9 -static const char col_gray2[]       = "#444444";
     10 -static const char col_gray3[]       = "#bbbbbb";
     11 -static const char col_gray4[]       = "#eeeeee";
     12 -static const char col_cyan[]        = "#005577";
     13 -static const char *colors[][3]      = {
     14 +
     15 +/* loaded on dwm launch, has to be present */
     16 +static const char *flyscheme_default[][3] = {
     17  	/*               fg         bg         border   */
     18 -	[SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
     19 -	[SchemeSel]  = { col_gray4, col_cyan,  col_cyan  },
     20 +	[SchemeNorm] = { "#bbbbbb", "#222222", "#444444" },
     21 +	[SchemeSel]  = { "#eeeeee", "#005577", "#005577" },
     22 +};
     23 +
     24 +static const char *flyscheme_dracula[][3] = {
     25 +	[SchemeNorm] = { "#f8f8f2", "#282a36", "#44475a" },
     26 +	[SchemeSel]  = { "#282a36", "#bd93f9", "#bd93f9" },
     27 +};
     28 +
     29 +static const char *flyscheme_solarized[][3] = {
     30 +	[SchemeNorm] = { "#839496", "#002b36", "#073642" },
     31 +	[SchemeSel]  = { "#002b36", "#2aa198", "#2aa198" },
     32 +};
     33 +
     34 +static const char *flyscheme_nord[][3] = {
     35 +	[SchemeNorm] = { "#d8dee9", "#2e3440", "#4c566a" },
     36 +	[SchemeSel]  = { "#2e3440", "#88c0d0", "#88c0d0" },
     37 +};
     38 +
     39 +static const char *flyscheme_gruvbox[][3] = {
     40 +	[SchemeNorm] = { "#ebdbb2", "#282828", "#3c3836" },
     41 +	[SchemeSel]  = { "#282828", "#fabd2f", "#fabd2f" },
     42 +};
     43 +
     44 +static const char *flyscheme_light[][3] = {
     45 +	[SchemeNorm] = { "#222222", "#eeeeee", "#cccccc" },
     46 +	[SchemeSel]  = { "#ffffff", "#4a90e2", "#4a90e2" },
     47 +};
     48 +
     49 +static const char *flyscheme_plan9[][3] = {
     50 +	[SchemeNorm] = { "#000000", "#ffffea", "#999999" },
     51 +	[SchemeSel]  = { "#000000", "#9ecfff", "#9ecfff" },
     52 +};
     53 +
     54 +static const char *flyscheme_cyberpunk[][3] = {
     55 +	[SchemeNorm] = { "#00ffcc", "#0d0221", "#1d1231" },
     56 +	[SchemeSel]  = { "#0d0221", "#ff00aa", "#ff00aa" },
     57 +};
     58 +
     59 +/*
     60 + * you can move the schemes to a different header and do #include "flyschemes.h"
     61 + * or you can move each scheme to its own file and do #include flyscheme_light.h, #include flyscheme_plan9.h, ...
     62 + * */
     63 +
     64 +static const char *(*flyschemes[])[3] = {
     65 +	flyscheme_default,
     66 +	flyscheme_light,
     67 +	flyscheme_plan9,
     68 +	flyscheme_dracula,
     69 +	flyscheme_solarized,
     70 +	flyscheme_nord,
     71 +	flyscheme_gruvbox,
     72 +	flyscheme_cyberpunk,
     73 +	NULL // used to count the number of flyschemes
     74  };
     75  
     76  /* tagging */
     77 @@ -57,7 +106,16 @@ static const Layout layouts[] = {
     78  
     79  /* commands */
     80  static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */
     81 -static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL };
     82 +static const char *dmenucmd[] = {
     83 +	"dmenu_run",
     84 +	"-m", dmenumon,
     85 +	"-fn", dmenufont,
     86 +	"-nb", "#222222", /* changed as dmenucmd[6] in cycle_flyschemes */
     87 +	"-nf", "#bbbbbb", /* changed as dmenucmd[8] in cycle_flyschemes */
     88 +	"-sb", "#005577", /* changed as dmenucmd[10] in cycle_flyschemes */
     89 +	"-sf", "$eeeeee", /* changed as dmenucmd[12] in cycle_flyschemes */
     90 +	NULL
     91 +};
     92  static const char *termcmd[]  = { "st", NULL };
     93  
     94  static const Key keys[] = {
     95 @@ -73,7 +131,9 @@ static const Key keys[] = {
     96  	{ MODKEY,                       XK_l,      setmfact,       {.f = +0.05} },
     97  	{ MODKEY,                       XK_Return, zoom,           {0} },
     98  	{ MODKEY,                       XK_Tab,    view,           {0} },
     99 -	{ MODKEY|ShiftMask,             XK_c,      killclient,     {0} },
    100 +	{ MODKEY|ShiftMask,             XK_x,      killclient,     {0} },
    101 +	{ MODKEY,                       XK_c,      cycle_flyschemes, { .i = +1 } },
    102 +	{ MODKEY|ShiftMask,             XK_c,      cycle_flyschemes, { .i = -1 } },
    103  	{ MODKEY,                       XK_t,      setlayout,      {.v = &layouts[0]} },
    104  	{ MODKEY,                       XK_f,      setlayout,      {.v = &layouts[1]} },
    105  	{ MODKEY,                       XK_m,      setlayout,      {.v = &layouts[2]} },
    106 diff -up dwm-6.6-orig/dwm.1 dwm-6.6-flyschemes/dwm.1
    107 --- dwm-6.6-orig/dwm.1	2025-12-18 12:11:49.852471883 +0300
    108 +++ dwm-6.6-flyschemes/dwm.1	2025-12-21 11:59:37.963510226 +0300
    109 @@ -113,9 +113,15 @@ Decrease master area size.
    110  .B Mod1\-Return
    111  Zooms/cycles focused window to/from master area (tiled layouts only).
    112  .TP
    113 -.B Mod1\-Shift\-c
    114 +.B Mod1\-Shift\-x
    115  Close focused window.
    116  .TP
    117 +.B Mod1\-c
    118 +Cycle flyscheme.
    119 +.TP
    120 +.B Mod1\-Shift\-c
    121 +Cycle flyscheme back.
    122 +.TP
    123  .B Mod1\-Shift\-space
    124  Toggle focused window between tiled and floating state.
    125  .TP
    126 diff -up dwm-6.6-orig/dwm.c dwm-6.6-flyschemes/dwm.c
    127 --- dwm-6.6-orig/dwm.c	2025-12-18 12:11:49.852471883 +0300
    128 +++ dwm-6.6-flyschemes/dwm.c	2025-12-21 16:54:13.313862415 +0300
    129 @@ -141,6 +141,8 @@ typedef struct {
    130  } Rule;
    131  
    132  /* function declarations */
    133 +static void cycle_flyschemes(const Arg *arg);
    134 +static void update_scheme();
    135  static void applyrules(Client *c);
    136  static int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interact);
    137  static void arrange(Monitor *m);
    138 @@ -234,6 +236,7 @@ static int xerrorstart(Display *dpy, XEr
    139  static void zoom(const Arg *arg);
    140  
    141  /* variables */
    142 +static unsigned int iflysch = 0;
    143  static const char broken[] = "broken";
    144  static char stext[256];
    145  static int screen;
    146 @@ -485,7 +488,7 @@ cleanup(void)
    147  		cleanupmon(mons);
    148  	for (i = 0; i < CurLast; i++)
    149  		drw_cur_free(drw, cursor[i]);
    150 -	for (i = 0; i < LENGTH(colors); i++)
    151 +	for (i = 0; i < LENGTH(flyscheme_default); i++)
    152  		free(scheme[i]);
    153  	free(scheme);
    154  	XDestroyWindow(dpy, wmcheckwin);
    155 @@ -1583,9 +1586,9 @@ setup(void)
    156  	cursor[CurResize] = drw_cur_create(drw, XC_sizing);
    157  	cursor[CurMove] = drw_cur_create(drw, XC_fleur);
    158  	/* init appearance */
    159 -	scheme = ecalloc(LENGTH(colors), sizeof(Clr *));
    160 -	for (i = 0; i < LENGTH(colors); i++)
    161 -		scheme[i] = drw_scm_create(drw, colors[i], 3);
    162 +	scheme = ecalloc(LENGTH(flyscheme_default), sizeof(Clr *));
    163 +	for (i = 0; i < LENGTH(flyscheme_default); i++)
    164 +		scheme[i] = drw_scm_create(drw, flyscheme_default[i], 3);
    165  	/* init bars */
    166  	updatebars();
    167  	updatestatus();
    168 @@ -2139,6 +2142,36 @@ zoom(const Arg *arg)
    169  	pop(c);
    170  }
    171  
    172 +void
    173 +update_scheme()
    174 +{
    175 +	scheme[SchemeNorm] = drw_scm_create(drw, flyschemes[iflysch][SchemeNorm], 3);
    176 +	scheme[SchemeSel] = drw_scm_create(drw, flyschemes[iflysch][SchemeSel], 3);
    177 +	dmenucmd[6] = flyschemes[iflysch][SchemeNorm][1];
    178 +	dmenucmd[8] = flyschemes[iflysch][SchemeNorm][0];
    179 +	dmenucmd[10] = flyschemes[iflysch][SchemeSel][1];
    180 +	dmenucmd[12] = flyschemes[iflysch][SchemeSel][0];
    181 +	Client *cl = selmon->sel;
    182 +	Client *c;
    183 +	Monitor *m;
    184 +	for (m = mons; m; m = m->next)
    185 +		for (c = m->clients; c; c = c->next)
    186 +			focus(c);
    187 +	focus(cl);
    188 +}
    189 +
    190 +void
    191 +cycle_flyschemes(const Arg *arg)
    192 +{
    193 +	int flyschemes_limit = 256;
    194 +	int i;
    195 +	for(i = 0; flyschemes[i] != NULL && i < flyschemes_limit; i++)
    196 +		;
    197 +	iflysch += i + arg->i;
    198 +	iflysch %= i;
    199 +	update_scheme();
    200 +}
    201 +
    202  int
    203  main(int argc, char *argv[])
    204  {