add support for extra status. most of the code for it is already here,

so i think its stupid not to.
This commit is contained in:
speedie 2023-01-29 01:09:10 +01:00
parent 249e4fe21f
commit ed8d310fc3
16 changed files with 185 additions and 47 deletions

View file

@ -312,8 +312,7 @@ You can add, change and remove keybinds by editing `keybinds.h` and `mouse.h` an
- st - Default terminal
- Chromium - Default web browser
- htop - Status monitor
- sfeed - RSS reader
- rssread - RSS frontend
- newsboat - RSS reader
- cmus - Music player
- Default status bar also has support for moc/mocp (Music On Console)
- neovim - Text editor
@ -542,6 +541,7 @@ Below is a list of all .Xresources values you can define.
- speedwm.stack.i3mcount: 0
- speedwm.stack.mastercount: 1
- speedwm.stack.snap: 20
- speedwm.status.separator: ;
- speedwm.status.defaultstatus:
- speedwm.switcher.maxheight: 200
- speedwm.switcher.maxwidth: 600
@ -783,8 +783,11 @@ Below is a list of all modules bundled with speedwm. The source code for these m
- tags_pwl: Tags with powerlines.
- systray: Basic X11 system tray.
- status_basic: Basic status bar.
- status_basic_es: Basic status bar.
- status: Clickable status bar with color support through status2d.
- status_es: Clickable status bar with color support through status2d (Extra status).
- status_pwl: Non-clickable status bar with powerlines. It supports colors by cycling through colorschemes.
- status_pwl_es: Non-clickable status bar with powerlines. It supports colors by cycling through colorschemes (Extra status).
- title: Title, shows all windows, including hidden windows.
- title_basic: Basic title, shows focused window.

75
bar.h
View file

@ -3,43 +3,43 @@
* This header is for configuring the bar along with its modules. Below are some usage notes.
*
* Monitor:
* -1: Show the module on all monitors.
* 0": Show on the main monitor (monitor 0).
* 'A': Show on the focused monitor.
* -1: Show the module on all monitors.
* 0": Show on the main monitor (monitor 0).
* 'A': Show on the focused monitor.
*
* Bar:
* 0: Main bar.
* 1: Extra bar.
* 0: Main bar.
* 1: Extra bar.
*
* Alignment:
* bar_align_left: Force the module to be placed on the left side of the bar if possible.
* bar_align_right: Force the module to be placed on the right side of the bar if possible.
* bar_align_center: Force the module to be placed in the center of the bar if possible.
* bar_align_left_left: Force the module to be placed on the left side of the bar next to the center split.
* bar_align_left_right: Force the module to be placed on the right side of the bar next to the center split.
* bar_align_left_center: Force the module to be placed on the center in the middle of the remaining space left of the center split on the left..
* bar_align_right_left: Force the module to be placed on the left side of the bar next to the center split.
* bar_align_right_right: Force the module to be placed on the right side of the bar next to the center split.
* bar_align_right_center: Force the module to be placed on the center in the middle of the remaining space left of the center split on the right.
* bar_align_none: No specific alignment. This will give the module the remaining space.
* bar_align_left: Force the module to be placed on the left side of the bar if possible.
* bar_align_right: Force the module to be placed on the right side of the bar if possible.
* bar_align_center: Force the module to be placed in the center of the bar if possible.
* bar_align_left_left: Force the module to be placed on the left side of the bar next to the center split.
* bar_align_left_right: Force the module to be placed on the right side of the bar next to the center split.
* bar_align_left_center: Force the module to be placed on the center in the middle of the remaining space left of the center split on the left..
* bar_align_right_left: Force the module to be placed on the left side of the bar next to the center split.
* bar_align_right_right: Force the module to be placed on the right side of the bar next to the center split.
* bar_align_right_center: Force the module to be placed on the center in the middle of the remaining space left of the center split on the right.
* bar_align_none: No specific alignment. This will give the module the remaining space.
*
* Width:
* Function to run when getting the width of the module.
*
* Syntax: width_<module>
* Example: width_tags_pwl
* Syntax: width_<module>
* Example: width_tags_pwl
*
* Draw
* Function to run when drawing the module.
*
* Syntax: draw_<module>
* Example: draw_tags_pwl
* Syntax: draw_<module>
* Example: draw_tags_pwl
*
* Click
* Function to run when getting a click.
*
* Syntax: click_<module>
* Example: click_tags_pwl
* Syntax: click_<module>
* Example: click_tags_pwl
*
* Module name
* Does nothing special, just helpful for debugging among other things.
@ -48,22 +48,25 @@
*
* List of modules that can be used.
*
* ltsymbol: Standard, basic layout icon.
* tags: Basic tags, without powerlines.
* tags_pwl: Tags with powerlines.
* systray: System tray.
* status_basic: Basic status bar.
* status: Clickable status bar with color support.
* status_pwl: Status with powerlines. NOTE: It is not clickable.
* title: Title, shows all windows, including hidden windows.
* title_basic: Basic title, shows focused window.
* ltsymbol: Standard, basic layout icon.
* tags: Basic tags, without powerlines.
* tags_pwl: Tags with powerlines.
* systray: System tray.
* status_basic: Basic status bar.
* status_basic_es: Basic status bar (Extra status).
* status: Clickable status bar with color support.
* status_es: Clickable status bar with color support (Extra status).
* status_pwl: Status with powerlines. NOTE: It is not clickable.
* status_pwl_es: Status with powerlines. NOTE: It is not clickable (Extra status).
* title: Title, shows all windows, including hidden windows.
* title_basic: Basic title, shows focused window.
*
*/
static const BarRule barrules[] = {
/* Monitor Bar Alignment Width Draw Click Module name */
{ -1, 0, bar_align_left, width_ltsymbol, draw_ltsymbol, click_ltsymbol, "layout" },
{ -1, 0, bar_align_left, width_tags_pwl, draw_tags_pwl, click_tags_pwl, "powerline tags" },
{ 'A', 0, bar_align_right, width_systray, draw_systray, click_systray, "systray" },
{ -1, 0, bar_align_right, width_status_pwl, draw_status_pwl, click_status_pwl, "powerline status" },
{ -1, 0, bar_align_none, width_title, draw_title, click_title, "title" },
/* Monitor Bar Alignment Width Draw Click Module name */
{ -1, 0, bar_align_left, width_ltsymbol, draw_ltsymbol, click_ltsymbol, "layout" },
{ -1, 0, bar_align_left, width_tags_pwl, draw_tags_pwl, click_tags_pwl, "powerline tags" },
{ 'A', 0, bar_align_right, width_systray, draw_systray, click_systray, "systray" },
{ -1, 0, bar_align_right, width_status_pwl, draw_status_pwl, click_status_pwl, "powerline status" },
{ -1, 0, bar_align_none, width_title, draw_title, click_title, "title" },
};

View file

@ -4,8 +4,11 @@
#include "tags.c" /* Include tags */
#include "layoutindicator.c" /* Include layout indicator */
#include "statusbar.c" /* Include status bar with status2d and clickstatus */
#include "statusbar-es.c" /* Include status bar with status2d and clickstatus */
#include "statusbar-basic.c" /* Include basic status bar */
#include "statusbar-basic-es.c" /* Include basic status bar */
#include "statusbar-powerline.c" /* Include powerline status bar */
#include "statusbar-powerline-es.c" /* Include powerline status bar */
#include "title-basic.c" /* Include basic title */
#include "title.c" /* Include title */
#include "systray.c" /* Include systray */

View file

@ -3,8 +3,11 @@
#include "tags.h"
#include "layoutindicator.h"
#include "statusbar.h"
#include "statusbar-es.h"
#include "statusbar-basic.h"
#include "statusbar-basic-es.h"
#include "statusbar-powerline.h"
#include "statusbar-powerline-es.h"
#include "title-basic.h"
#include "title.h"
#include "systray.h"

31
bar/statusbar-basic-es.c Normal file
View file

@ -0,0 +1,31 @@
int
width_status_basic_es(Bar *bar, BarWidthArg *a)
{
if (selmon->hidestatus) {
return 0;
} else {
return TEXTW(estext);
}
}
int
draw_status_basic_es(Bar *bar, BarDrawArg *a)
{
if (selmon->hidestatus) {
return 0;
} else {
return drw_text(drw, a->x, 0, a->w, bh, lrpad / 2, estext, 0, True);
}
}
int
click_status_basic_es(Bar *bar, Arg *arg, BarClickArg *a)
{
if (selmon->hidestatus) {
return 0;
} else {
return clickstatusbar;
}
}

3
bar/statusbar-basic-es.h Normal file
View file

@ -0,0 +1,3 @@
static int width_status_basic_es(Bar *bar, BarWidthArg *a);
static int draw_status_basic_es(Bar *bar, BarDrawArg *a);
static int click_status_basic_es(Bar *bar, Arg *arg, BarClickArg *a);

29
bar/statusbar-es.c Normal file
View file

@ -0,0 +1,29 @@
int
width_status_es(Bar *bar, BarWidthArg *a)
{
if (selmon->hidestatus) {
return 0;
} else {
return textlength(rawestext) + lrpad;
}
}
int
draw_status_es(Bar *bar, BarDrawArg *a)
{
if (selmon->hidestatus) {
return 0;
} else {
return drawstatustext(a->x, rawestext);
}
}
int
click_status_es(Bar *bar, Arg *arg, BarClickArg *a)
{
if (selmon->hidestatus) {
return 0;
} else {
return click_status_text(arg, a->rel_x, rawestext);
}
}

3
bar/statusbar-es.h Normal file
View file

@ -0,0 +1,3 @@
static int width_status_es(Bar *bar, BarWidthArg *a);
static int draw_status_es(Bar *bar, BarDrawArg *a);
static int click_status_es(Bar *bar, Arg *arg, BarClickArg *a);

View file

@ -0,0 +1,29 @@
int
click_status_pwl_es(Bar *bar, Arg *arg, BarClickArg *a)
{
if (selmon->hidestatus) {
return 0;
} else {
return clickstatusbar;
}
}
int
width_status_pwl_es(Bar *bar, BarWidthArg *a)
{
if (selmon->hidestatus) {
return 0;
} else {
return widthpowerlinestatus(rawestext);
}
}
int
draw_status_pwl_es(Bar *bar, BarDrawArg *a)
{
if (selmon->hidestatus) {
return 0;
} else {
return drawpowerlinestatus(a->x + a->w, rawestext);
}
}

View file

@ -0,0 +1,3 @@
static int width_status_pwl_es(Bar *bar, BarWidthArg *a);
static int draw_status_pwl_es(Bar *bar, BarDrawArg *a);
static int click_status_pwl_es(Bar *bar, Arg *arg, BarClickArg *a);

View file

@ -45,8 +45,11 @@ Below is a list of all modules bundled with speedwm. The source code for these m
- tags_pwl: Tags with powerlines.
- systray: Basic X11 system tray.
- status_basic: Basic status bar.
- status_basic_es: Basic status bar.
- status: Clickable status bar with color support through status2d.
- status_es: Clickable status bar with color support through status2d (Extra status).
- status_pwl: Non-clickable status bar with powerlines. It supports colors by cycling through colorschemes.
- status_pwl_es: Non-clickable status bar with powerlines. It supports colors by cycling through colorschemes (Extra status).
- title: Title, shows all windows, including hidden windows.
- title_basic: Basic title, shows focused window.

View file

@ -243,6 +243,7 @@ speedwm.stack.mastercount: 1 ! Number of master clients in the maste
speedwm.stack.snap: 20 ! Snap pixel (<char>)
!! Text to print when no status bar is running. Empty means nothing.
speedwm.status.separator: ;
speedwm.status.defaultstatus:
!! Switcher options

View file

@ -61,6 +61,7 @@ static int autoresize = 1; /* Allow resizing clients aut
static char font[] = "Noto Sans Regular 9"; /* Font to draw the bar with */
/* Status options */
static char statussep = ';'; /* Separator used to switch from the main status bar to the next */
static char defaultstatus[] = ""; /* What to print when a status bar is not running */
/* Task switcher options

View file

@ -1,4 +1,4 @@
.\" Automatically generated by Pandoc 3.0
.\" Automatically generated by Pandoc 3.0.1
.\"
.\" Define V font for inline verbatim, using C font in formats
.\" that render this, and otherwise B font.
@ -602,9 +602,7 @@ Chromium - Default web browser
.IP \[bu] 2
htop - Status monitor
.IP \[bu] 2
sfeed - RSS reader
.IP \[bu] 2
rssread - RSS frontend
newsboat - RSS reader
.IP \[bu] 2
cmus - Music player
.RS 2
@ -1061,6 +1059,8 @@ speedwm.stack.mastercount: 1
.IP \[bu] 2
speedwm.stack.snap: 20
.IP \[bu] 2
speedwm.status.separator: ;
.IP \[bu] 2
speedwm.status.defaultstatus:
.IP \[bu] 2
speedwm.switcher.maxheight: 200
@ -1509,11 +1509,19 @@ systray: Basic X11 system tray.
.IP \[bu] 2
status_basic: Basic status bar.
.IP \[bu] 2
status_basic_es: Basic status bar.
.IP \[bu] 2
status: Clickable status bar with color support through status2d.
.IP \[bu] 2
status_es: Clickable status bar with color support through status2d
(Extra status).
.IP \[bu] 2
status_pwl: Non-clickable status bar with powerlines.
It supports colors by cycling through colorschemes.
.IP \[bu] 2
status_pwl_es: Non-clickable status bar with powerlines.
It supports colors by cycling through colorschemes (Extra status).
.IP \[bu] 2
title: Title, shows all windows, including hidden windows.
.IP \[bu] 2
title_basic: Basic title, shows focused window.

View file

@ -816,12 +816,15 @@ static Client *swallowingclient(Window w);
static Client *termforwin(const Client *c);
static pid_t winpid(Window w);
/* status text */
static char stext[1024];
static char rawstext[1024];
static char estext[1024];
static char rawestext[1024];
/* variables */
static const char notitle[] = ""; /* Title when none can be grabbed. */
static Client *lastfocused = NULL;
static char stext[1024]; /* max character count */
static char rawstext[1024]; /* max character count */
static int screen;
static int tw, sh; /* X display screen geometry width, height */
static int bh; /* bar geometry */
@ -6029,10 +6032,21 @@ updatestatus(void)
Monitor* m;
if (!gettextprop(root, XA_WM_NAME, rawstext, sizeof(rawstext)) && !selmon->hidestatus) {
strcpy(stext, defaultstatus);
estext[0] = '\0';
} else {
if (!selmon->hidestatus) {
copyvalidchars(stext, rawstext);
}
char *e = strchr(rawstext, statussep);
if (e) {
*e = '\0'; e++;
strncpy(rawestext, e, sizeof(estext) - 1);
copyvalidchars(estext, rawestext);
} else {
estext[0] = '\0';
}
copyvalidchars(stext, rawstext);
}
}
for (m = mons; m; m = m->next)

View file

@ -97,6 +97,7 @@ ResourcePref resources[] = {
{ "text.layout14", STRING, &text_layout14 },
{ "text.layout15", STRING, &text_layout15 },
{ "run.shell", STRING, &shell },
{ "status.separator", STRING, &statussep },
{ "status.defaultstatus", STRING, &defaultstatus },
{ "fullscreen.lockfullscreen", INTEGER, &lockfullscreen },
{ "fullscreen.movefullscreenmon", INTEGER, &movefullscreenmon },