removed slstatus and just built it into dwm instead as it is really simple
This commit is contained in:
@@ -2,9 +2,6 @@ if [[ $- != *i* ]] ; then
|
||||
return
|
||||
fi
|
||||
|
||||
# source /usr/share/bash-completion/completions/fzf
|
||||
# source /usr/share/fzf/key-bindings.bash
|
||||
|
||||
alias ls="ls -a --color"
|
||||
alias comp="make && doas make install && make clean && pkill dwm"
|
||||
alias update_world="doas emerge --ask --update --newuse --deep @world"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
function! everforest#get_configuration() "{{{
|
||||
return {
|
||||
\ 'background': get(g:, 'everforest_background', 'medium'),
|
||||
\ 'transparent_background': get(g:, 'everforest_transparent_background', 1),
|
||||
\ 'transparent_background': get(g:, 'everforest_transparent_background', 2),
|
||||
\ 'dim_inactive_windows': get(g:, 'everforest_dim_inactive_windows', 0),
|
||||
\ 'disable_italic_comment': get(g:, 'everforest_disable_italic_comment', 0),
|
||||
\ 'enable_italic': get(g:, 'everforest_enable_italic', 0),
|
||||
|
||||
@@ -15,7 +15,7 @@ LDFLAGS = ${LIBS}
|
||||
|
||||
CC = gcc
|
||||
|
||||
SRC = drw.c dwm.c util.c
|
||||
SRC = bar.c drw.c dwm.c util.c
|
||||
OBJ = ${SRC:.c=.o}
|
||||
|
||||
all: dwm
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
#include "bar.h"
|
||||
#include <stdio.h>
|
||||
|
||||
const char* vol() {
|
||||
static char buf[5];
|
||||
float v;
|
||||
FILE *fp = popen("wpctl get-volume @DEFAULT_AUDIO_SINK@", "r");
|
||||
if (!fp || fscanf(fp, "Volume: %f", &v) != 1) return NULL;
|
||||
pclose(fp);
|
||||
snprintf(buf, sizeof(buf), "%d%%", (int)(v * 100));
|
||||
return buf;
|
||||
}
|
||||
|
||||
const char* age() {
|
||||
static char buf[5];
|
||||
int days;
|
||||
FILE *fp = popen("sh -c 'echo $(( ( $(date +%s) - $(stat -c %W /) ) / 86400 ))'", "r");
|
||||
if (!fp || fscanf(fp, "%d", &days) != 1) return NULL;
|
||||
pclose(fp);
|
||||
snprintf(buf, sizeof(buf), "%dd", days);
|
||||
return buf;
|
||||
}
|
||||
|
||||
void execute_bar(char *out, size_t len) {
|
||||
snprintf(out, len, "V: %s A: %s", vol(), age());
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
#include "util.h"
|
||||
void execute_bar(char *out, size_t len);
|
||||
@@ -14,6 +14,7 @@
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/Xft/Xft.h>
|
||||
|
||||
#include "bar.h"
|
||||
#include "drw.h"
|
||||
#include "util.h"
|
||||
|
||||
@@ -649,6 +650,7 @@ drawbar(Monitor *m)
|
||||
return;
|
||||
/* draw status first so it can be overdrawn by tags later */
|
||||
if (m == selmon) { /* status is only drawn on selected monitor */
|
||||
execute_bar(stext, sizeof(stext));
|
||||
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||
tw = TEXTW(stext) - lrpad + 2; /* 2px right padding */
|
||||
drw_text(drw, m->ww - tw, 0, tw, bh, 0, stext, 0);
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#include <stddef.h>
|
||||
#define MAX(A, B) ((A) > (B) ? (A) : (B))
|
||||
#define MIN(A, B) ((A) < (B) ? (A) : (B))
|
||||
#define BETWEEN(X, A, B) ((A) <= (X) && (X) <= (B))
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
.POSIX:
|
||||
|
||||
PREFIX = /usr/local
|
||||
CFLAGS = -std=c17 -pedantic -Wall -Wextra -Wno-unused-parameter -O2 -march=native $(shell pkg-config --cflags x11) -D_DEFAULT_SOURCE
|
||||
|
||||
slstatus: slstatus.c
|
||||
gcc $(CFLAGS) -o $@ $< -s $(shell pkg-config --libs-only-L x11) $(shell pkg-config --libs-only-l x11)
|
||||
|
||||
clean:
|
||||
rm -f slstatus
|
||||
|
||||
install: slstatus
|
||||
install -Dm755 slstatus "$(DESTDIR)$(PREFIX)/bin/slstatus"
|
||||
|
||||
uninstall:
|
||||
rm -f "$(DESTDIR)$(PREFIX)/bin/slstatus"
|
||||
@@ -1,76 +0,0 @@
|
||||
#define _GNU_SOURCE
|
||||
#define AT_FDCWD -100
|
||||
#include <sys/syscall.h>
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include <sys/stat.h>
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
const char* vol() {
|
||||
static char buf[5];
|
||||
float v;
|
||||
FILE *fp = popen("wpctl get-volume @DEFAULT_AUDIO_SINK@", "r");
|
||||
if (!fp || fscanf(fp, "Volume: %f", &v) != 1) return NULL;
|
||||
pclose(fp);
|
||||
snprintf(buf, sizeof(buf), "%d%%", (int)(v * 100));
|
||||
return buf;
|
||||
}
|
||||
|
||||
const char* age() {
|
||||
static char buf[4];
|
||||
static time_t last;
|
||||
time_t now = time(NULL);
|
||||
if (now - last < 900) return buf;
|
||||
struct statx stx;
|
||||
time_t created = (!syscall(SYS_statx, AT_FDCWD, "/", 0, STATX_BTIME, &stx) && (stx.stx_mask & STATX_BTIME)) ? stx.stx_btime.tv_sec : now;
|
||||
snprintf(buf, sizeof(buf), "%d", (int)((now - created) / 86400));
|
||||
last = now;
|
||||
return buf;
|
||||
}
|
||||
|
||||
volatile sig_atomic_t done = 0;
|
||||
void terminate() { done = 1; }
|
||||
void die(const char *msg) {
|
||||
fprintf(stderr, "%s\n", msg);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int main() {
|
||||
Display *dpy;
|
||||
size_t i, len;
|
||||
int ret;
|
||||
char status[18];
|
||||
struct sigaction act = { .sa_handler = terminate, .sa_flags = SA_RESTART };
|
||||
struct arg {
|
||||
const char *(*func)(void);
|
||||
const char *fmt;
|
||||
};
|
||||
const struct arg args[] = {
|
||||
{ vol, "V: %s " }, // 9 bytes
|
||||
{ age, "A: %sd" }, // 8 bytes
|
||||
};
|
||||
|
||||
sigaction(SIGINT, &act, NULL);
|
||||
sigaction(SIGTERM, &act, NULL);
|
||||
|
||||
if (!(dpy = XOpenDisplay(NULL))) die("XOpenDisplay: Failed to open display");
|
||||
while(!done) {
|
||||
status[0] = '\0';
|
||||
for (i = len = 0; i < 2; i++) {
|
||||
const char *res = args[i].func();
|
||||
if (!res) res = "n/a";
|
||||
if ((ret = snprintf(status + len, sizeof(status) - len, args[i].fmt, res)) < 0) break;
|
||||
len += ret;
|
||||
}
|
||||
|
||||
if (XStoreName(dpy, DefaultRootWindow(dpy), status) < 0) die("XStoreName: Allocation failed");
|
||||
XFlush(dpy);
|
||||
nanosleep(&(struct timespec){ .tv_sec = 0, .tv_nsec = 500 * 1000000 }, NULL); // 500ms
|
||||
}
|
||||
XStoreName(dpy, DefaultRootWindow(dpy), NULL);
|
||||
if (XCloseDisplay(dpy) < 0) die("XCloseDisplay: Failed to close display");
|
||||
return 0;
|
||||
}
|
||||
@@ -66,7 +66,6 @@ static unsigned int cursorthickness = 2;
|
||||
*/
|
||||
static int bellvolume = 0;
|
||||
|
||||
// char *termname = "st-256color";
|
||||
char *termname = "st-256color";
|
||||
unsigned int tabspaces = 8;
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -4,7 +4,6 @@ bind M-, send-prefix
|
||||
|
||||
set -g focus-events on
|
||||
set-option -g default-terminal "tmux-256color"
|
||||
set-option -as terminal-features ',xterm-ghostty:RGB'
|
||||
set -g status-style 'fg=#7FBBB3 bg=default'
|
||||
set -g base-index 1
|
||||
set -g pane-base-index 1
|
||||
@@ -22,7 +21,6 @@ set -g @plugin 'tmux-plugins/tmux-resurrect'
|
||||
set -g @plugin 'tmux-plugins/tmux-continuum'
|
||||
|
||||
set -g @continuum-restore 'on'
|
||||
set -g @continuum-boot 'on'
|
||||
set -g @resurrect-strategy-nvim 'session'
|
||||
|
||||
run '$HOME/.config/tmux/plugins/tpm/tpm'
|
||||
|
||||
Reference in New Issue
Block a user