]> git.sur5r.net Git - i3/i3/commitdiff
Implement restart-command to restart i3 without having to end your session
authorMichael Stapelberg <michael+git@stapelberg.de>
Fri, 27 Feb 2009 21:40:48 +0000 (22:40 +0100)
committerMichael Stapelberg <michael+git@stapelberg.de>
Fri, 27 Feb 2009 21:40:48 +0000 (22:40 +0100)
include/i3.h
src/commands.c
src/mainx.c

index 9acf2c6584ac8dc7d3793a6067840b5eab64e0f7..41ccbf6bb72960b26c7250d3bf776a774e39849a 100644 (file)
@@ -20,6 +20,7 @@
 
 #define NUM_ATOMS 9
 
+extern char *application_path;
 extern Display *xkbdpy;
 extern TAILQ_HEAD(bindings_head, Binding) bindings;
 extern SLIST_HEAD(stack_wins_head, Stack_Window) stack_wins;
index 38ce6ef14de58a52e2ee8363e82c6af01fc0756c..0871baf8fb527ded6d0e2ba0ad84925eee9a95a4 100644 (file)
@@ -347,6 +347,13 @@ void parse_command(xcb_connection_t *conn, const char *command) {
                 return;
         }
 
+        /* Is it <restart>? */
+        if (strncmp(command, "restart", strlen("restart")) == 0) {
+                printf("restarting \"%s\"...\n", application_path);
+                execl(application_path, application_path, NULL);
+                /* not reached */
+        }
+
         /* Is it 'f' for fullscreen? */
         if (command[0] == 'f') {
                 if (CUR_CELL->currently_focused == NULL)
index ef431220a2e4e175c08f1ff2b4d4204f4056507c..84150e780b068f31bfe57c11aa3b8ea5c9cb0ea4 100644 (file)
@@ -44,6 +44,9 @@
 #include "xinerama.h"
 #include "i3.h"
 
+/* This is the path to i3, copied from argv[0] when starting up */
+char *application_path;
+
 /* This is our connection to X11 for use with XKB */
 Display *xkbdpy;
 
@@ -279,6 +282,8 @@ int main(int argc, char *argv[], char *env[]) {
         xcb_window_t root;
         xcb_intern_atom_cookie_t atom_cookies[NUM_ATOMS];
 
+        application_path = sstrdup(argv[0]);
+
         /* Initialize the table data structures for each workspace */
         init_table();