mirror of
				https://github.com/swaywm/sway.git
				synced 2025-11-03 09:01:43 -05:00 
			
		
		
		
	Merge pull request #1881 from nbraud/usr-lib
Install swaybar and swaybg under /usr/lib/sway
This commit is contained in:
		
						commit
						c96ac2ff2a
					
				
					 5 changed files with 54 additions and 5 deletions
				
			
		| 
						 | 
					@ -19,6 +19,14 @@ is_freebsd = host_machine.system().startswith('freebsd')
 | 
				
			||||||
datadir = get_option('datadir')
 | 
					datadir = get_option('datadir')
 | 
				
			||||||
sysconfdir = get_option('sysconfdir')
 | 
					sysconfdir = get_option('sysconfdir')
 | 
				
			||||||
prefix = get_option('prefix')
 | 
					prefix = get_option('prefix')
 | 
				
			||||||
 | 
					libexecdir = get_option('libexecdir')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if libexecdir == ''
 | 
				
			||||||
 | 
						libexecdir = 'lib'
 | 
				
			||||||
 | 
					endif
 | 
				
			||||||
 | 
					sway_libexecdir = join_paths(prefix, libexecdir, 'sway')
 | 
				
			||||||
 | 
					add_project_arguments('-DSWAY_LIBEXECDIR="/@0@"'.format(sway_libexecdir), language : 'c')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
jsonc          = dependency('json-c', version: '>=0.13')
 | 
					jsonc          = dependency('json-c', version: '>=0.13')
 | 
				
			||||||
pcre           = dependency('libpcre')
 | 
					pcre           = dependency('libpcre')
 | 
				
			||||||
| 
						 | 
					@ -113,6 +121,7 @@ config = configuration_data()
 | 
				
			||||||
config.set('sysconfdir', join_paths(prefix, sysconfdir))
 | 
					config.set('sysconfdir', join_paths(prefix, sysconfdir))
 | 
				
			||||||
config.set('datadir', join_paths(prefix, datadir))
 | 
					config.set('datadir', join_paths(prefix, datadir))
 | 
				
			||||||
config.set('prefix', prefix)
 | 
					config.set('prefix', prefix)
 | 
				
			||||||
 | 
					config.set('sway_libexecdir', sway_libexecdir)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
configure_file(
 | 
					configure_file(
 | 
				
			||||||
	configuration: config,
 | 
						configuration: config,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -11,9 +11,9 @@
 | 
				
			||||||
# Configures enabled compositor features for specific programs
 | 
					# Configures enabled compositor features for specific programs
 | 
				
			||||||
permit * fullscreen keyboard mouse
 | 
					permit * fullscreen keyboard mouse
 | 
				
			||||||
permit @prefix@/bin/swaylock lock
 | 
					permit @prefix@/bin/swaylock lock
 | 
				
			||||||
permit @prefix@/bin/swaybg background
 | 
					 | 
				
			||||||
permit @prefix@/bin/swaygrab screenshot
 | 
					permit @prefix@/bin/swaygrab screenshot
 | 
				
			||||||
permit @prefix@/bin/swaybar panel
 | 
					permit @sway_libexecdir@/swaybg  background
 | 
				
			||||||
 | 
					permit @sway_libexecdir@/swaybar panel
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Configures enabled IPC features for specific programs
 | 
					# Configures enabled IPC features for specific programs
 | 
				
			||||||
ipc @prefix@/bin/swaymsg {
 | 
					ipc @prefix@/bin/swaymsg {
 | 
				
			||||||
| 
						 | 
					@ -24,7 +24,7 @@ ipc @prefix@/bin/swaymsg {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ipc @prefix@/bin/swaybar {
 | 
					ipc @sway_libexecdir@/swaybar {
 | 
				
			||||||
    bar-config enabled
 | 
					    bar-config enabled
 | 
				
			||||||
    outputs enabled
 | 
					    outputs enabled
 | 
				
			||||||
    workspaces enabled
 | 
					    workspaces enabled
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -11,6 +11,7 @@
 | 
				
			||||||
#include "log.h"
 | 
					#include "log.h"
 | 
				
			||||||
#include "stringop.h"
 | 
					#include "stringop.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct cmd_results *cmd_exec_always(int argc, char **argv) {
 | 
					struct cmd_results *cmd_exec_always(int argc, char **argv) {
 | 
				
			||||||
	struct cmd_results *error = NULL;
 | 
						struct cmd_results *error = NULL;
 | 
				
			||||||
	if (!config->active) return cmd_results_new(CMD_DEFER, NULL, NULL);
 | 
						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) {
 | 
				
			||||||
	if ((pid = fork()) == 0) {
 | 
						if ((pid = fork()) == 0) {
 | 
				
			||||||
		// Fork child process again
 | 
							// Fork child process again
 | 
				
			||||||
		setsid();
 | 
							setsid();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if ((*child = fork()) == 0) {
 | 
							if ((*child = fork()) == 0) {
 | 
				
			||||||
 | 
								// Acquire the current PATH
 | 
				
			||||||
 | 
								char *path = getenv("PATH");
 | 
				
			||||||
 | 
								const char *extra_path = ":" SWAY_LIBEXECDIR;
 | 
				
			||||||
 | 
								const size_t extra_size = sizeof(SWAY_LIBEXECDIR) + 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								if (!path) {
 | 
				
			||||||
 | 
									size_t n = confstr(_CS_PATH, NULL, 0);
 | 
				
			||||||
 | 
									path = malloc(n + extra_size);
 | 
				
			||||||
 | 
									if (!path) {
 | 
				
			||||||
 | 
										wlr_log(L_ERROR, "exec_always: Unable to allocate PATH");
 | 
				
			||||||
 | 
										exit(EXIT_FAILURE);
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
									confstr(_CS_PATH, path, n);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								} else {
 | 
				
			||||||
 | 
									size_t n = strlen(path) + 1;
 | 
				
			||||||
 | 
									char *tmp = malloc(n + extra_size);
 | 
				
			||||||
 | 
									if (!tmp) {
 | 
				
			||||||
 | 
										wlr_log(L_ERROR, "exec_always: Unable to allocate PATH");
 | 
				
			||||||
 | 
										exit(EXIT_FAILURE);
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									strncpy(tmp, path, n);
 | 
				
			||||||
 | 
									path = tmp;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								// Append /usr/lib/sway to PATH
 | 
				
			||||||
 | 
								strcat(path, extra_path);
 | 
				
			||||||
 | 
								if (!setenv("PATH", path, 1)) {
 | 
				
			||||||
 | 
									free(path);
 | 
				
			||||||
 | 
									wlr_log(L_ERROR, "exec_always: Unable to set PATH");
 | 
				
			||||||
 | 
									exit(EXIT_FAILURE);
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								free(path);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								// Execute the command
 | 
				
			||||||
			execl("/bin/sh", "/bin/sh", "-c", cmd, (void *)NULL);
 | 
								execl("/bin/sh", "/bin/sh", "-c", cmd, (void *)NULL);
 | 
				
			||||||
			// Not reached
 | 
								// Not reached
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -24,5 +24,6 @@ executable(
 | 
				
			||||||
		wlroots,
 | 
							wlroots,
 | 
				
			||||||
	],
 | 
						],
 | 
				
			||||||
	link_with: [lib_sway_common, lib_sway_client],
 | 
						link_with: [lib_sway_common, lib_sway_client],
 | 
				
			||||||
	install: true
 | 
						install: true,
 | 
				
			||||||
 | 
						install_dir: sway_libexecdir
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -14,5 +14,6 @@ executable(
 | 
				
			||||||
		wlroots,
 | 
							wlroots,
 | 
				
			||||||
	],
 | 
						],
 | 
				
			||||||
	link_with: [lib_sway_common, lib_sway_client],
 | 
						link_with: [lib_sway_common, lib_sway_client],
 | 
				
			||||||
	install: true
 | 
						install: true,
 | 
				
			||||||
 | 
						install_dir: sway_libexecdir
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue