commit 6b684f915130c464239c0bc33e60a53b215db575
Author: uint23 <abhinav.prsai@gmail.com>
AuthorDate: Thu Apr 10 19:55:36 2025 +0100
Commit: uint23 <abhinav.prsai@gmail.com>
CommitDate: Thu Apr 10 19:55:36 2025 +0100
qol
qol
---
src/config.h | 14 +++++++++-----
src/sxbar.c | 54 +++++++++++++++++++++---------------------------------
2 files changed, 30 insertions(+), 38 deletions(-)
diff --git a/src/config.h b/src/config.h
index dac372c..08cc978 100644
--- a/src/config.h
+++ b/src/config.h
@@ -7,6 +7,11 @@
#define MAXBARH 40 // The max height of the bar, this shouldn't really be more than 40
#define MAXBDRW 10 // The max border width of the bar
+#include <X11/keysym.h>
+#define BUTTONLC 1 // Left click
+#define BUTTONMC 2 // Middle click
+#define BUTTONRC 3 // Right click
+
// Keybindings
//#define TOGGLE { ModMask|ShiftMask, XK_b, {.v=toggle}}
@@ -15,10 +20,9 @@ static unsigned int centre = 1; // If using padding, this will centre your bar
static unsigned int barh = 20; // Bar height
static unsigned int padh = 400; // Horizontal bar padding
static unsigned int padv = 10; // Vertical bar padding
-static unsigned int bdrw = 0; // Border width of the bar. Set to 0 for no border
+static unsigned int bdrw = 10; // Border width of the bar. Set to 0 for no border
-static const char colfg[] = "#ABCDEF"; // Foreground colour
-static const char colbg[] = "#555555"; // Background colour
-static const char colbdr[] = "#090425"; // Border colour
+static const char colbg[] = "#A0A0DD"; // Background colour
+static const char colbdr[] = "#FF0000"; // Border colour
// static const char *font = "terminus";
-// static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
+static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
diff --git a/src/sxbar.c b/src/sxbar.c
index dbb30bc..28b02c1 100644
--- a/src/sxbar.c
+++ b/src/sxbar.c
@@ -2,6 +2,7 @@
#include <X11/X.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
+#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <time.h>
@@ -29,12 +30,11 @@ static void cleanup(void);
static void createwin(void);
static unsigned long getcol(const char *colstr);
static void run(void);
-static void setdock(void);
+static void setatoms(void);
static void sethints(void);
static void setup(void);
// Variables
-static unsigned long fgpx;
static unsigned long bgpx;
static unsigned long bdrpx;
static unsigned int scrw;
@@ -46,6 +46,7 @@ static unsigned int barw;
static Display *dpy;
static Window barwin;
static Window root;
+//static GC gc;
// Functions
static void
@@ -66,13 +67,8 @@ createwin(void)
ExposureMask | KeyPressMask
);
- // Set dock properties BEFORE mapping
- setdock();
-
- // Map the window
+ setatoms();
XMapWindow(dpy, barwin);
-
- // Make sure it's on top
XRaiseWindow(dpy, barwin);
XSync(dpy, False);
}
@@ -116,7 +112,7 @@ run(void)
}
static void
-setdock(void)
+setatoms(void)
{
Atom type, dock, state, sticky, strut, strutpartial, override;
unsigned long strutvals[4] = {0}; // left, right, top, bottom
@@ -191,41 +187,33 @@ setup(void)
if (dpy == 0)
death("Failed to open display.");
- scr = DefaultScreen(dpy);
+ scr = DefaultScreen(dpy);
scrw = DisplayWidth(dpy, scr);
scrh = DisplayHeight(dpy, scr);
root = RootWindow(dpy, scr);
-
- if (topbar) {
- if (padv) bary = padv;
- else bary = 0;
- } else {
- if (padv) bary = scrh - barh - padv;
- else bary = scrh - barh;
- }
+ // Calculate bar y-position
+ if (topbar)
+ bary = padv ? padv : 0;
+ else
+ bary = padv ? scrh - barh - padv - bdrw :
+ scrh - barh - bdrw;
+
+ // Calculate bar x-position and width
if (padh) {
- if (centre) {
- barx = padh;
- barw = scrw - (padh * 2);
- } else {
- barx = 0;
- barw = scrw - padh;
- }
+ barx = centre ? padh : 0;
+ barw = centre ? scrw - (padh * 2) : scrw - padh;
} else {
barx = 0;
barw = scrw;
}
- if (barh > MAXBARH)
- barh = MAXBARH;
- if (padv > MAXPADV)
- padv = MAXPADV;
- if (padh > MAXPADH)
- padh = MAXPADH;
+ // Clamp dimensions
+ if (barh > MAXBARH) barh = MAXBARH;
+ if (padv > MAXPADV) padv = MAXPADV;
+ if (padh > MAXPADH) padh = MAXPADH;
- fgpx = getcol(colfg);
- bgpx = getcol(colbg);
+ bgpx = getcol(colbg);
bdrpx = getcol(colbdr);
}