From e58dcfbcd127e00bec22141387037bc58ce8bec8 Mon Sep 17 00:00:00 2001 From: stkhan Date: Mon, 27 Mar 2023 20:57:44 -0500 Subject: init --- wm/dwmblocks/LICENSE | 7 -- wm/dwmblocks/Makefile | 37 ------- wm/dwmblocks/README.md | 15 --- wm/dwmblocks/blocks.def.h | 11 -- wm/dwmblocks/blocks.h | 15 --- wm/dwmblocks/dwmblocks-battery | 21 ---- wm/dwmblocks/dwmblocks-brightness | 6 -- wm/dwmblocks/dwmblocks-du | 5 - wm/dwmblocks/dwmblocks-forecast | 18 ---- wm/dwmblocks/dwmblocks-mpc | 6 -- wm/dwmblocks/dwmblocks-volume | 13 --- wm/dwmblocks/dwmblocks.c | 213 -------------------------------------- 12 files changed, 367 deletions(-) delete mode 100644 wm/dwmblocks/LICENSE delete mode 100644 wm/dwmblocks/Makefile delete mode 100644 wm/dwmblocks/README.md delete mode 100644 wm/dwmblocks/blocks.def.h delete mode 100644 wm/dwmblocks/blocks.h delete mode 100755 wm/dwmblocks/dwmblocks-battery delete mode 100755 wm/dwmblocks/dwmblocks-brightness delete mode 100755 wm/dwmblocks/dwmblocks-du delete mode 100755 wm/dwmblocks/dwmblocks-forecast delete mode 100755 wm/dwmblocks/dwmblocks-mpc delete mode 100755 wm/dwmblocks/dwmblocks-volume delete mode 100644 wm/dwmblocks/dwmblocks.c (limited to 'wm/dwmblocks') diff --git a/wm/dwmblocks/LICENSE b/wm/dwmblocks/LICENSE deleted file mode 100644 index 3ec2656..0000000 --- a/wm/dwmblocks/LICENSE +++ /dev/null @@ -1,7 +0,0 @@ -ISC License (ISC) - -Copyright 2020 torrinfail - -Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/wm/dwmblocks/Makefile b/wm/dwmblocks/Makefile deleted file mode 100644 index 21d9bce..0000000 --- a/wm/dwmblocks/Makefile +++ /dev/null @@ -1,37 +0,0 @@ -PREFIX := /usr/local -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 - -options: - @echo dwmblocks build options: - @echo "CFLAGS = ${CFLAGS}" - @echo "LDFLAGS = ${LDFLAGS}" - @echo "CC = ${CC}" - -dwmblocks: dwmblocks.c blocks.def.h blocks.h - ${CC} -o dwmblocks dwmblocks.c ${CFLAGS} ${LDFLAGS} - -blocks.h: - cp blocks.def.h $@ - -clean: - rm -f *.o *.gch dwmblocks - -install: dwmblocks - mkdir -p ${DESTDIR}${PREFIX}/bin - cp -f dwmblocks ${DESTDIR}${PREFIX}/bin - cp -f dwmblocks-* ${DESTDIR}${PREFIX}/bin - chmod 755 ${DESTDIR}${PREFIX}/bin/dwmblocks - -uninstall: - rm -f ${DESTDIR}${PREFIX}/bin/dwmblocks - -.PHONY: all options clean install uninstall diff --git a/wm/dwmblocks/README.md b/wm/dwmblocks/README.md deleted file mode 100644 index dda2259..0000000 --- a/wm/dwmblocks/README.md +++ /dev/null @@ -1,15 +0,0 @@ -# dwmblocks -Modular status bar for dwm written in c. -# usage -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. -# modifying blocks -The statusbar is made from text output from commandline programs. -Blocks are added and removed by editing the blocks.h header file. -By default the blocks.h header file is created the first time you run make which copies the default 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. -# patches -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. -I do not maintain these but I will take pull requests to update them. -
-dwmblocks-statuscmd-b6b0be4.diff diff --git a/wm/dwmblocks/blocks.def.h b/wm/dwmblocks/blocks.def.h deleted file mode 100644 index 9c22d68..0000000 --- a/wm/dwmblocks/blocks.def.h +++ /dev/null @@ -1,11 +0,0 @@ -//Modify this file to change what commands output to your statusbar, and recompile using the make command. -static const Block blocks[] = { - /*Icon*/ /*Command*/ /*Update Interval*/ /*Update Signal*/ - {"Mem:", "free -h | awk '/^Mem/ { print $3\"/\"$2 }' | sed s/i//g", 30, 0}, - - {"", "date '+%b %d (%a) %I:%M%p'", 5, 0}, -}; - -//sets delimeter between status commands. NULL character ('\0') means no delimeter. -static char delim[] = " | "; -static unsigned int delimLen = 5; diff --git a/wm/dwmblocks/blocks.h b/wm/dwmblocks/blocks.h deleted file mode 100644 index 2b7566c..0000000 --- a/wm/dwmblocks/blocks.h +++ /dev/null @@ -1,15 +0,0 @@ -//Modify this file to change what commands output to your statusbar, and recompile using the make command. -static const Block blocks[] = { - - /*Icon*/ /*Command*/ /*Update Interval*/ /*Update Signal*/ - {"", "dwmblocks-mpc", 2, 2}, - {"", "dwmblocks-du", 60, 0}, - {"", "dwmblocks-volume", 0, 10}, - {"", "dwmblocks-battery", 1, 0}, - {"🕗 ", "date '+%k:%M'", 1, 0}, - {"📅 ", "date '+%A, %B %d %G'", 1, 0}, -}; - -//sets delimeter between status commands. NULL character ('\0') means no delimeter. -static char delim[] = " | "; -static unsigned int delimLen = 5; diff --git a/wm/dwmblocks/dwmblocks-battery b/wm/dwmblocks/dwmblocks-battery deleted file mode 100755 index 66f1d1f..0000000 --- a/wm/dwmblocks/dwmblocks-battery +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh - -BAT_FILE=/sys/class/power_supply/BAT0 - -for battery in $BAT_FILE; do - # If non-first battery, print a space separator. - [ -n "${capacity+x}" ] && printf " " - # Sets up the status and capacity - case "$(cat "$battery/status" 2>&1)" in - "Full") status="🔋" ;; - "Discharging") status="🔋-" ;; - "Charging") status="🔋+" ;; - "Not charging") status="🛑" ;; - *) exit 1 ;; - esac - capacity="$(cat "$battery/capacity" 2>&1)" - # Will make a warn variable if discharging and low - [ "$status" = "🔋" ] && [ "$capacity" -le 25 ] && warn="❗" - # Prints the info - printf "%s%s%d%%" "$status " "$warn" " $capacity"; unset warn -done && printf "\\n" diff --git a/wm/dwmblocks/dwmblocks-brightness b/wm/dwmblocks/dwmblocks-brightness deleted file mode 100755 index 420518d..0000000 --- a/wm/dwmblocks/dwmblocks-brightness +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -CMD=$(light | sed 's/...$//') -ICON=💡 - -echo "$ICON $CMD%" diff --git a/wm/dwmblocks/dwmblocks-du b/wm/dwmblocks/dwmblocks-du deleted file mode 100755 index ed5f791..0000000 --- a/wm/dwmblocks/dwmblocks-du +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh -icon='💾' -cmd=$(df -h --output='pcent' /home | sed 1g | tr -d '\n ') - -echo $icon $cmd diff --git a/wm/dwmblocks/dwmblocks-forecast b/wm/dwmblocks/dwmblocks-forecast deleted file mode 100755 index 3c2482e..0000000 --- a/wm/dwmblocks/dwmblocks-forecast +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh - -weatherreport="$HOME/.cache/dwmblocks_forecast" -getforecast() { curl -sf "wttr.in/" > "$weatherreport" || exit 1 ;} - -# Some very particular and terse stream manipulation. We get the maximum -# precipitation chance and the daily high and low from the downloaded file and -# display them with coresponding emojis. -showweather() { printf "%s" "$(sed '16q;d' "$weatherreport" | - grep -wo "[0-9]*%" | sort -rn | sed "s/^/☔ /g;1q" | tr -d '\n')" -sed '13q;d' "$weatherreport" | grep -o "m\\([-+]\\)*[0-9]\\+" | sed 's/+//g' | sort -n -t 'm' -k 2n | sed -e 1b -e '$!d' | tr '\n|m' ' ' | awk '{print " 🥶 " $1 "°","🌞 " $2 "°"}' ;} - -# The test if our forcecast is updated to the day. If it isn't download a new -# weather report from wttr.in with the above function. -[ "$(stat -c %y "$weatherreport" 2>/dev/null | cut -d' ' -f1)" = "$(date '+%Y-%m-%d')" ] || - getforecast - -showweather diff --git a/wm/dwmblocks/dwmblocks-mpc b/wm/dwmblocks/dwmblocks-mpc deleted file mode 100755 index c468ec8..0000000 --- a/wm/dwmblocks/dwmblocks-mpc +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -SONG=$(mpc --format "%title% - %artist%" | mpc --format "%title% - %artist%" | sed "/^volume:/d;s/\\&/&/g;s/\\[paused\\].*/⏸/g;/\\[playing\\].*/d;/^ERROR/Q" | sed 1q;) -ICON="🎵" - -echo "$ICON $SONG" diff --git a/wm/dwmblocks/dwmblocks-volume b/wm/dwmblocks/dwmblocks-volume deleted file mode 100755 index 048fa04..0000000 --- a/wm/dwmblocks/dwmblocks-volume +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh - -case $BLOCK_BUTTON in - 4) pamixer --allow-boost -i 1;; - 5) pamixer --allow-boost -d 1;; -esac -ICON="🔉" -VOL=$(pamixer --get-volume) - -if [ $(pamixer --get-mute) = 'true' ]; then - ICON="🔇" -fi -echo "$ICON $VOL%" diff --git a/wm/dwmblocks/dwmblocks.c b/wm/dwmblocks/dwmblocks.c deleted file mode 100644 index 62c481c..0000000 --- a/wm/dwmblocks/dwmblocks.c +++ /dev/null @@ -1,213 +0,0 @@ -#include -#include -#include -#include -#include -#ifndef NO_X -#include -#endif -#ifdef __OpenBSD__ -#define SIGPLUS SIGUSR1+1 -#define SIGMINUS SIGUSR1-1 -#else -#define SIGPLUS SIGRTMIN -#define SIGMINUS SIGRTMIN -#endif -#define LENGTH(X) (sizeof(X) / sizeof (X[0])) -#define CMDLENGTH 75 -#define MIN( a, b ) ( ( a < b) ? a : b ) -#define STATUSLENGTH (LENGTH(blocks) * CMDLENGTH + 1) - -typedef struct { - char* icon; - char* command; - unsigned int interval; - unsigned int signal; -} Block; -#ifndef __OpenBSD__ -void dummysighandler(int num); -#endif -void sighandler(int num); -void getcmds(int time); -void getsigcmds(unsigned int signal); -void setupsignals(); -void sighandler(int signum); -int getstatus(char *str, char *last); -void statusloop(); -void termhandler(); -void pstdout(); -#ifndef NO_X -void setroot(); -static void (*writestatus) () = setroot; -static int setupX(); -static Display *dpy; -static int screen; -static Window root; -#else -static void (*writestatus) () = pstdout; -#endif - - -#include "blocks.h" - -static char statusbar[LENGTH(blocks)][CMDLENGTH] = {0}; -static char statusstr[2][STATUSLENGTH]; -static int statusContinue = 1; -static int returnStatus = 0; - -//opens process *cmd and stores output in *output -void getcmd(const Block *block, char *output) -{ - strcpy(output, block->icon); - FILE *cmdf = popen(block->command, "r"); - if (!cmdf) - return; - int i = strlen(block->icon); - fgets(output+i, CMDLENGTH-i-delimLen, cmdf); - i = strlen(output); - if (i == 0) { - //return if block and command output are both empty - pclose(cmdf); - return; - } - //only chop off newline if one is present at the end - i = output[i-1] == '\n' ? i-1 : i; - if (delim[0] != '\0') { - strncpy(output+i, delim, delimLen); - } - else - output[i++] = '\0'; - pclose(cmdf); -} - -void getcmds(int time) -{ - const Block* current; - for (unsigned int i = 0; i < LENGTH(blocks); i++) { - current = blocks + i; - if ((current->interval != 0 && time % current->interval == 0) || time == -1) - getcmd(current,statusbar[i]); - } -} - -void getsigcmds(unsigned int signal) -{ - const Block *current; - for (unsigned int i = 0; i < LENGTH(blocks); i++) { - current = blocks + i; - if (current->signal == signal) - getcmd(current,statusbar[i]); - } -} - -void setupsignals() -{ -#ifndef __OpenBSD__ - /* initialize all real time signals with dummy handler */ - for (int i = SIGRTMIN; i <= SIGRTMAX; i++) - signal(i, dummysighandler); -#endif - - for (unsigned int i = 0; i < LENGTH(blocks); i++) { - if (blocks[i].signal > 0) - signal(SIGMINUS+blocks[i].signal, sighandler); - } - -} - -int getstatus(char *str, char *last) -{ - strcpy(last, str); - str[0] = '\0'; - for (unsigned int i = 0; i < LENGTH(blocks); i++) - strcat(str, statusbar[i]); - str[strlen(str)-strlen(delim)] = '\0'; - return strcmp(str, last);//0 if they are the same -} - -#ifndef NO_X -void setroot() -{ - if (!getstatus(statusstr[0], statusstr[1]))//Only set root if text has changed. - return; - XStoreName(dpy, root, statusstr[0]); - XFlush(dpy); -} - -int setupX() -{ - dpy = XOpenDisplay(NULL); - if (!dpy) { - fprintf(stderr, "dwmblocks: Failed to open display\n"); - return 0; - } - screen = DefaultScreen(dpy); - root = RootWindow(dpy, screen); - return 1; -} -#endif - -void pstdout() -{ - if (!getstatus(statusstr[0], statusstr[1]))//Only write out if text has changed. - return; - printf("%s\n",statusstr[0]); - fflush(stdout); -} - - -void statusloop() -{ - setupsignals(); - int i = 0; - getcmds(-1); - while (1) { - getcmds(i++); - writestatus(); - if (!statusContinue) - break; - sleep(1.0); - } -} - -#ifndef __OpenBSD__ -/* this signal handler should do nothing */ -void dummysighandler(int signum) -{ - return; -} -#endif - -void sighandler(int signum) -{ - getsigcmds(signum-SIGPLUS); - writestatus(); -} - -void termhandler() -{ - statusContinue = 0; -} - -int main(int argc, char** argv) -{ - for (int i = 0; i < argc; i++) {//Handle command line arguments - if (!strcmp("-d",argv[i])) - strncpy(delim, argv[++i], delimLen); - else if (!strcmp("-p",argv[i])) - writestatus = pstdout; - } -#ifndef NO_X - if (!setupX()) - return 1; -#endif - delimLen = MIN(delimLen, strlen(delim)); - delim[delimLen++] = '\0'; - signal(SIGTERM, termhandler); - signal(SIGINT, termhandler); - statusloop(); -#ifndef NO_X - XCloseDisplay(dpy); -#endif - return 0; -} -- cgit v1.2.3