Compare commits

...

3 Commits

Author SHA1 Message Date
stupidcomputer 011925061d make statusbar program accept notifications 2024-04-15 21:49:28 -05:00
stupidcomputer 275fa01164 add a new module to the statusbar
make it such that notifications can occur. that is, write to
~/.cache/statusbar_notification, and things appear on the bar. pretty
cool right?
2024-04-15 19:34:16 -05:00
stupidcomputer 405fed6955 add a password menu 2024-04-15 19:33:35 -05:00
7 changed files with 61 additions and 10 deletions

View File

@ -35,6 +35,10 @@ super + e
super + shift + e super + shift + e
systemctl suspend systemctl suspend
# password menu
super + z
passmenu
# manipulate a node # manipulate a node
super + {_,ctrl +,shift + }{h,j,k,l} super + {_,ctrl +,shift + }{h,j,k,l}
bspc node -{f,p,s} {west,south,north,east} bspc node -{f,p,s} {west,south,north,east}

View File

@ -19,6 +19,8 @@
, xrandr , xrandr
, svkbd , svkbd
, xkbset , xkbset
, rbw
, xclip
, libsForQt5 , libsForQt5
}: }:
@ -29,7 +31,7 @@ stdenv.mkDerivation rec {
src = ./utils; src = ./utils;
nativeBuildInputs = [ makeWrapper pkg-config libxcb ]; nativeBuildInputs = [ makeWrapper pkg-config libxcb ];
buildInputs = [ libxcb bash feh xrandr jq curl fzy ytfzf ffmpeg sshuttle svkbd scrcpy xkbset libsForQt5.kolourpaint ]; buildInputs = [ libxcb bash feh xrandr jq curl fzy ytfzf ffmpeg sshuttle svkbd scrcpy xkbset rbw xclip libsForQt5.kolourpaint ];
buildPhase = '' buildPhase = ''
ls ls

View File

@ -1,6 +1,6 @@
LDFLAGS=`pkg-config --cflags --libs xcb` LDFLAGS=`pkg-config --cflags --libs xcb`
CFLAGS=-ggdb -fsanitize=address CFLAGS=-ggdb -fsanitize=address
main: battery.o bspwm.o time.o battstatus.o main: battery.o bspwm.o time.o battstatus.o message.o
clean: clean:
rm *.o main rm *.o main

View File

@ -17,12 +17,14 @@
#include "battstatus.h" #include "battstatus.h"
#include "bspwm.h" #include "bspwm.h"
#include "time.h" #include "time.h"
#include "message.h"
struct module mods[] = { struct module mods[] = {
{mod_battery, "battery", "BAT0", { '\0' }}, {mod_battery, "battery", "BAT0", { '\0' }},
{mod_battstatus, "battstatus", "BAT0", { '\0' }}, {mod_battstatus, "battstatus", "BAT0", { '\0' }},
{mod_time, "time", "", { '\0' }}, {mod_time, "time", "", { '\0' }},
{mod_bspwm, "bspwm", "", { '\0' }}, {mod_bspwm, "bspwm", "", { '\0' }},
/* {mod_message, "message", "/home/usr/.cache/statusbar_notification", { '\0' }}, */
}; };
void create_module_proc(int index, char *pipename) { void create_module_proc(int index, char *pipename) {
@ -59,17 +61,12 @@ void redraw() {
static char NAMED_PIPE[] = "/home/usr/.cache/statusbar_pipe"; static char NAMED_PIPE[] = "/home/usr/.cache/statusbar_pipe";
int main(void) { int main(void) {
char pipename[BUFFER_SIZE];
srand(time(NULL)); srand(time(NULL));
strcpy(pipename, &NAMED_PIPE); mkfifo(&NAMED_PIPE, 0666); /* it's okay if this fails */
pipename[sizeof(NAMED_PIPE) - 1] = 'A' + (rand() % 26); int fd = open(&NAMED_PIPE, O_RDWR);
pipename[sizeof(NAMED_PIPE)] = 'A' + (rand() % 26);
pipename[sizeof(NAMED_PIPE) + 1] = '\0';
mkfifo(pipename, 0666);
int fd = open(pipename, O_RDWR);
struct message msg; struct message msg;
create_module_procs(pipename); create_module_procs(&NAMED_PIPE);
for (;;) { for (;;) {
int ret = read(fd, &msg, sizeof(msg)); int ret = read(fd, &msg, sizeof(msg));

View File

@ -0,0 +1,35 @@
#include <unistd.h>
#include <stdio.h>
#include <fcntl.h>
#include <string.h>
#include <sys/inotify.h>
#include "message.h"
#include "common.h"
int mod_message(char *config, char *name, char *pipename) {
struct message msg;
struct inotify_event buf;
strcpy(msg.name, name);
int fd = inotify_init();
int outfd = open(pipename, O_WRONLY);
for(;;) {
int watchdesc = inotify_add_watch(fd, config, IN_MODIFY);
read:
int watchread = read(fd, &buf, sizeof(struct inotify_event));
/* the file's changed, so reread it */
int filefd = open(config, O_RDONLY, 0);
int read_in = read(filefd, msg.content, sizeof(msg.content));
msg.content[read_in - 1] = '\0';
close(filefd);
/* write the new */
write(outfd, &msg, sizeof(msg));
inotify_rm_watch(fd, watchdesc); /* not sure why this is needed */
}
return 0;
}

View File

@ -0,0 +1,6 @@
#ifndef STATUS_MESSAGE_H
#define STATUS_MESSAGE_H
int mod_message(char *config, char *name, char *pipename);
#endif

7
builds/utils/sh/passmenu Executable file
View File

@ -0,0 +1,7 @@
# wrapper around rbw
resp=$(rbw list | tmenu)
rbw get "$resp" | xclip -selection clipboard
sleep 15
echo "cleared" | xclip -selection clipboard