sites

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

commit 0e391b50a6ae9a90128249eae31681afc6cfc4ac
parent 1007ac4858cae592264b21fe53a7697af82e5986
Author: fennec <fennec>
Date:   Thu, 21 Dec 2023 14:24:53 +0000

Patch to add individual colors to launcher icons

Diffstat:
Mdwm.suckless.org/patches/keypressrelease/index.md | 146+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------
1 file changed, 125 insertions(+), 21 deletions(-)

diff --git a/dwm.suckless.org/patches/keypressrelease/index.md b/dwm.suckless.org/patches/keypressrelease/index.md @@ -1,38 +1,142 @@ -keypressrelease -=============== +launcher-colors +======== Description ----------- -This patch lets you specify whether a key binding should be executed at the -_KeyPress_ or _KeyRelease_ event. Executing on _KeyRelease_ fixes bugs such as -`scrot -s` [failing to execute from a key binding](//lists.suckless.org/dev/1108/9185.html) -due to keys not being released in time. +This patch adds colors to the launcher icons which you click to launch programs and commands. -Note that the new parameter must be added to all non-standard key bindings -manually after patching. +Usage: +------ + +File config.def.h + +Append new color scheme to the colors array. +Example below. + + static const char *colors[][3] = { + /* fg bg border */ + [SchemeNorm] = { gray3, black, gray2 }, + [SchemeSel] = { gray4, blue, blue }, + [SchemeTitle] = { white, black, black }, // active window title + [TabSel] = { blue, gray2, black }, + [TabNorm] = { gray3, black, black }, + [SchemeTag] = { gray3, black, black }, + [SchemeTag1] = { blue, black, black }, + [SchemeTag2] = { red, black, black }, + [SchemeTag3] = { orange, black, black }, + [SchemeTag4] = { green, black, black }, + [SchemeTag5] = { pink, black, black }, + [SchemeLayout] = { green, black, black }, + [SchemeBtnPrev] = { green, black, black }, + [SchemeBtnNext] = { yellow, black, black }, + [SchemeBtnClose] = { red, black, black }, + [SchemeColorEW] = { orange, black, black }, // color ewww launcher icon + [SchemeColorFF] = { yellow, black, black }, // color firefox launcher icon + [SchemeColorDS] = { red, black, black }, // color discord launcher icon + [SchemeColorTG] = { green, black, black }, // color telegram launcher icon + [SchemeColorMS] = { blue, black, black }, // color mintstick launcher icon + [SchemeColorPC] = { pink, black, black }, // color pavucontrol launcher icon + }; + +The command names defined for the launchers are important since these are used again later. + + static const Launcher launchers[] = { + /* command name to display */ + { eww, "" }, + { firefox, "" }, + { discord, "ﱲ" }, + { telegram, "" }, + { mintstick, "虜" }, + { pavucontrol, "墳" }, + }; + +File dwm.c + +Append new color schemes to the enum. +Example below. + + enum { + SchemeNorm, + SchemeSel, + SchemeTitle, + SchemeTag, + SchemeTag1, + SchemeTag2, + SchemeTag3, + SchemeTag4, + SchemeTag5, + SchemeLayout, + TabSel, + TabNorm, + SchemeBtnPrev, + SchemeBtnNext, + SchemeBtnClose, + SchemeColorEW, + SchemeColorFF, + SchemeColorDS, + SchemeColorTG, + SchemeColorMS, + SchemeColorPC + }; /* color schemes */ + +File dwm.c -Usage ------ -A working `scrot -s` key binding: +Navigate to the line where the following is defined: - { KeyRelease, 0, XK_Print, spawn, SHCMD("scrot -s") }, + w = TEXTW(m->ltsymbol); -Or to only display the bar while the toggle key is held down (requires that it -is hidden to start with), add: +Comment out line - { KeyRelease, MODKEY, XK_b, togglebar, {0} }, + drw_setscheme(drw, scheme[SchemeLayout]); -Alternatives ------------- +Inside the for loop add if conditions to set the different color schemes for each launcher. -An alternative is to put a tiny sleep right before executing scrot. +Example below. +Note. The command name should match the ones defined inside config.def.h - { ControlMask, XK_Print, spawn, SHCMD("sleep 0.2; scrot -s") }, + w = TEXTW(m->ltsymbol); + //drw_setscheme(drw, scheme[SchemeLayout]); + x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0); + + for (i = 0; i < LENGTH(launchers); i++) + { + if (launchers[i].command == eww){ + drw_setscheme(drw, scheme[SchemeColorEW]); + } + + if (launchers[i].command == firefox){ + drw_setscheme(drw, scheme[SchemeColorFF]); + } + + if (launchers[i].command == discord){ + drw_setscheme(drw, scheme[SchemeColorDS]); + } + + if (launchers[i].command == telegram){ + drw_setscheme(drw, scheme[SchemeColorTG]); + } + + if (launchers[i].command == mintstick){ + drw_setscheme(drw, scheme[SchemeColorMS]); + } + + if (launchers[i].command == pavucontrol){ + drw_setscheme(drw, scheme[SchemeColorPC]); + } + + w = TEXTW(launchers[i].name); + +After a rebuild. + +The result will be as shown below. + +https://imgur.com/a/JsqUKiC Download -------- -* [dwm-keypressrelease-6.0.diff](dwm-keypressrelease-6.0.diff) +[dwm-launchers-colors-20231221-81aca1b.diff](dwm-launchers-colors-20231221-81aca1b.diff) Author ------ -* Niklas Høj - `<niklas at hoej dot me>` +* [fennec](https://debugthis.dev) - <xovo6six@gmail.com> +