]> git.armaanb.net Git - momen.git/commitdiff
Initial commit main
authorArmaan Bhojwani <me@armaanb.net>
Tue, 11 May 2021 01:47:34 +0000 (21:47 -0400)
committerArmaan Bhojwani <me@armaanb.net>
Tue, 11 May 2021 01:47:34 +0000 (21:47 -0400)
.gitignore [new file with mode: 0644]
LICENSE [new file with mode: 0644]
Makefile [new file with mode: 0644]
README [new file with mode: 0644]
momen.1.scd [new file with mode: 0644]
momen.c [new file with mode: 0644]

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..47f42b0
--- /dev/null
@@ -0,0 +1,2 @@
+momen
+momen.1
diff --git a/LICENSE b/LICENSE
new file mode 100644 (file)
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 (file)
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 (file)
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 (file)
index 0000000..ab8e86e
--- /dev/null
@@ -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 (file)
index 0000000..3798701
--- /dev/null
+++ b/momen.c
@@ -0,0 +1,36 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <Xm/Text.h>
+
+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);
+}