Split up statusbutton into seperate patches

This commit is contained in:
Alexis Jhon Gaspar 2023-11-01 22:29:00 +08:00
parent 8a215d997e
commit 57a05555f3
13 changed files with 208 additions and 154 deletions

View file

@ -564,10 +564,12 @@ static const BarRule barrules[] = {
/* monitor bar alignment widthfunc drawfunc clickfunc hoverfunc name */
#if BAR_STATUSBUTTON_PATCH
{ -1, 0, BAR_ALIGN_LEFT, width_stbutton, draw_stbutton, click_stbutton, NULL, "statusbutton" },
{ -1, 1, BAR_ALIGN_LEFT, width_stbutton2, draw_stbutton2, click_stbutton2, NULL, "statusbutton2" },
{ -1, 1, BAR_ALIGN_LEFT, width_stbutton3, draw_stbutton3, click_stbutton3, NULL, "statusbutton3" },
{ -1, 1, BAR_ALIGN_LEFT, width_stbutton4, draw_stbutton4, click_stbutton4, NULL, "statusbutton4" },
#endif // BAR_STATUSBUTTON_PATCH
#if BAR_DOCKBUTTONS_PATCH
{ -1, 1, BAR_ALIGN_LEFT, width_dcbutton, draw_dcbutton, click_dcbutton, NULL, "dockbutton" },
{ -1, 1, BAR_ALIGN_LEFT, width_dcbutton2, draw_dcbutton2, click_dcbutton2, NULL, "dockbutton2" },
{ -1, 1, BAR_ALIGN_LEFT, width_dcbutton3, draw_dcbutton3, click_dcbutton3, NULL, "dockbutton3" },
#endif // BAR_DOCKBUTTONS_PATCH
#if BAR_TAGGRID_PATCH
{ -1, 0, BAR_ALIGN_LEFT, width_taggrid, draw_taggrid, click_taggrid, NULL, "taggrid" },
#endif // BAR_TAGGRID_PATCH
@ -580,12 +582,14 @@ static const BarRule barrules[] = {
#if BAR_TAGLABELS_PATCH
{ -1, 0, BAR_ALIGN_LEFT, width_taglabels, draw_taglabels, click_taglabels, hover_taglabels, "taglabels" },
#endif // BAR_TAGLABELS_PATCH
#if BAR_STATUSBUTTON_PATCH
{ -1, 0, BAR_ALIGN_RIGHT, width_stbutton5, draw_stbutton5, click_stbutton5, NULL, "statusbutton5" },
{ -1, 1, BAR_ALIGN_RIGHT, width_stbutton6, draw_stbutton6, click_stbutton6, NULL, "statusbutton6" },
{ -1, 1, BAR_ALIGN_RIGHT, width_stbutton7, draw_stbutton7, click_stbutton7, NULL, "statusbutton7" },
{ -1, 1, BAR_ALIGN_RIGHT, width_stbutton8, draw_stbutton8, click_stbutton8, NULL, "statusbutton8" },
#endif // BAR_STATUSBUTTON_PATCH
#if BAR_POWERBUTTON_PATCH
{ -1, 0, BAR_ALIGN_RIGHT, width_powbutton, draw_powbutton, click_powbutton, NULL, "powerbutton" },
#endif // BAR_POWERBUTTON_PATCH
#if BAR_WINCONTROLBUTTONS_PATCH
{ -1, 1, BAR_ALIGN_RIGHT, width_winbutton, draw_winbutton, click_winbutton, NULL, "statusbutton6" },
{ -1, 1, BAR_ALIGN_RIGHT, width_winbutton2, draw_winbutton2, click_winbutton2, NULL, "statusbutton7" },
{ -1, 1, BAR_ALIGN_RIGHT, width_winbutton3, draw_winbutton3, click_winbutton3, NULL, "statusbutton8" },
#endif // BAR_WINCONTROLBUTTONS_PATCH
#if BAR_SYSTRAY_PATCH
{ 0, 0, BAR_ALIGN_RIGHT, width_systray, draw_systray, click_systray, NULL, "systray" },
#endif // BAR_SYSTRAY_PATCH
@ -1404,7 +1408,7 @@ static const Command commands[] = {
/* button definitions */
#if STATUSBUTTON_PATCH
/* click can be ClkButton, ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */
/* click can be ClkButton*, ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */
#else
/* click can be ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */
#endif //
@ -1414,17 +1418,23 @@ static const Button buttons[] = {
{ ClkButton, 0, Button1, spawn, SHCMD("spmenu_run -d -a '-g 4 -l 10'") /* use spmenu instead of dmenu */ },
{ ClkButton, 0, Button2, spawn, {.v = dmenucmd } /* launch dmenu instead if middle-clicked*/ },
{ ClkButton, 0, Button3, spawn, SHCMD("jgmenu_run apps | jgmenu --simple --at-pointer") /* launch jgmenu on right click */ },
#endif // BAR_STATUSBUTTON_PATCH
#if BAR_DOCKBUTTONS_PATCH
{ ClkButton2, 0, Button1, spawn, {.v = termcmd } },
{ ClkButton2, 0, Button3, spawn, SHCMD("printf ' New tabbed session, tabbed -c -r 2 st -w \"\"\n New dvtm session, st -T dvtm abduco -c dvtm dvtm-status\n' | jgmenu --simple --at-pointer") },
{ ClkButton3, 0, Button1, spawn, SHCMD("firefox") },
{ ClkButton3, 0, Button3, spawn, SHCMD("printf ' New Window, firefox\n󱀣 New Private Window, firefox -private-window\n' | jgmenu --simple --at-pointer") },
{ ClkButton4, 0, Button1, spawn, SHCMD("st -T ncmpcpp ncmpcpp") },
{ ClkButton4, 0, Button3, spawn, SHCMD("printf '󰒮 Previous Song, mpc prev\n󰐊 Play, mpc play\n󰏤 Pause, mpc pause\n󰓛 Stop, mpc stop\n󰒭 Next Song, mpc next\n󰕾 Vol +5%%,mpc vol +5\n󰖀 Vol -5%%, mpc vol -5\n' | jgmenu --simple --at-pointer") },
#endif // BAR_DOCKBUTTONS_PATCH
#if BAR_POWERBUTTON_PATCH
{ ClkButton5, 0, Button1, spawn, SHCMD("shutdown") },
#endif // BAR_POWERBUTTON_PATCH
#if BAR_WINCONTROLBUTTONS_PATCH
{ ClkButton6, 0, Button1, killclient, {0} },
{ ClkButton7, 0, Button1, togglemax, {0} },
{ ClkButton8, 0, Button1, showhideclient, {0} },
#endif // BAR_STATUSBUTTON_PATCH
#endif // BAR_WINCONTROLBUTTONS_PATCH
{ ClkLtSymbol, 0, Button1, setlayout, {0} },
#if BAR_LAYOUTMENU_PATCH
{ ClkLtSymbol, 0, Button3, layoutmenu, {0} },

View file

@ -232,14 +232,20 @@ enum {
enum {
#if BAR_STATUSBUTTON_PATCH
ClkButton,
#endif // BAR_STATUSBUTTON_PATCH
#if BAR_DOCKBUTTONS_PATCH
ClkButton2,
ClkButton3,
ClkButton4,
#endif // BAR_DOCKBUTTONS_PATCH
#if BAR_POWERBUTTON_PATCH
ClkButton5,
#endif // BAR_POWERBUTTON_PATCH
#if BAR_WINCONTROLBUTTONS_PATCH
ClkButton6,
ClkButton7,
ClkButton8,
#endif // BAR_STATUSBUTTON_PATCH
#endif // BAR_WINCONTROLBUTTONS_PATCH
#if TAB_PATCH
ClkTabBar,
#endif // TAB_PATCH

View file

@ -0,0 +1,51 @@
int
width_dcbutton(Bar *bar, BarArg *a)
{
return TEXTW(buttonbar2);
}
int
draw_dcbutton(Bar *bar, BarArg *a)
{
return drw_text(drw, a->x, a->y, a->w, a->h, lrpad / 2, buttonbar2, 0, False);
}
int
click_dcbutton(Bar *bar, Arg *arg, BarArg *a)
{
return ClkButton2;
}
int
width_dcbutton2(Bar *bar, BarArg *a)
{
return TEXTW(buttonbar3);
}
int
draw_dcbutton2(Bar *bar, BarArg *a)
{
return drw_text(drw, a->x, a->y, a->w, a->h, lrpad / 2, buttonbar3, 0, False);
}
int
click_dcbutton2(Bar *bar, Arg *arg, BarArg *a)
{
return ClkButton3;
}
int
width_dcbutton3(Bar *bar, BarArg *a)
{
return TEXTW(buttonbar4);
}
int
draw_dcbutton3(Bar *bar, BarArg *a)
{
return drw_text(drw, a->x, a->y, a->w, a->h, lrpad / 2, buttonbar4, 0, False);
}
int
click_dcbutton3(Bar *bar, Arg *arg, BarArg *a)
{
return ClkButton4;
}

View file

@ -0,0 +1,9 @@
static int width_dcbutton(Bar *bar, BarArg *a);
static int draw_dcbutton(Bar *bar, BarArg *a);
static int click_dcbutton(Bar *bar, Arg *arg, BarArg *a);
static int width_dcbutton2(Bar *bar, BarArg *a);
static int draw_dcbutton2(Bar *bar, BarArg *a);
static int click_dcbutton2(Bar *bar, Arg *arg, BarArg *a);
static int width_dcbutton3(Bar *bar, BarArg *a);
static int draw_dcbutton3(Bar *bar, BarArg *a);
static int click_dcbutton3(Bar *bar, Arg *arg, BarArg *a);

View file

@ -0,0 +1,17 @@
int
width_powbutton(Bar *bar, BarArg *a)
{
return TEXTW(buttonbar5);
}
int
draw_powbutton(Bar *bar, BarArg *a)
{
return drw_text(drw, a->x, a->y, a->w, a->h, lrpad / 20, buttonbar5, 0, False);
}
int
click_powbutton(Bar *bar, Arg *arg, BarArg *a)
{
return ClkButton5;
}

View file

@ -0,0 +1,3 @@
static int width_powbutton(Bar *bar, BarArg *a);
static int draw_powbutton(Bar *bar, BarArg *a);
static int click_powbutton(Bar *bar, Arg *arg, BarArg *a);

View file

@ -15,123 +15,4 @@ click_stbutton(Bar *bar, Arg *arg, BarArg *a)
{
return ClkButton;
}
/* modification by Lucas-mother3 to add more buttons */
int
width_stbutton2(Bar *bar, BarArg *a)
{
return TEXTW(buttonbar2);
}
int
draw_stbutton2(Bar *bar, BarArg *a)
{
return drw_text(drw, a->x, a->y, a->w, a->h, lrpad / 2, buttonbar2, 0, False);
}
int
click_stbutton2(Bar *bar, Arg *arg, BarArg *a)
{
return ClkButton2;
}
int
width_stbutton3(Bar *bar, BarArg *a)
{
return TEXTW(buttonbar3);
}
int
draw_stbutton3(Bar *bar, BarArg *a)
{
return drw_text(drw, a->x, a->y, a->w, a->h, lrpad / 2, buttonbar3, 0, False);
}
int
click_stbutton3(Bar *bar, Arg *arg, BarArg *a)
{
return ClkButton3;
}
int
width_stbutton4(Bar *bar, BarArg *a)
{
return TEXTW(buttonbar4);
}
int
draw_stbutton4(Bar *bar, BarArg *a)
{
return drw_text(drw, a->x, a->y, a->w, a->h, lrpad / 2, buttonbar4, 0, False);
}
int
click_stbutton4(Bar *bar, Arg *arg, BarArg *a)
{
return ClkButton4;
}
int
width_stbutton5(Bar *bar, BarArg *a)
{
return TEXTW(buttonbar5);
}
int
draw_stbutton5(Bar *bar, BarArg *a)
{
return drw_text(drw, a->x, a->y, a->w, a->h, lrpad / 20, buttonbar5, 0, False);
}
int
click_stbutton5(Bar *bar, Arg *arg, BarArg *a)
{
return ClkButton5;
}
int
width_stbutton6(Bar *bar, BarArg *a)
{
return TEXTW(buttonbar6);
}
int
draw_stbutton6(Bar *bar, BarArg *a)
{
return drw_text(drw, a->x, a->y, a->w, a->h, lrpad / 2, buttonbar6, 0, False);
}
int
click_stbutton6(Bar *bar, Arg *arg, BarArg *a)
{
return ClkButton6;
}
int
width_stbutton7(Bar *bar, BarArg *a)
{
return TEXTW(buttonbar7);
}
int
draw_stbutton7(Bar *bar, BarArg *a)
{
return drw_text(drw, a->x, a->y, a->w, a->h, lrpad / 2, buttonbar7, 0, False);
}
int
click_stbutton7(Bar *bar, Arg *arg, BarArg *a)
{
return ClkButton7;
}
int
width_stbutton8(Bar *bar, BarArg *a)
{
return TEXTW(buttonbar8);
}
int
draw_stbutton8(Bar *bar, BarArg *a)
{
return drw_text(drw, a->x, a->y, a->w, a->h, lrpad / 2, buttonbar8, 0, False);
}
int
click_stbutton8(Bar *bar, Arg *arg, BarArg *a)
{
return ClkButton8;
}

View file

@ -1,24 +1,3 @@
static int width_stbutton(Bar *bar, BarArg *a);
static int draw_stbutton(Bar *bar, BarArg *a);
static int click_stbutton(Bar *bar, Arg *arg, BarArg *a);
static int width_stbutton2(Bar *bar, BarArg *a);
static int draw_stbutton2(Bar *bar, BarArg *a);
static int click_stbutton2(Bar *bar, Arg *arg, BarArg *a);
static int width_stbutton3(Bar *bar, BarArg *a);
static int draw_stbutton3(Bar *bar, BarArg *a);
static int click_stbutton3(Bar *bar, Arg *arg, BarArg *a);
static int width_stbutton4(Bar *bar, BarArg *a);
static int draw_stbutton4(Bar *bar, BarArg *a);
static int click_stbutton4(Bar *bar, Arg *arg, BarArg *a);
static int width_stbutton5(Bar *bar, BarArg *a);
static int draw_stbutton5(Bar *bar, BarArg *a);
static int click_stbutton5(Bar *bar, Arg *arg, BarArg *a);
static int width_stbutton6(Bar *bar, BarArg *a);
static int draw_stbutton6(Bar *bar, BarArg *a);
static int click_stbutton6(Bar *bar, Arg *arg, BarArg *a);
static int width_stbutton7(Bar *bar, BarArg *a);
static int draw_stbutton7(Bar *bar, BarArg *a);
static int click_stbutton7(Bar *bar, Arg *arg, BarArg *a);
static int width_stbutton8(Bar *bar, BarArg *a);
static int draw_stbutton8(Bar *bar, BarArg *a);
static int click_stbutton8(Bar *bar, Arg *arg, BarArg *a);

View file

@ -0,0 +1,51 @@
int
width_winbutton(Bar *bar, BarArg *a)
{
return TEXTW(buttonbar6);
}
int
draw_winbutton(Bar *bar, BarArg *a)
{
return drw_text(drw, a->x, a->y, a->w, a->h, lrpad / 2, buttonbar6, 0, False);
}
int
click_winbutton(Bar *bar, Arg *arg, BarArg *a)
{
return ClkButton6;
}
int
width_winbutton2(Bar *bar, BarArg *a)
{
return TEXTW(buttonbar7);
}
int
draw_winbutton2(Bar *bar, BarArg *a)
{
return drw_text(drw, a->x, a->y, a->w, a->h, lrpad / 2, buttonbar7, 0, False);
}
int
click_winbutton2(Bar *bar, Arg *arg, BarArg *a)
{
return ClkButton7;
}
int
width_winbutton3(Bar *bar, BarArg *a)
{
return TEXTW(buttonbar8);
}
int
draw_winbutton3(Bar *bar, BarArg *a)
{
return drw_text(drw, a->x, a->y, a->w, a->h, lrpad / 2, buttonbar8, 0, False);
}
int
click_winbutton3(Bar *bar, Arg *arg, BarArg *a)
{
return ClkButton8;
}

View file

@ -0,0 +1,9 @@
static int width_winbutton(Bar *bar, BarArg *a);
static int draw_winbutton(Bar *bar, BarArg *a);
static int click_winbutton(Bar *bar, Arg *arg, BarArg *a);
static int width_winbutton2(Bar *bar, BarArg *a);
static int draw_winbutton2(Bar *bar, BarArg *a);
static int click_winbutton2(Bar *bar, Arg *arg, BarArg *a);
static int width_winbutton3(Bar *bar, BarArg *a);
static int draw_winbutton3(Bar *bar, BarArg *a);
static int click_winbutton3(Bar *bar, Arg *arg, BarArg *a);

View file

@ -395,4 +395,12 @@
#if TILE_LAYOUT
#include "layout_tile.c"
#endif
#if BAR_DOCKBUTTONS_PATCH
#include "bar_dockbutton.c"
#endif
#if BAR_POWERBUTTON_PATCH
#include "bar_powerbutton.c"
#endif
#if BAR_WINCONTROLBUTTONS_PATCH
#include "bar_wincontrolbutton.c"
#endif

View file

@ -388,4 +388,12 @@
#if TILE_LAYOUT
#include "layout_tile.h"
#endif
#if BAR_DOCKBUTTONS_PATCH
#include "bar_dockbutton.h"
#endif
#if BAR_POWERBUTTON_PATCH
#include "bar_powerbutton.h"
#endif
#if BAR_WINCONTROLBUTTONS_PATCH
#include "bar_wincontrolbutton.h"
#endif

View file

@ -1469,3 +1469,25 @@
* This can be optionally disabled in favour of other layouts.
*/
#define MONOCLE_LAYOUT 1
/**
* Specific build patches
*/
/* Additional status buttons for the taskbar/bottom bar.
* This can be an alternative for dockbar programs.
*/
#define BAR_DOCKBUTTONS_PATCH 1
/* A simple power button for dwm.
* Uses jgmenu, and a script handling the commands.
*/
#define BAR_POWERBUTTON_PATCH 1
/* Decorative window control buttons for dwm.
* Depends on the MAXIMIZE patch.
*/
#define BAR_WINCONTROLBUTTONS_PATCH 1