]> git.lizzy.rs Git - bspwm.git/commitdiff
Pass a *run level* argument to `bspwmrc`
authorBastien Dejean <nihilhill@gmail.com>
Mon, 27 Jul 2020 16:36:08 +0000 (18:36 +0200)
committerBastien Dejean <nihilhill@gmail.com>
Mon, 27 Jul 2020 16:36:08 +0000 (18:36 +0200)
Fixes #1158.

doc/bspwm.1
doc/bspwm.1.asciidoc
src/bspwm.c
src/settings.c
src/settings.h

index 65ed6f00444bb2a3e840c18643418a25be3506fa..9c3e99fa29b55f7636317ffab111778bf00b1642 100644 (file)
@@ -2,12 +2,12 @@
 .\"     Title: bspwm
 .\"    Author: [see the "Author" section]
 .\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
-.\"      Date: 07/26/2020
+.\"      Date: 07/27/2020
 .\"    Manual: Bspwm Manual
-.\"    Source: Bspwm 0.9.9-16-g1506582
+.\"    Source: Bspwm 0.9.9-25-g8f41d79
 .\"  Language: English
 .\"
-.TH "BSPWM" "1" "07/26/2020" "Bspwm 0\&.9\&.9\-16\-g1506582" "Bspwm Manual"
+.TH "BSPWM" "1" "07/27/2020" "Bspwm 0\&.9\&.9\-25\-g8f41d79" "Bspwm Manual"
 .\" -----------------------------------------------------------------
 .\" * Define some portability stuff
 .\" -----------------------------------------------------------------
@@ -1601,6 +1601,11 @@ State of the focused node of a focused desktop\&.
 .RS 4
 Active flags of the focused node of a focused desktop\&.
 .RE
+.SH "CONFIGURATION FILE"
+.sp
+Its default path is \fI$XDG_CONFIG_HOME/bspwm/bspwmrc\fR\&.
+.sp
+An argument is passed to this script: the run level, a number which indicates whether it was launched after a restart (cf\&. \fIwm \-r\fR) or not\&.
 .SH "ENVIRONMENT VARIABLES"
 .PP
 \fIBSPWM_SOCKET\fR
index a120d277084ce87d04df922f5d5b5b48286e8e35..0923f94a4798971a1ed0ef530812bf7701806487 100644 (file)
@@ -944,6 +944,13 @@ Each item has the form '<type><value>' where '<type>' is the first character of
 'G(S?P?L?M?)'::
        Active flags of the focused node of a focused desktop.
 
+Configuration file
+------------------
+
+Its default path is '$XDG_CONFIG_HOME/bspwm/bspwmrc'.
+
+An argument is passed to this script: the run level, a number which indicates whether it was launched after a restart (cf. 'wm -r') or not.
+
 Environment Variables
 ---------------------
 
index d70a35af9b023d5f2f7df93f77ecbc883974913d..dca03fdea238a2975da5239830882564eec0a69c 100644 (file)
@@ -94,6 +94,7 @@ int main(int argc, char *argv[])
        fd_set descriptors;
        char socket_path[MAXLEN];
        char state_path[MAXLEN] = {0};
+       int run_level = 0;
        config_path[0] = '\0';
        int sock_fd = -1, cli_fd, dpy_fd, max_fd, n;
        struct sockaddr_un sock_address;
@@ -116,9 +117,11 @@ int main(int argc, char *argv[])
                                snprintf(config_path, sizeof(config_path), "%s", optarg);
                                break;
                        case 's':
+                               run_level |= 1;
                                snprintf(state_path, sizeof(state_path), "%s", optarg);
                                break;
                        case 'o':
+                               run_level |= 2;
                                sock_fd = strtol(optarg, &end, 0);
                                if (*end != '\0') {
                                        sock_fd = -1;
@@ -192,7 +195,7 @@ int main(int argc, char *argv[])
        signal(SIGTERM, sig_handler);
        signal(SIGCHLD, sig_handler);
        signal(SIGPIPE, SIG_IGN);
-       run_config();
+       run_config(run_level);
        running = true;
 
        while (running) {
index df2dbe235d9bee97c8afe4ebccf5d4956982f7e6..15f652b61e26bd6f0097391c3e91344ac1f5014f 100644 (file)
@@ -28,8 +28,6 @@
 #include "bspwm.h"
 #include "settings.h"
 
-extern char **environ;
-
 char external_rules_command[MAXLEN];
 char status_prefix[MAXLEN];
 
@@ -74,14 +72,16 @@ bool remove_disabled_monitors;
 bool remove_unplugged_monitors;
 bool merge_overlapping_monitors;
 
-void run_config(void)
+void run_config(int run_level)
 {
        if (fork() == 0) {
                if (dpy != NULL) {
                        close(xcb_get_file_descriptor(dpy));
                }
                setsid();
-               execle(config_path, config_path, (char *) NULL, environ);
+               char arg1[2];
+               snprintf(arg1, 2, "%i", run_level);
+               execl(config_path, config_path, arg1, (char *) NULL);
                err("Couldn't execute the configuration file.\n");
        }
 }
index 021bf6d06afd8f7a749779db0d42c88fad15f2ee..f1cb85e86b519bf8bfee6d3e04e95ae51c896316 100644 (file)
@@ -111,7 +111,7 @@ extern bool remove_disabled_monitors;
 extern bool remove_unplugged_monitors;
 extern bool merge_overlapping_monitors;
 
-void run_config(void);
+void run_config(int run_level);
 void load_settings(void);
 
 #endif