1
0

spring cleaning 1

This commit is contained in:
dtb
2023-12-31 10:46:23 -07:00
parent ea31d1221c
commit f501a77764
116 changed files with 4712 additions and 8 deletions

21
Wip/bitch/Makefile Normal file
View File

@@ -0,0 +1,21 @@
CFLAGS = -g
RM = rm -f
SOURCE = bitch.c
TARGETS = bitch
all: $(TARGETS)
motif: $(SOURCE)
$(CC) $(CFLAGS) -o $@ \
-DMOTIF -I/usr/pkg/include/ -I/usr/X11R7/include/ \
-L/usr/pkg/lib/ -L/usr/X11R7/lib -lXm -lX11 \
$(SOURCE)
gtk4: $(SOURCE)
$(CC) $(CFLAGS) -o $@ \
-DGTK4 `pkg-config --cflags gtk4` `pkg-config --libs gtk4` \
$(SOURCE)
clean:
$(RM) $(TARGETS)
%: %.c
$(CC) -o $@ $(CFLAGS) $@.c
.PHONY: all clean

45
Wip/bitch/bitch.1 Normal file
View File

@@ -0,0 +1,45 @@
.TH BITCH 1
.SH NAME
bitch \(en a pretty interface from which to select tasks
.SH SYNOPSIS
bitch
.RB ( -rx )
.RB [ -h
.BR horizontal ]
.RB [ -v
.BR vertical ]
.SH GRAPHICS
Bitch is written for the GNU Image Manipulation Program's Graphical Toolkit 4.
A windowing system is required to use bitch.
.SH DESCRIPTION
Bitch reads a list of newline-delimited items from standard input and presents a menu with the options.
.PP
With the
.B -x
option, bitch will eXit when the first item is chosen, otherwise bitch will print or execute subsequent selections.
.PP
With the
.B -r
option, bitch will execute the selected item with system(3). Otherwise, bitch will print the selection text.
.PP
The window bitch presents will be of the horizontal and vertical resolution specified with
.B -h
and
.B -v
respectively.
.SH BUGS
He who calls bitches bitches gets no bitches.
.SH COPYRIGHT
Public domain.

208
Wip/bitch/bitch.c Normal file
View File

@@ -0,0 +1,208 @@
#include <stdio.h>
#include <stdlib.h> /* stderr, atoi(3) */
#include <string.h> /* strchr(3) */
#include <sysexits.h> /* EX_USAGE */
#include <unistd.h> /* getopt(3) */
#ifdef GTK4
# include <gtk/gtk.h>
#endif
#ifdef MOTIF
# include <Xm/Xm.h>
# include <Xm/PushB.h>
#endif
#define BUF 100
/* Pinephone dimensions as default */
static unsigned int h = 720;
static unsigned int v = 1440;
static char *argv0;
static char buf[BUF];
static char f;
static unsigned char shy = 0;
static int fake_argc = 1;
static char *fake_argv[2] = { NULL, NULL };
#ifdef GTK4
static GtkApplication *app;
static void activate(GtkApplication *app, gpointer user_data);
static void button_pressed(GtkWidget *button, gpointer data);
#endif
#ifdef MOTIF
static XtAppContext app_context;
static void activate(void);
static void button_pressed(
Widget w, XtPointer client_data, XmPushButtonCallbackStruct *cbs
);
#endif
int main(int argc, char *argv[]){
int c;
extern char *optarg;
int status;
argv0 = argv[0];
fake_argv[0] = argv0;
f = 'x';
while((c = getopt(argc, argv, "h:v:wx")) != -1)
switch(c){
case 'h':
h = atoi(optarg);
break;
case 'w':
f = 'w';
break;
case 'v':
v = atoi(optarg);
break;
case 'x':
shy = 1;
break;
default: usage:
fprintf(stderr, "\
Usage: %s (-rx)\n\
\t(-h [horizontal resolution]) (-v [vertical resolution])\n",
argv0
);
return EX_USAGE;
}
#ifdef GTK4
app = gtk_application_new(
"org.trinity.femaledog", G_APPLICATION_FLAGS_NONE
);
g_signal_connect(app, "activate", G_CALLBACK(activate), NULL);
status = g_application_run(G_APPLICATION(app), 1, fake_argv);
g_object_unref(app);
#endif
#ifdef MOTIF
activate();
#endif
return status;
}
char *
sip(void){
int c;
char *s;
if(fgets(buf, sizeof(buf) / sizeof(*buf), stdin) == NULL){
if(ferror(stdin) != 0)
#ifdef GTK4
g_print
#else
printf
#endif
("%s: stdin: file read error\n", argv0);
return NULL;
}
if((s = strchr(buf, '\n')) == NULL) /* flush */
while((c = getc(stdin)) != '\n' && c != EOF);
else
*s = '\0';
return buf;
}
#ifdef GTK4
static void
activate(GtkApplication *app, gpointer user_data){
GtkWidget *box;
GtkWidget *button;
int c;
char *s;
GtkWidget *scrolledwindow;
GtkWidget *window;
window = gtk_application_window_new(app);
gtk_window_set_title(GTK_WINDOW(window), "Bitch");
gtk_window_set_default_size(GTK_WINDOW(window), h, v);
scrolledwindow = gtk_scrolled_window_new();
gtk_scrolled_window_set_overlay_scrolling(GTK_SCROLLED_WINDOW(scrolledwindow), 1);
gtk_window_set_child(GTK_WINDOW(window), scrolledwindow);
box = gtk_list_box_new();
//gtk_widget_set_halign(box, GTK_ALIGN_CENTER);
//gtk_widget_set_valign(box, GTK_ALIGN_CENTER);
gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(scrolledwindow), box);
for(;;){
if(sip() == NULL)
break;
button = gtk_button_new_with_label(buf);
g_signal_connect(
button, "clicked", G_CALLBACK(button_pressed), NULL
);
gtk_list_box_insert(GTK_LIST_BOX(box), button, -1);
}
gtk_window_present(GTK_WINDOW(window));
return;
}
static void
button_pressed(GtkWidget *button, gpointer data){
switch(f){
case 'w':
g_print("%s\n", gtk_button_get_label(GTK_BUTTON(button)));
break;
case 'x':
system(gtk_button_get_label(GTK_BUTTON(button)));
break;
}
if(shy)
g_application_quit(G_APPLICATION(app));
return;
}
#endif /* ifdef GTK4 */
#ifdef MOTIF
static void
activate(void){
Widget button;
Widget top_wid;
top_wid = XtVaAppInitialize(
&app_context, "Bitch", NULL, 0, &fake_argc, fake_argv, NULL,
NULL
);
for(;;){
if(sip() == NULL)
break;
button = XmCreatePushButton(top_wid, buf, NULL, 0);
XtManageChild(button);
XtAddCallback(button, XmNactivateCallback, button_pressed, NULL);
}
XtRealizeWidget(top_wid);
XtAppMainLoop(app_context);
}
static void
button_pressed(
Widget w,
XtPointer client_data,
XmPushButtonCallbackStruct *cbs
){
printf("pressed\n");
if(shy)
XtAppSetExitFlag(app_context);
}
#endif

7
Wip/bitch/bitch_please Executable file
View File

@@ -0,0 +1,7 @@
#!/bin/sh
set -ex
$(for folder in $(printf "%s\n" "$PATH" | tr ':' '\n');
do ls $folder
done | sort | $(command -v bitch))