summaryrefslogtreecommitdiff
path: root/swayidle/89.patch
blob: c3fe4b4db1ea86551a38049098e1f0598ecd7cfc (plain)
    1 From 4cc31289ee8159e656a5d4795db525791e266b01 Mon Sep 17 00:00:00 2001
    2 From: Jan Beich <jbeich@FreeBSD.org>
    3 Date: Mon, 21 Dec 2020 21:03:14 +0000
    4 Subject: [PATCH 1/4] Drop dependency on sd-login
    5 
    6 Only sd_bus_* functions appear to be used, also supported by basu.
    7 ---
    8  main.c | 2 --
    9  1 file changed, 2 deletions(-)
   10 
   11 diff --git a/main.c b/main.c
   12 index bdf4ad61..89da9693 100644
   13 --- a/main.c
   14 +++ b/main.c
   15 @@ -18,10 +18,8 @@
   16  #include "idle-client-protocol.h"
   17  #if HAVE_SYSTEMD
   18  #include <systemd/sd-bus.h>
   19 -#include <systemd/sd-login.h>
   20  #elif HAVE_ELOGIND
   21  #include <elogind/sd-bus.h>
   22 -#include <elogind/sd-login.h>
   23  #endif
   24  
   25  static struct org_kde_kwin_idle *idle_manager = NULL;
   26 
   27 From efb2264837822a6743ff9c65e7f1c1227cbe86c8 Mon Sep 17 00:00:00 2001
   28 From: Jan Beich <jbeich@FreeBSD.org>
   29 Date: Mon, 21 Dec 2020 21:24:35 +0000
   30 Subject: [PATCH 2/4] build: rename logind-provider to sd-bus-provider
   31 
   32 Based on https://github.com/swaywm/sway/commit/fdbe98512a71
   33 ---
   34  main.c            | 26 +++++++++++++-------------
   35  meson.build       | 39 +++++++++++++++++++++++++++++++--------
   36  meson_options.txt |  2 +-
   37  3 files changed, 45 insertions(+), 22 deletions(-)
   38 
   39 diff --git a/main.c b/main.c
   40 index 89da9693..9acf448f 100644
   41 --- a/main.c
   42 +++ b/main.c
   43 @@ -16,9 +16,9 @@
   44  #include <wordexp.h>
   45  #include "config.h"
   46  #include "idle-client-protocol.h"
   47 -#if HAVE_SYSTEMD
   48 +#if HAVE_LIBSYSTEMD
   49  #include <systemd/sd-bus.h>
   50 -#elif HAVE_ELOGIND
   51 +#elif HAVE_LIBELOGIND
   52  #include <elogind/sd-bus.h>
   53  #endif
   54  
   55 @@ -141,7 +141,7 @@ static void cmd_exec(char *param) {
   56  	}
   57  }
   58  
   59 -#if HAVE_SYSTEMD || HAVE_ELOGIND
   60 +#if HAVE_LOGIND
   61  #define DBUS_LOGIND_SERVICE "org.freedesktop.login1"
   62  #define DBUS_LOGIND_PATH "/org/freedesktop/login1"
   63  #define DBUS_LOGIND_MANAGER_INTERFACE "org.freedesktop.login1.Manager"
   64 @@ -545,7 +545,7 @@ static void enable_timeouts(void) {
   65  	if (state.timeouts_enabled) {
   66  		return;
   67  	}
   68 -#if HAVE_SYSTEMD || HAVE_ELOGIND
   69 +#if HAVE_LOGIND
   70  	if (get_logind_idle_inhibit()) {
   71  		swayidle_log(LOG_INFO, "Not enabling timeouts: idle inhibitor found");
   72  		return;
   73 @@ -560,7 +560,7 @@ static void enable_timeouts(void) {
   74  	}
   75  }
   76  
   77 -#if HAVE_SYSTEMD || HAVE_ELOGIND
   78 +#if HAVE_LOGIND
   79  static void disable_timeouts(void) {
   80  	if (!state.timeouts_enabled) {
   81  		return;
   82 @@ -582,7 +582,7 @@ static void handle_idle(void *data, struct org_kde_kwin_idle_timeout *timer) {
   83  	struct swayidle_timeout_cmd *cmd = data;
   84  	cmd->resume_pending = true;
   85  	swayidle_log(LOG_DEBUG, "idle state");
   86 -#if HAVE_SYSTEMD || HAVE_ELOGIND
   87 +#if HAVE_LOGIND
   88  	if (cmd->idlehint) {
   89  		set_idle_hint(true);
   90  	} else
   91 @@ -599,7 +599,7 @@ static void handle_resume(void *data, struct org_kde_kwin_idle_timeout *timer) {
   92  	if (cmd->registered_timeout != cmd->timeout) {
   93  		register_timeout(cmd, cmd->timeout);
   94  	}
   95 -#if HAVE_SYSTEMD || HAVE_ELOGIND
   96 +#if HAVE_LOGIND
   97  	if (cmd->idlehint) {
   98  		set_idle_hint(false);
   99  	} else
  100 @@ -672,7 +672,7 @@ static int parse_timeout(int argc, char **argv) {
  101  }
  102  
  103  static int parse_sleep(int argc, char **argv) {
  104 -#if !HAVE_SYSTEMD && !HAVE_ELOGIND
  105 +#if !HAVE_LOGIND
  106  	swayidle_log(LOG_ERROR, "%s not supported: swayidle was compiled "
  107  		       "with neither systemd nor elogind support.", "before-sleep");
  108  	exit(-1);
  109 @@ -692,7 +692,7 @@ static int parse_sleep(int argc, char **argv) {
  110  }
  111  
  112  static int parse_resume(int argc, char **argv) {
  113 -#if !HAVE_SYSTEMD && !HAVE_ELOGIND
  114 +#if !HAVE_LOGIND
  115  	swayidle_log(LOG_ERROR, "%s not supported: swayidle was compiled "
  116  			"with neither systemd nor elogind support.", "after-resume");
  117  	exit(-1);
  118 @@ -712,7 +712,7 @@ static int parse_resume(int argc, char **argv) {
  119  }
  120  
  121  static int parse_lock(int argc, char **argv) {
  122 -#if !HAVE_SYSTEMD && !HAVE_ELOGIND
  123 +#if !HAVE_LOGIND
  124  	swayidle_log(LOG_ERROR, "%s not supported: swayidle was compiled"
  125  			" with neither systemd nor elogind support.", "lock");
  126  	exit(-1);
  127 @@ -732,7 +732,7 @@ static int parse_lock(int argc, char **argv) {
  128  }
  129  
  130  static int parse_unlock(int argc, char **argv) {
  131 -#if !HAVE_SYSTEMD && !HAVE_ELOGIND
  132 +#if !HAVE_LOGIND
  133  	swayidle_log(LOG_ERROR, "%s not supported: swayidle was compiled"
  134  			" with neither systemd nor elogind support.", "unlock");
  135  	exit(-1);
  136 @@ -752,7 +752,7 @@ static int parse_unlock(int argc, char **argv) {
  137  }
  138  
  139  static int parse_idlehint(int argc, char **argv) {
  140 -#if !HAVE_SYSTEMD && !HAVE_ELOGIND
  141 +#if !HAVE_LOGIND
  142  	swayidle_log(LOG_ERROR, "%s not supported: swayidle was compiled"
  143  			" with neither systemd nor elogind support.", "idlehint");
  144  	exit(-1);
  145 @@ -1035,7 +1035,7 @@ int main(int argc, char *argv[]) {
  146  	}
  147  
  148  	bool should_run = !wl_list_empty(&state.timeout_cmds);
  149 -#if HAVE_SYSTEMD || HAVE_ELOGIND
  150 +#if HAVE_LOGIND
  151  	connect_to_bus();
  152  	setup_property_changed_listener();
  153  	if (state.before_sleep_cmd || state.after_resume_cmd) {
  154 diff --git a/meson.build b/meson.build
  155 index 0e75c66f..fc6f544e 100644
  156 --- a/meson.build
  157 +++ b/meson.build
  158 @@ -3,7 +3,7 @@ project(
  159  	'c',
  160  	version: '1.7',
  161  	license: 'MIT',
  162 -	meson_version: '>=0.48.0',
  163 +	meson_version: '>=0.50.0',
  164  	default_options: [
  165  		'c_std=c11',
  166  		'warning_level=2',
  167 @@ -32,7 +32,6 @@ wayland_protos = dependency('wayland-protocols', version: '>=1.14')
  168  wayland_server = dependency('wayland-server')
  169  bash_comp      = dependency('bash-completion', required: false)
  170  fish_comp      = dependency('fish', required: false)
  171 -logind = dependency('lib' + get_option('logind-provider'), required: get_option('logind'))
  172  
  173  scdoc = find_program('scdoc', required: get_option('man-pages'))
  174  wayland_scanner = find_program('wayland-scanner')
  175 @@ -77,15 +76,39 @@ swayidle_deps = [
  176  	wayland_server,
  177  ]
  178  
  179 -conf_data = configuration_data()
  180 -conf_data.set10('HAVE_SYSTEMD', false)
  181 -conf_data.set10('HAVE_ELOGIND', false)
  182 +if get_option('sd-bus-provider') == 'auto'
  183 +	if not get_option('logind').disabled()
  184 +		assert(get_option('auto_features').auto(), 'sd-bus-provider must not be set to auto since auto_features != auto')
  185 +	endif
  186 +	sdbus = dependency('libsystemd',
  187 +		required: false,
  188 +		not_found_message: 'libsystemd not found, trying libelogind',
  189 +	)
  190 +	if not sdbus.found()
  191 +		sdbus = dependency('libelogind',
  192 +			required: false,
  193 +		)
  194 +	endif
  195 +else
  196 +	sdbus = dependency(get_option('sd-bus-provider'), required: get_option('logind'))
  197 +endif
  198 +
  199 +logind_deps_found = sdbus.found()
  200 +if get_option('logind').enabled() and not logind_deps_found
  201 +	error('Building with -Dlogind=enabled, but sd-bus has not been not found')
  202 +endif
  203 +have_logind = (not get_option('logind').disabled()) and logind_deps_found
  204  
  205 -if logind.found()
  206 -	swayidle_deps += logind
  207 -	conf_data.set10('HAVE_' + get_option('logind-provider').to_upper(), true)
  208 +if have_logind
  209 +	swayidle_deps += sdbus
  210  endif
  211  
  212 +conf_data = configuration_data()
  213 +
  214 +conf_data.set10('HAVE_LIBSYSTEMD', sdbus.found() and sdbus.name() == 'libsystemd')
  215 +conf_data.set10('HAVE_LIBELOGIND', sdbus.found() and sdbus.name() == 'libelogind')
  216 +conf_data.set10('HAVE_LOGIND', have_logind)
  217 +
  218  configure_file(output: 'config.h', configuration: conf_data)
  219  
  220  executable(
  221 diff --git a/meson_options.txt b/meson_options.txt
  222 index d40de9cb..f96aba0e 100644
  223 --- a/meson_options.txt
  224 +++ b/meson_options.txt
  225 @@ -1,6 +1,6 @@
  226  option('man-pages', type: 'feature', value: 'auto', description: 'Generate and install man pages')
  227  option('logind', type: 'feature', value: 'auto', description: 'Enable support for logind')
  228 -option('logind-provider', type: 'combo', choices: ['systemd', 'elogind'], value: 'systemd', description: 'Provider of logind support library')
  229 +option('sd-bus-provider', type: 'combo', choices: ['auto', 'libsystemd', 'libelogind'], value: 'auto', description: 'Provider of the sd-bus library')
  230  option('zsh-completions', type: 'boolean', value: true, description: 'Install zsh shell completions.')
  231  option('bash-completions', type: 'boolean', value: true, description: 'Install bash shell completions.')
  232  option('fish-completions', type: 'boolean', value: true, description: 'Install fish shell completions.')
  233 
  234 From 88bc257f72f62f7dcc5046656ae53b9df74f5e67 Mon Sep 17 00:00:00 2001
  235 From: Jan Beich <jbeich@FreeBSD.org>
  236 Date: Thu, 24 Dec 2020 23:24:05 +0000
  237 Subject: [PATCH 3/4] build: add basu as sd-bus provider
  238 
  239 Based on https://github.com/swaywm/sway/commit/a52176f83035
  240 ---
  241  main.c            | 12 +++++++-----
  242  meson.build       |  5 +++++
  243  meson_options.txt |  2 +-
  244  3 files changed, 13 insertions(+), 6 deletions(-)
  245 
  246 diff --git a/main.c b/main.c
  247 index 9acf448f..66dbd981 100644
  248 --- a/main.c
  249 +++ b/main.c
  250 @@ -20,6 +20,8 @@
  251  #include <systemd/sd-bus.h>
  252  #elif HAVE_LIBELOGIND
  253  #include <elogind/sd-bus.h>
  254 +#elif HAVE_BASU
  255 +#include <basu/sd-bus.h>
  256  #endif
  257  
  258  static struct org_kde_kwin_idle *idle_manager = NULL;
  259 @@ -674,7 +676,7 @@ static int parse_timeout(int argc, char **argv) {
  260  static int parse_sleep(int argc, char **argv) {
  261  #if !HAVE_LOGIND
  262  	swayidle_log(LOG_ERROR, "%s not supported: swayidle was compiled "
  263 -		       "with neither systemd nor elogind support.", "before-sleep");
  264 +		       "with neither systemd nor elogind nor basu support.", "before-sleep");
  265  	exit(-1);
  266  #endif
  267  	if (argc < 2) {
  268 @@ -694,7 +696,7 @@ static int parse_sleep(int argc, char **argv) {
  269  static int parse_resume(int argc, char **argv) {
  270  #if !HAVE_LOGIND
  271  	swayidle_log(LOG_ERROR, "%s not supported: swayidle was compiled "
  272 -			"with neither systemd nor elogind support.", "after-resume");
  273 +			"with neither systemd nor elogind nor basu support.", "after-resume");
  274  	exit(-1);
  275  #endif
  276  	if (argc < 2) {
  277 @@ -714,7 +716,7 @@ static int parse_resume(int argc, char **argv) {
  278  static int parse_lock(int argc, char **argv) {
  279  #if !HAVE_LOGIND
  280  	swayidle_log(LOG_ERROR, "%s not supported: swayidle was compiled"
  281 -			" with neither systemd nor elogind support.", "lock");
  282 +			" with neither systemd nor elogind nor basu support.", "lock");
  283  	exit(-1);
  284  #endif
  285  	if (argc < 2) {
  286 @@ -734,7 +736,7 @@ static int parse_lock(int argc, char **argv) {
  287  static int parse_unlock(int argc, char **argv) {
  288  #if !HAVE_LOGIND
  289  	swayidle_log(LOG_ERROR, "%s not supported: swayidle was compiled"
  290 -			" with neither systemd nor elogind support.", "unlock");
  291 +			" with neither systemd nor elogind nor basu support.", "unlock");
  292  	exit(-1);
  293  #endif
  294  	if (argc < 2) {
  295 @@ -754,7 +756,7 @@ static int parse_unlock(int argc, char **argv) {
  296  static int parse_idlehint(int argc, char **argv) {
  297  #if !HAVE_LOGIND
  298  	swayidle_log(LOG_ERROR, "%s not supported: swayidle was compiled"
  299 -			" with neither systemd nor elogind support.", "idlehint");
  300 +			" with neither systemd nor elogind nor basu support.", "idlehint");
  301  	exit(-1);
  302  #endif
  303  	if (state.logind_idlehint) {
  304 diff --git a/meson.build b/meson.build
  305 index fc6f544e..2fb8a3a7 100644
  306 --- a/meson.build
  307 +++ b/meson.build
  308 @@ -87,8 +87,12 @@ if get_option('sd-bus-provider') == 'auto'
  309  	if not sdbus.found()
  310  		sdbus = dependency('libelogind',
  311  			required: false,
  312 +			not_found_message: 'libelogind not found, trying basu',
  313  		)
  314  	endif
  315 +	if not sdbus.found()
  316 +		sdbus = dependency('basu', required: false)
  317 +	endif
  318  else
  319  	sdbus = dependency(get_option('sd-bus-provider'), required: get_option('logind'))
  320  endif
  321 @@ -107,6 +111,7 @@ conf_data = configuration_data()
  322  
  323  conf_data.set10('HAVE_LIBSYSTEMD', sdbus.found() and sdbus.name() == 'libsystemd')
  324  conf_data.set10('HAVE_LIBELOGIND', sdbus.found() and sdbus.name() == 'libelogind')
  325 +conf_data.set10('HAVE_BASU', sdbus.found() and sdbus.name() == 'basu')
  326  conf_data.set10('HAVE_LOGIND', have_logind)
  327  
  328  configure_file(output: 'config.h', configuration: conf_data)
  329 diff --git a/meson_options.txt b/meson_options.txt
  330 index f96aba0e..4cb0cb65 100644
  331 --- a/meson_options.txt
  332 +++ b/meson_options.txt
  333 @@ -1,6 +1,6 @@
  334  option('man-pages', type: 'feature', value: 'auto', description: 'Generate and install man pages')
  335  option('logind', type: 'feature', value: 'auto', description: 'Enable support for logind')
  336 -option('sd-bus-provider', type: 'combo', choices: ['auto', 'libsystemd', 'libelogind'], value: 'auto', description: 'Provider of the sd-bus library')
  337 +option('sd-bus-provider', type: 'combo', choices: ['auto', 'libsystemd', 'libelogind', 'basu'], value: 'auto', description: 'Provider of the sd-bus library')
  338  option('zsh-completions', type: 'boolean', value: true, description: 'Install zsh shell completions.')
  339  option('bash-completions', type: 'boolean', value: true, description: 'Install bash shell completions.')
  340  option('fish-completions', type: 'boolean', value: true, description: 'Install fish shell completions.')
  341 
  342 From e639f341c9900de9fd16b47b5d4ea650bc44eadf Mon Sep 17 00:00:00 2001
  343 From: Jan Beich <jbeich@FreeBSD.org>
  344 Date: Thu, 24 Dec 2020 23:50:40 +0000
  345 Subject: [PATCH 4/4] ci: add FreeBSD job
  346 
  347 ---
  348  .build.yml => .builds/alpine.yml |  0
  349  .builds/freebsd.yml              | 17 +++++++++++++++++
  350  2 files changed, 17 insertions(+)
  351  rename .build.yml => .builds/alpine.yml (100%)
  352  create mode 100644 .builds/freebsd.yml
  353 
  354 diff --git a/.build.yml b/.builds/alpine.yml
  355 similarity index 100%
  356 rename from .build.yml
  357 rename to .builds/alpine.yml
  358 diff --git a/.builds/freebsd.yml b/.builds/freebsd.yml
  359 new file mode 100644
  360 index 00000000..9bea6989
  361 --- /dev/null
  362 +++ b/.builds/freebsd.yml
  363 @@ -0,0 +1,17 @@
  364 +image: freebsd/latest
  365 +packages:
  366 +  - basu
  367 +  - meson
  368 +  - pkgconf
  369 +  - scdoc
  370 +  - wayland
  371 +  - wayland-protocols
  372 +sources:
  373 +  - https://github.com/swaywm/swayidle
  374 +tasks:
  375 +  - setup: |
  376 +      cd swayidle
  377 +      meson build
  378 +  - build: |
  379 +      cd swayidle
  380 +      ninja -C build

Generated by cgit