summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar emersion <contact@emersion.fr>2018-05-05 20:09:34 +0100
committerLibravatar GitHub <noreply@github.com>2018-05-05 20:09:34 +0100
commitc96ac2ff2a61571dc34f3a68dbe13a9b9c5884de (patch)
tree80579da473fb095b61a4693a1ab009d2fb6ea595
parentMerge pull request #1924 from nbraud/spelling (diff)
parentMerge branch 'master' into usr-lib (diff)
downloadsway-c96ac2ff2a61571dc34f3a68dbe13a9b9c5884de.tar.gz
sway-c96ac2ff2a61571dc34f3a68dbe13a9b9c5884de.tar.zst
sway-c96ac2ff2a61571dc34f3a68dbe13a9b9c5884de.zip
Merge pull request #1881 from nbraud/usr-lib
Install swaybar and swaybg under /usr/lib/sway
-rw-r--r--meson.build9
-rw-r--r--security.d/00-defaults.in6
-rw-r--r--sway/commands/exec_always.c38
-rw-r--r--swaybar/meson.build3
-rw-r--r--swaybg/meson.build3
5 files changed, 54 insertions, 5 deletions
diff --git a/meson.build b/meson.build
index bf266e5f..e40dc33c 100644
--- a/meson.build
+++ b/meson.build
@@ -19,6 +19,14 @@ is_freebsd = host_machine.system().startswith('freebsd')
19datadir = get_option('datadir') 19datadir = get_option('datadir')
20sysconfdir = get_option('sysconfdir') 20sysconfdir = get_option('sysconfdir')
21prefix = get_option('prefix') 21prefix = get_option('prefix')
22libexecdir = get_option('libexecdir')
23
24if libexecdir == ''
25 libexecdir = 'lib'
26endif
27sway_libexecdir = join_paths(prefix, libexecdir, 'sway')
28add_project_arguments('-DSWAY_LIBEXECDIR="/@0@"'.format(sway_libexecdir), language : 'c')
29
22 30
23jsonc = dependency('json-c', version: '>=0.13') 31jsonc = dependency('json-c', version: '>=0.13')
24pcre = dependency('libpcre') 32pcre = dependency('libpcre')
@@ -113,6 +121,7 @@ config = configuration_data()
113config.set('sysconfdir', join_paths(prefix, sysconfdir)) 121config.set('sysconfdir', join_paths(prefix, sysconfdir))
114config.set('datadir', join_paths(prefix, datadir)) 122config.set('datadir', join_paths(prefix, datadir))
115config.set('prefix', prefix) 123config.set('prefix', prefix)
124config.set('sway_libexecdir', sway_libexecdir)
116 125
117configure_file( 126configure_file(
118 configuration: config, 127 configuration: config,
diff --git a/security.d/00-defaults.in b/security.d/00-defaults.in
index e4626477..b5ae1149 100644
--- a/security.d/00-defaults.in
+++ b/security.d/00-defaults.in
@@ -11,9 +11,9 @@
11# Configures enabled compositor features for specific programs 11# Configures enabled compositor features for specific programs
12permit * fullscreen keyboard mouse 12permit * fullscreen keyboard mouse
13permit @prefix@/bin/swaylock lock 13permit @prefix@/bin/swaylock lock
14permit @prefix@/bin/swaybg background
15permit @prefix@/bin/swaygrab screenshot 14permit @prefix@/bin/swaygrab screenshot
16permit @prefix@/bin/swaybar panel 15permit @sway_libexecdir@/swaybg background
16permit @sway_libexecdir@/swaybar panel
17 17
18# Configures enabled IPC features for specific programs 18# Configures enabled IPC features for specific programs
19ipc @prefix@/bin/swaymsg { 19ipc @prefix@/bin/swaymsg {
@@ -24,7 +24,7 @@ ipc @prefix@/bin/swaymsg {
24 } 24 }
25} 25}
26 26
27ipc @prefix@/bin/swaybar { 27ipc @sway_libexecdir@/swaybar {
28 bar-config enabled 28 bar-config enabled
29 outputs enabled 29 outputs enabled
30 workspaces enabled 30 workspaces enabled
diff --git a/sway/commands/exec_always.c b/sway/commands/exec_always.c
index af4e4965..b3078640 100644
--- a/sway/commands/exec_always.c
+++ b/sway/commands/exec_always.c
@@ -11,6 +11,7 @@
11#include "log.h" 11#include "log.h"
12#include "stringop.h" 12#include "stringop.h"
13 13
14
14struct cmd_results *cmd_exec_always(int argc, char **argv) { 15struct cmd_results *cmd_exec_always(int argc, char **argv) {
15 struct cmd_results *error = NULL; 16 struct cmd_results *error = NULL;
16 if (!config->active) return cmd_results_new(CMD_DEFER, NULL, NULL); 17 if (!config->active) return cmd_results_new(CMD_DEFER, NULL, NULL);
@@ -51,7 +52,44 @@ struct cmd_results *cmd_exec_always(int argc, char **argv) {
51 if ((pid = fork()) == 0) { 52 if ((pid = fork()) == 0) {
52 // Fork child process again 53 // Fork child process again
53 setsid(); 54 setsid();
55
54 if ((*child = fork()) == 0) { 56 if ((*child = fork()) == 0) {
57 // Acquire the current PATH
58 char *path = getenv("PATH");
59 const char *extra_path = ":" SWAY_LIBEXECDIR;
60 const size_t extra_size = sizeof(SWAY_LIBEXECDIR) + 1;
61
62 if (!path) {
63 size_t n = confstr(_CS_PATH, NULL, 0);
64 path = malloc(n + extra_size);
65 if (!path) {
66 wlr_log(L_ERROR, "exec_always: Unable to allocate PATH");
67 exit(EXIT_FAILURE);
68 }
69 confstr(_CS_PATH, path, n);
70
71 } else {
72 size_t n = strlen(path) + 1;
73 char *tmp = malloc(n + extra_size);
74 if (!tmp) {
75 wlr_log(L_ERROR, "exec_always: Unable to allocate PATH");
76 exit(EXIT_FAILURE);
77 }
78
79 strncpy(tmp, path, n);
80 path = tmp;
81 }
82
83 // Append /usr/lib/sway to PATH
84 strcat(path, extra_path);
85 if (!setenv("PATH", path, 1)) {
86 free(path);
87 wlr_log(L_ERROR, "exec_always: Unable to set PATH");
88 exit(EXIT_FAILURE);
89 }
90 free(path);
91
92 // Execute the command
55 execl("/bin/sh", "/bin/sh", "-c", cmd, (void *)NULL); 93 execl("/bin/sh", "/bin/sh", "-c", cmd, (void *)NULL);
56 // Not reached 94 // Not reached
57 } 95 }
diff --git a/swaybar/meson.build b/swaybar/meson.build
index d65edb11..41c81a88 100644
--- a/swaybar/meson.build
+++ b/swaybar/meson.build
@@ -24,5 +24,6 @@ executable(
24 wlroots, 24 wlroots,
25 ], 25 ],
26 link_with: [lib_sway_common, lib_sway_client], 26 link_with: [lib_sway_common, lib_sway_client],
27 install: true 27 install: true,
28 install_dir: sway_libexecdir
28) 29)
diff --git a/swaybg/meson.build b/swaybg/meson.build
index 8704de6d..716178d2 100644
--- a/swaybg/meson.build
+++ b/swaybg/meson.build
@@ -14,5 +14,6 @@ executable(
14 wlroots, 14 wlroots,
15 ], 15 ],
16 link_with: [lib_sway_common, lib_sway_client], 16 link_with: [lib_sway_common, lib_sway_client],
17 install: true 17 install: true,
18 install_dir: sway_libexecdir
18) 19)