Compare commits

..

29 Commits

Author SHA1 Message Date
ee01830c33 Add fcitx5 module 2023-09-29 11:25:28 -07:00
cef428daea Added dwmblocks-mu4e 2023-09-29 03:39:29 -07:00
cf2d0ed30e Fix possible resource leak 2023-09-16 11:02:44 -07:00
bb55ac56dd Move some stuff around 2023-09-15 22:10:53 -07:00
e911dd7095 Update blocks.def.h 2023-09-15 15:05:07 -07:00
ae08d6f2ce Create config.def.mk 2023-09-15 15:03:02 -07:00
3b0049fed5 Add space after bluetooth in network 2023-09-09 20:31:16 -07:00
4aaf17b26a Remove PKGBUILD 2023-09-09 02:11:55 -07:00
316e32a6a5 Update Makefile and add config.mk 2023-09-09 02:11:00 -07:00
89073bf8bd Update PKGBUILD 2023-09-09 00:35:10 -07:00
cc78fe00af Ensure pulse gets cleaned up 2023-09-09 00:31:15 -07:00
26b304eeb3 Make pulse listener built in 2023-09-08 23:39:55 -07:00
f009fcb92b Update dwmblocks-battery 2023-07-29 00:18:16 -07:00
76c2d59fcc Merge branch 'main' of git.zander.im:Zander671/dwmblocks 2023-07-28 23:49:57 -07:00
6ae62476ce Update dwmblocks-battery 2023-07-28 23:49:29 -07:00
ca5b3e68ba Fix dwmblocks-volume 2023-06-07 15:30:14 -07:00
def7285b73 Ensure dwmblocks-fcitx5 gets uninstalled in Makefile 2023-05-28 10:56:08 -07:00
a28859d1f2 Added dwmblocks-fcitx5 2023-05-28 10:50:45 -07:00
6165643fb3 Add PKGBUILD 2023-05-23 03:04:48 -07:00
294ad801e4 ix volume script 2023-05-06 14:31:12 -07:00
41c41b7702 pdate icons in scripts 2023-05-04 15:04:51 -07:00
2e64eee765 Clean up dwmblocks-pulse-listener.c 2023-03-06 12:53:36 -08:00
502f596c87 Clean up dwmblocks-pulse-listener.c 2023-02-23 12:07:46 -08:00
b0441e32af Update README.md 2023-02-23 11:59:57 -08:00
5400dcfc75 Fix wait time 2023-02-23 10:22:56 -08:00
c37f05bc35 Merge branch 'main' of git.zander.im:Zander671/dwmblocks 2023-02-23 09:27:37 -08:00
b88de94327 Merge branch 'main' of git.zander.im:Zander671/dwmblocks 2023-02-23 09:27:22 -08:00
0c37278ced Merge branch 'main' of git.zander.im:Zander671/dwmblocks 2023-02-23 09:23:04 -08:00
e18e6ac3a9 Added dwmblocks-pulse-listener.c 2023-02-23 09:22:54 -08:00
13 changed files with 277 additions and 132 deletions

57
.gitignore vendored
View File

@ -1,56 +1,3 @@
# Custom blocks file
blocks.h
# Prerequisites
*.d
# Object files
*.o
*.ko
*.obj
*.elf
# Linker output
*.ilk
*.map
*.exp
# Precompiled Headers
*.gch
*.pch
# Libraries
*.lib
*.a
*.la
*.lo
# Shared objects (inc. Windows DLLs)
*.dll
*.so
*.so.*
*.dylib
# Executables
*.exe
*.out
*.app
*.i*86
*.x86_64
*.hex
dwmblocks dwmblocks
config.mk
# Debug files blocks.h
*.dSYM/
*.su
*.idb
*.pdb
# Kernel Module Compile Results
*.mod*
*.cmd
.tmp_versions/
modules.order
Module.symvers
Mkfile.old
dkms.conf

View File

@ -1,27 +1,23 @@
PREFIX := /usr/local include config.mk
CC := cc
CFLAGS := -pedantic -Wall -Wno-deprecated-declarations -Os
LDFLAGS := -lX11
# FreeBSD (uncomment)
#LDFLAGS += -L/usr/local/lib -I/usr/local/include
# # OpenBSD (uncomment)
#LDFLAGS += -L/usr/X11R6/lib -I/usr/X11R6/include
all: options dwmblocks all: options dwmblocks
options: options:
@echo dwmblocks build options: @echo dwmblocks build options:
@echo "CFLAGS = ${CFLAGS}" @echo "CFLAGS = ${CFLAGS} ${NO_X}"
@echo "LDFLAGS = ${LDFLAGS}" @echo "LDFLAGS = ${LDFLAGS}"
@echo "CC = ${CC}" @echo "CC = ${CC}"
@echo "PULSEFLAGS = ${PULSEFLAGS}"
dwmblocks: dwmblocks.c blocks.def.h blocks.h dwmblocks: dwmblocks.c pulse-listener.c blocks.def.h blocks.h
${CC} -o dwmblocks dwmblocks.c ${CFLAGS} ${LDFLAGS} ${CC} ${NO_X} -o dwmblocks dwmblocks.c pulse-listener.c ${CFLAGS} ${PULSEFLAGS} ${LDFLAGS}
blocks.h: blocks.h:
cp blocks.def.h $@ cp blocks.def.h $@
config.mk:
cp config.def.mk $@
clean: clean:
rm -f *.o *.gch dwmblocks rm -f *.o *.gch dwmblocks
@ -32,6 +28,11 @@ install: dwmblocks
install -m0755 scripts/* ${DESTDIR}${PREFIX}/bin install -m0755 scripts/* ${DESTDIR}${PREFIX}/bin
uninstall: uninstall:
rm -f ${DESTDIR}${PREFIX}/bin/dwmblocks rm -f ${DESTDIR}${PREFIX}/bin/dwmblocks \
${DESTDIR}${PREFIX}/bin/dwmblocks-battery \
${DESTDIR}${PREFIX}/bin/dwmblocks-network \
${DESTDIR}${PREFIX}/bin/dwmblocks-volume \
${DESTDIR}${PREFIX}/bin/dwmblocks-fcitx5 \
${DESTDIR}${PREFIX}/bin/dwmblocks-mu4e
.PHONY: all options clean install uninstall .PHONY: all options clean install uninstall

View File

@ -1,15 +1,26 @@
# dwmblocks # dwmblocks
Modular status bar for dwm written in c. My personal fork of dwmblocks. Original found
# usage [here](https://github.com/torrinfail/dwmblocks).
Dwmblocks is a modular status bar for dwm written in c.
## Usage
To use dwmblocks first run 'make' and then install it with 'sudo make install'. To use dwmblocks first run 'make' and then install it with 'sudo make install'.
After that you can put dwmblocks in your xinitrc or other startup script to have it start with dwm. After that you can put dwmblocks in your xinitrc or other startup script to have
# modifying blocks it start with dwm.
The statusbar is made from text output from commandline programs.
Blocks are added and removed by editing the blocks.h header file. The dwmblocks-pulse-listener program is a small daemon that takes the pid of a
By default the blocks.h header file is created the first time you run make which copies the default config from blocks.def.h. dwmblocks instance and notifies it of pulse audio volume changes.
This is so you can edit your status bar commands and they will not get overwritten in a future update.
# patches ## Modifying Blocks
Here are some patches to dwmblocks that add features that I either don't want to merge in, or that require a dwm patch to work. The status bar is made from text output from command-line programs. Blocks are
I do not maintain these but I will take pull requests to update them. added and removed by editing the blocks.h header file. By default the blocks.h
<br> header file is created the first time you run make which copies the default
<a href=https://gist.github.com/IGeraGera/e4a5583b91b3eec2e81fdceb44dea717>dwmblocks-statuscmd-b6b0be4.diff</a> config from blocks.def.h. This is so you can edit your status bar commands and
they will not get overwritten in a future update.
## Other Changes
Note that the intervals listed in blocks.h are in milliseconds (1/1000 second).
Because of this, the SECONDS() macro is provided for readability. I also
implemented some changes from Luke Smith's fork found
[here](https://github.com/LukeSmithxyz/dwmblocks).

View File

@ -3,13 +3,22 @@
static const Block blocks[] = { static const Block blocks[] = {
/*Icon*/ /*Command*/ /*Update Interval*/ /*Update Signal*/ /*Icon*/ /*Command*/ /*Update Interval*/ /*Update Signal*/
{"", "dwmblocks-battery", SECONDS(10), 0}, // {"", "dwmblocks-battery", SECONDS(10), 0},
{"", "dwmblocks-volume", 125, 0}, {"", "[ \"$(fcitx5-remote)\" -eq 2 ] && printf '和' || printf '英'", 0, 2},
{"", "dwmblocks-mu4e", SECONDS(15), 0},
{"", "dwmblocks-volume", 0, 1},
{"", "date +'%a %b %d'", SECONDS(30), 0}, {"", "date +'%a %b %d'", SECONDS(30), 0},
{"", "date +'%R'", SECONDS(2), 0}, {"", "date +'%R'", SECONDS(2), 0},
{"", "dwmblocks-network", SECONDS(5), 0}, {"", "dwmblocks-network", SECONDS(5), 0},
//{"", "dwmblocks-fcitx5", 250, 0},
};
#include "pulse-listener.h"
static const ThreadCallback thread_callbacks[] = {
pulse_listener_main
}; };
// sets delimeter between status commands. NULL character ('\0') means no delimeter. // sets delimeter between status commands. NULL character ('\0') means no delimeter.
static char delim[] = " "; static char delim[] = " ";
static unsigned int delimLen = 5; static unsigned int delimLen = 2;

14
config.def.mk Normal file
View File

@ -0,0 +1,14 @@
PREFIX := /usr/local
CC := cc
CFLAGS := -pedantic -Wall -Wno-deprecated-declarations -Os
LDFLAGS := -lX11
PULSEFLAGS := -lpulse
NO_X =
# Uncomment to build without X11
# NO_X = -DNO_X
# FreeBSD (uncomment)
#LDFLAGS += -L/usr/local/lib -I/usr/local/include
# OpenBSD (uncomment)
#LDFLAGS += -L/usr/X11R6/lib -I/usr/X11R6/include

View File

@ -4,12 +4,14 @@
#include<unistd.h> #include<unistd.h>
#include<signal.h> #include<signal.h>
#include <time.h> #include <time.h>
#include <math.h>
#include <pthread.h>
#ifndef NO_X #ifndef NO_X
#include<X11/Xlib.h> #include<X11/Xlib.h>
#endif #endif
#ifdef __OpenBSD__ #ifdef __OpenBSD__
#define SIGPLUS SIGUSR1+1 #define SIGPLUS (SIGUSR1 + 1)
#define SIGMINUS SIGUSR1-1 #define SIGMINUS (SIGUSR1 - 1)
#else #else
#define SIGPLUS SIGRTMIN #define SIGPLUS SIGRTMIN
#define SIGMINUS SIGRTMIN #define SIGMINUS SIGRTMIN
@ -26,6 +28,7 @@ typedef struct {
unsigned int interval; unsigned int interval;
unsigned int signal; unsigned int signal;
} Block; } Block;
typedef void(*ThreadCallback)(pthread_t *);
void getcmd(const Block *block, char *output); void getcmd(const Block *block, char *output);
void getcmds(int time); void getcmds(int time);
void getsigcmds(unsigned int signal); void getsigcmds(unsigned int signal);
@ -37,7 +40,9 @@ void setupsignals(void);
int getstatus(char *str, char *last); int getstatus(char *str, char *last);
void pstdout(void); void pstdout(void);
int gcd(int n1, int n2); int gcd(int n1, int n2);
void startthreads(void);
void statusloop(void); void statusloop(void);
void stopthreads(void);
void termhandler(void); void termhandler(void);
#ifndef NO_X #ifndef NO_X
void setroot(void); void setroot(void);
@ -56,6 +61,10 @@ static char statusbar[LENGTH(blocks)][CMDLENGTH] = {0};
static char statusstr[2][STATUSLENGTH]; static char statusstr[2][STATUSLENGTH];
static int statuscontinue = 1; static int statuscontinue = 1;
static pthread_t main_thread;
static pthread_t threads[LENGTH(thread_callbacks)];
static int initdone = 0;
//opens process *cmd and stores output in *output //opens process *cmd and stores output in *output
void getcmd(const Block *block, char *output) { void getcmd(const Block *block, char *output) {
strcpy(output, block->icon); strcpy(output, block->icon);
@ -64,7 +73,7 @@ void getcmd(const Block *block, char *output) {
return; return;
} }
int i = strlen(block->icon); int i = strlen(block->icon);
fgets(output+i, CMDLENGTH-i-delimLen, cmdf); fgets(output + i, CMDLENGTH - i - delimLen, cmdf);
i = strlen(output); i = strlen(output);
if (i == 0) { if (i == 0) {
//return if block and command output are both empty //return if block and command output are both empty
@ -72,9 +81,9 @@ void getcmd(const Block *block, char *output) {
return; return;
} }
//only chop off newline if one is present at the end //only chop off newline if one is present at the end
i = output[i-1] == '\n' ? i-1 : i; i = output[i - 1] == '\n' ? i - 1 : i;
if (delim[0] != '\0') { if (delim[0] != '\0') {
strncpy(output+i, delim, delimLen); strncpy(output + i, delim, delimLen);
} else { } else {
output[i++] = '\0'; output[i++] = '\0';
} }
@ -83,20 +92,20 @@ void getcmd(const Block *block, char *output) {
void getcmds(int time) { void getcmds(int time) {
const Block* current; const Block* current;
for (unsigned int i = 0; i < LENGTH(blocks); i++) { for (unsigned int i = 0; i < LENGTH(blocks); ++i) {
current = blocks + i; current = blocks + i;
if ((current->interval != 0 && time % current->interval == 0) || time == -1) { if ((current->interval != 0 && time % current->interval == 0) || time == -1) {
getcmd(current,statusbar[i]); getcmd(current, statusbar[i]);
} }
} }
} }
void getsigcmds(unsigned int signal) { void getsigcmds(unsigned int signal) {
const Block *current; const Block *current;
for (unsigned int i = 0; i < LENGTH(blocks); i++) { for (unsigned int i = 0; i < LENGTH(blocks); ++i) {
current = blocks + i; current = blocks + i;
if (current->signal == signal) { if (current->signal == signal) {
getcmd(current,statusbar[i]); getcmd(current, statusbar[i]);
} }
} }
} }
@ -116,14 +125,14 @@ void sighandler(int signum) {
void setupsignals() { void setupsignals() {
#ifndef __OpenBSD__ #ifndef __OpenBSD__
/* initialize all real time signals with dummy handler */ /* initialize all real time signals with dummy handler */
for (int i = SIGRTMIN; i <= SIGRTMAX; i++) { for (int i = SIGRTMIN; i <= SIGRTMAX; ++i) {
signal(i, dummysighandler); signal(i, dummysighandler);
} }
#endif #endif
for (unsigned int i = 0; i < LENGTH(blocks); i++) { for (unsigned int i = 0; i < LENGTH(blocks); ++i) {
if (blocks[i].signal > 0) { if (blocks[i].signal > 0) {
signal(SIGMINUS+blocks[i].signal, sighandler); signal(SIGMINUS + blocks[i].signal, sighandler);
} }
} }
@ -132,7 +141,7 @@ void setupsignals() {
int getstatus(char *str, char *last) { int getstatus(char *str, char *last) {
strcpy(last, str); strcpy(last, str);
str[0] = '\0'; str[0] = '\0';
for (unsigned int i = 0; i < LENGTH(blocks); i++) { for (unsigned int i = 0; i < LENGTH(blocks); ++i) {
strcat(str, statusbar[i]); strcat(str, statusbar[i]);
} }
str[strlen(str)-strlen(delim)] = '\0'; str[strlen(str)-strlen(delim)] = '\0';
@ -140,10 +149,18 @@ int getstatus(char *str, char *last) {
} }
void pstdout() { void pstdout() {
if (!getstatus(statusstr[0], statusstr[1])) { //Only write out if text has changed. if (!initdone || !getstatus(statusstr[0], statusstr[1])) { //Only write out if text has changed.
return; return;
} }
printf("%s\n",statusstr[0]); printf("%s\n", statusstr[0]);
fflush(stdout);
}
void somebar_pstdout() {
if (!initdone || !getstatus(statusstr[0], statusstr[1])) { //Only write out if text has changed.
return;
}
printf("status %s\n", statusstr[0]);
fflush(stdout); fflush(stdout);
} }
@ -157,19 +174,34 @@ int gcd(int n1, int n2) {
return n1; return n1;
} }
void startthreads() {
main_thread = pthread_self();
for (int i = 0; i < LENGTH(thread_callbacks); ++i) {
pthread_create(&threads[i],
NULL,
(void *(*)(void *)) thread_callbacks[i],
&main_thread);
}
}
void statusloop() { void statusloop() {
setupsignals(); setupsignals();
unsigned int interval = -1; unsigned int interval = -1;
for (int i = 0; i < LENGTH(blocks); i++){ for (int i = 0; i < LENGTH(blocks); ++i){
if (blocks[i].interval){ if (blocks[i].interval){
interval = gcd(blocks[i].interval, interval); interval = gcd(blocks[i].interval, interval);
} }
} }
startthreads();
int i = 0; int i = 0;
getcmds(-1); getcmds(-1);
const struct timespec sleeptime = { 0, interval * 1000000 }; long nsec_part = interval * 1000000;
time_t sec_part = floor(nsec_part / 1000000000.0);
nsec_part -= sec_part * 1000000000l;
const struct timespec sleeptime = { sec_part, nsec_part };
struct timespec tosleep = sleeptime; struct timespec tosleep = sleeptime;
while (statuscontinue) { while (statuscontinue) {
initdone = 1;
if (nanosleep(&tosleep, &tosleep) < 0) { if (nanosleep(&tosleep, &tosleep) < 0) {
continue; continue;
} }
@ -179,13 +211,20 @@ void statusloop() {
} }
} }
void stopthreads() {
for (int i = 0; i < LENGTH(thread_callbacks); ++i) {
pthread_cancel(threads[i]);
pthread_join(threads[i], NULL);
}
}
void termhandler() { void termhandler() {
statuscontinue = 0; statuscontinue = 0;
} }
#ifndef NO_X #ifndef NO_X
void setroot() { void setroot() {
if (!getstatus(statusstr[0], statusstr[1])) { //Only set root if text has changed. if (!initdone || !getstatus(statusstr[0], statusstr[1])) { //Only set root if text has changed.
return; return;
} }
XStoreName(dpy, root, statusstr[0]); XStoreName(dpy, root, statusstr[0]);
@ -210,6 +249,8 @@ int main(int argc, char** argv) {
strncpy(delim, argv[++i], delimLen); strncpy(delim, argv[++i], delimLen);
} else if (strcmp("-p", argv[i]) == 0) { } else if (strcmp("-p", argv[i]) == 0) {
writestatus = pstdout; writestatus = pstdout;
} else if (strcmp("-s", argv[i]) == 0) {
writestatus = somebar_pstdout;
} }
} }
#ifndef NO_X #ifndef NO_X
@ -225,5 +266,6 @@ int main(int argc, char** argv) {
#ifndef NO_X #ifndef NO_X
XCloseDisplay(dpy); XCloseDisplay(dpy);
#endif #endif
stopthreads();
return 0; return 0;
} }

103
pulse-listener.c Normal file
View File

@ -0,0 +1,103 @@
#include "pulse-listener.h"
#include <pulse/pulseaudio.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <signal.h>
#include <limits.h>
#define ERROR(...) fprintf(stderr, "error: " __VA_ARGS__)
#ifdef __OpenBSD__
#define SIGMAX (SIGUSR2 - 1)
#define SIGMIN (SIGUSR1 - 1)
#else
#define SIGMAX SIGRTMAX
#define SIGMIN SIGRTMIN
#endif
static void sink_info_callback(pa_context *ctx, const pa_sink_info *info,
int eol, pthread_t *main_thread) {
pthread_kill(*main_thread, SIGMIN + 1);
}
static void server_info_callback(pa_context *ctx, const pa_server_info *info,
pthread_t *main_thread) {
pa_operation *op = pa_context_get_sink_info_by_name(
ctx,
info->default_sink_name,
(pa_sink_info_cb_t) sink_info_callback,
main_thread);
pa_operation_unref(op);
}
static void subscribe_callback(pa_context *ctx,
pa_subscription_event_type_t type, uint32_t idx,
pthread_t *main_thread) {
if ((type & PA_SUBSCRIPTION_EVENT_FACILITY_MASK) == PA_SUBSCRIPTION_EVENT_SINK) {
pa_operation *op = pa_context_get_sink_info_by_index(ctx,
idx,
(pa_sink_info_cb_t) sink_info_callback,
main_thread);
pa_operation_unref(op);
}
}
static void state_callback(pa_context *ctx, pthread_t *main_thread) {
pa_operation *op;
switch (pa_context_get_state(ctx)) {
case PA_CONTEXT_READY:
op = pa_context_get_server_info(ctx,
(pa_server_info_cb_t) server_info_callback,
main_thread);
pa_operation_unref(op);
pa_context_set_subscribe_callback(ctx,
(pa_context_subscribe_cb_t) subscribe_callback,
main_thread);
op = pa_context_subscribe(ctx, PA_SUBSCRIPTION_MASK_SINK, NULL, NULL);
pa_operation_unref(op);
break;
case PA_CONTEXT_FAILED:
pthread_kill(*main_thread, SIGMIN + 1);
break;
default:
break;
}
}
static void cleanup(void *data_to_free[2]) {
pa_context_unref(data_to_free[1]);
pa_mainloop_free(data_to_free[0]);
}
void pulse_listener_main(pthread_t *main_thread) {
pthread_setcanceltype(PTHREAD_CANCEL_DISABLE, NULL);
pa_mainloop *mainloop = pa_mainloop_new();
if (!mainloop) {
ERROR("could not create pulse mainloop\n");
return;
}
pa_mainloop_api *api = pa_mainloop_get_api(mainloop);
if (!api) {
ERROR("could not create pulse mainloop api\n");
return;
}
pa_context *context = pa_context_new(api, "dwmblocks-listener");
if (!context) {
ERROR("could not create pulse context\n");
return;
}
pa_context_set_state_callback(context,
(pa_context_notify_cb_t)&state_callback,
main_thread);
if (pa_context_connect(context, NULL, PA_CONTEXT_NOAUTOSPAWN, NULL) < 0) {
ERROR("could not connect to pulse\n");
return;
}
void *data_to_free[2] = { mainloop, context };
pthread_cleanup_push((void(*)(void *)) cleanup, data_to_free);
pthread_setcanceltype(PTHREAD_CANCEL_ENABLE, NULL);
pa_mainloop_run(mainloop, NULL);
pthread_cleanup_pop(1);
}

8
pulse-listener.h Normal file
View File

@ -0,0 +1,8 @@
#ifndef INCLUDED_PULSE_LISTENER_H
#define INCLUDED_PULSE_LISTENER_H
#include <pthread.h>
void pulse_listener_main(pthread_t *main_thread);
#endif

View File

@ -9,42 +9,37 @@ if [[ "$(uname)" = 'Linux' ]]; then
function is_adapted_connected { function is_adapted_connected {
let connected="$(cat /sys/class/power_supply/ADP1/online)" let connected="$(cat /sys/class/power_supply/ADP1/online)"
if ((${connected} == 1)); then ((${connected} == 1))
echo 'true'
else
echo 'false'
fi
} }
function get_battery_icon { function print_battery_icon {
let charge_percent="${1}" let charge_percent="${1}"
if "$(is_adapted_connected)"; then if ((${charge_percent} <= 10)); then
echo -n '' echo -n '󰂃'
elif ((${charge_percent} <= 10)); then
echo -n ''
elif ((${charge_percent} <= 20)); then elif ((${charge_percent} <= 20)); then
echo -n '' echo -n '󰁻'
elif ((${charge_percent} <= 30)); then elif ((${charge_percent} <= 30)); then
echo -n '' echo -n '󰁼'
elif ((${charge_percent} <= 40)); then elif ((${charge_percent} <= 40)); then
echo -n '' echo -n '󰁽'
elif ((${charge_percent} <= 50)); then elif ((${charge_percent} <= 50)); then
echo -n '' echo -n '󰁾'
elif ((${charge_percent} <= 60)); then elif ((${charge_percent} <= 60)); then
echo -n '' echo -n '󰁿'
elif ((${charge_percent} <= 70)); then elif ((${charge_percent} <= 70)); then
echo -n '' echo -n '󰂀'
elif ((${charge_percent} <= 80)); then elif ((${charge_percent} <= 80)); then
echo -n '' echo -n '󰂁'
elif ((${charge_percent} < 100)); then elif ((${charge_percent} < 100)); then
echo -n '' echo -n '󰂂'
else else
echo -n '' echo -n '󰁹'
fi fi
} }
let cp="$(get_battery_percent)" let cp="$(get_battery_percent)"
get_battery_icon "${cp}" print_battery_icon "${cp}"
is_adapted_connected && echo -n '󱐋'
printf '%3d%%\n' "${cp}" printf '%3d%%\n' "${cp}"
# Linux ends here # Linux ends here
else else

12
scripts/dwmblocks-fcitx5 Executable file
View File

@ -0,0 +1,12 @@
#!/usr/bin/env zsh
local ime_sym=''
case "$(fcitx5-remote -n)" in
'keyboard-us')
ime_sym=''
;;
'mozc')
ime_sym="和"
;;
esac
printf '󰌌 %s' "${ime_sym}"

3
scripts/dwmblocks-mu4e Executable file
View File

@ -0,0 +1,3 @@
#!/usr/bin/env zsh
let message_count="$(mu find flag:unread AND maildir:/protonmail/Inbox 2>/dev/null | wc -l)"
(( "${message_count}" > 0 )) && printf ' %s' "${message_count}"

View File

@ -3,11 +3,11 @@
if [[ "$(uname)" = 'Linux' ]]; then if [[ "$(uname)" = 'Linux' ]]; then
local active_networks="$(nmcli c s --active)" local active_networks="$(nmcli c s --active)"
local output='' local output=''
[[ "${active_networks}" = *' wifi '* ]] && output="${output} " [[ "${active_networks}" = *' wifi '* ]] && output="${output}󰖩 "
[[ "${active_networks}" = *' ethernet '* ]] && output="${output}" [[ "${active_networks}" = *' ethernet '* ]] && output="${output}󰈁"
[[ "${active_networks}" = *' wireguard '* ]] && output="${output} " [[ "${active_networks}" = *' wireguard '* ]] && output="${output}󰖂 "
(( ${#output} == 0 )) && output='' (( ${#output} == 0 )) && output='󰈂'
bluetoothctl show | grep 'Powered: yes' >/dev/null && output="${output} " bluetoothctl show | grep 'Powered: yes' >/dev/null && output="${output}  "
printf '%s\n' "${output}" printf '%s\n' "${output}"
else else
echo "${0}: error: unknown os: \"$(uname)\"" >&2 echo "${0}: error: unknown os: \"$(uname)\"" >&2

View File

@ -3,12 +3,12 @@
let volume="$(pamixer --get-volume)" let volume="$(pamixer --get-volume)"
local icon local icon
if [[ "$(pamixer --get-mute)" = "true" ]]; then if [[ "$(pamixer --get-mute)" = "true" ]]; then
icon='' icon='󰸈'
elif ((${volume} > 50)); then elif ((${volume} > 50)); then
icon='' icon='󰕾'
elif ((${volume} > 0)); then elif ((${volume} >= 0)); then
icon='奔' icon='󰖀'
else else
icon='' icon=''
fi fi
printf '%s%3d%%\n' "${icon}" "${volume}" printf '%s%3d%%\n' "${icon}" "${volume}"