From f2a118c380a13ac6dc04f1a4cda9532a2367c96f Mon Sep 17 00:00:00 2001 From: Armaan Bhojwani Date: Mon, 10 May 2021 21:47:34 -0400 Subject: [PATCH 1/1] Initial commit --- .gitignore | 2 ++ LICENSE | 19 +++++++++++++++++++ Makefile | 13 +++++++++++++ README | 6 ++++++ momen.1.scd | 10 ++++++++++ momen.c | 36 ++++++++++++++++++++++++++++++++++++ 6 files changed, 86 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 Makefile create mode 100644 README create mode 100644 momen.1.scd create mode 100644 momen.c diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..47f42b0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +momen +momen.1 diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..f3fa714 --- /dev/null +++ b/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2021 Armaan Bhojwani + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..abce05d --- /dev/null +++ b/Makefile @@ -0,0 +1,13 @@ +all: + ${CC} momen.c -o momen -lXm -lXt -lcurl ${LDFLAGS} -std=c99 ${CFLAGS} -Wall \ + -Wextra -pedantic + scdoc < momen.1.scd > momen.1 + +install: + mkdir -p /usr/local/bin /usr/local/man + cp momen /usr/local/bin/momen + cp momen.1 /usr/local/man/man1/momen.1 + +uninstall: + rm /usr/local/bin/momen + rm /usr/local/man/man1/momen.1 diff --git a/README b/README new file mode 100644 index 0000000..d4a67dd --- /dev/null +++ b/README @@ -0,0 +1,6 @@ +momen +----- + +A dmenu replacement in motif. + +MIT License Armaan Bhojwani 2021. diff --git a/momen.1.scd b/momen.1.scd new file mode 100644 index 0000000..ab8e86e --- /dev/null +++ b/momen.1.scd @@ -0,0 +1,10 @@ +momen(1) + +# NAME +momen - program runner + +# SYNOPSIS +*momen* + +# LICENSE +MIT License, Armaan Bhojwani 2021. diff --git a/momen.c b/momen.c new file mode 100644 index 0000000..3798701 --- /dev/null +++ b/momen.c @@ -0,0 +1,36 @@ +#include +#include +#include + +void +execute(Widget text_w, XtPointer client_data, XtPointer call_data) +{ + // Discard unused parameters + (void)client_data; + (void)call_data; + + char *value = XmTextGetString(text_w); + char *valuep = (char *) calloc(strlen(value) + 2, sizeof(char)); + sprintf(valuep, "%s &", value); + printf("Launching %s\n", valuep); + system(valuep); + XtFree(value); + free(valuep); + exit(0); +} + +int +main(int argc, char *argv[]) +{ + Widget toplevel, text_w; + XtAppContext app; + + XtSetLanguageProc(NULL, NULL, NULL); + toplevel = XtVaOpenApplication(&app, "momen", NULL, 0, &argc, argv, NULL, + sessionShellWidgetClass, NULL); + text_w = XmCreateText(toplevel, "text", NULL, 0); + XtManageChild(text_w); + XtAddCallback(text_w, XmNactivateCallback, execute, NULL); + XtRealizeWidget(toplevel); + XtAppMainLoop(app); +} -- 2.39.2