Skip to content

Instantly share code, notes, and snippets.

@p4p1
Created May 30, 2020 15:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save p4p1/0b900a284f60efd3dde9508550a123f1 to your computer and use it in GitHub Desktop.
Save p4p1/0b900a284f60efd3dde9508550a123f1 to your computer and use it in GitHub Desktop.
📡📡📡📡
/* diff file for startup commands in dwm */
diff -up a/config.def.h b/config.def.h
--- a/config.def.h 2019-02-02 13:55:28.000000000 +0100
+++ b/config.def.h 2020-05-30 17:23:39.085114250 +0200
@@ -18,6 +18,16 @@ static const char *colors[][3] = {
[SchemeSel] = { col_gray4, col_cyan, col_cyan },
};
+/* Run things on startup */
+static unsigned int child_pid = 0;
+static const char *(stup_prgs[5][4]) = { // [Number_programs][Number_args]
+ /* prog path arg1 arg2 arg... */
+ { "setxkbmap", "-option", "caps:escape", NULL },
+ { NULL, NULL, NULL, NULL }
+};
+
+#include "startup.c"
+
/* tagging */
static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
diff -up a/startup.c b/startup.c
--- a/startup.c 2020-05-30 17:25:55.234452034 +0200
+++ b/startup.c 2020-05-30 17:21:46.954895476 +0200
@@ -0,0 +1,33 @@
+void
+runStartupCommand(int pos)
+{
+ unsigned int id = 0;
+
+ if ((id = fork()) < 0)
+ exit(EXIT_FAILURE);
+ if (id == 0) {
+ if (execvp(stup_prgs[pos][0], (char **)stup_prgs[pos]) < 0) {
+ fprintf(stderr, "Command: %s failed\n", stup_prgs[pos][0]);
+ exit(-1);
+ }
+ exit(0);
+ }
+}
+
+void
+startup(void)
+{
+ unsigned int id = 0;
+
+ if ((id = fork()) < 0)
+ exit(EXIT_FAILURE);
+ if (id == 0) {
+ /* Child process in wich we will do the Autostart commands */
+ for (int i = 0; stup_prgs[i][0] != NULL; i++) {
+ runStartupCommand(i);
+ }
+ exit(0);
+ } else {
+ child_pid = id;
+ }
+}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment