From 3baa500c5e51859e256645c712b3fa441d300ee2 Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Tue, 21 Jan 2020 23:19:13 -0500 Subject: [PATCH] completion: use pkg-config to get install location for bash/fish Both shells provide pkg-config files which declare their designated completionsdir. Use this as the primary source of truth. --- meson.build | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/meson.build b/meson.build index 5c460bb..ce955f8 100644 --- a/meson.build +++ b/meson.build @@ -40,6 +40,8 @@ wayland_protos = dependency('wayland-protocols', version: '>=1.14') xkbcommon = dependency('xkbcommon') cairo = dependency('cairo') gdk_pixbuf = dependency('gdk-pixbuf-2.0', required: get_option('gdk-pixbuf')) +bash_comp = dependency('bash-completion', required: false) +fish_comp = dependency('fish', required: false) libpam = cc.find_library('pam', required: get_option('pam')) crypt = cc.find_library('crypt', required: not libpam.found()) math = cc.find_library('m') @@ -196,7 +198,11 @@ if get_option('bash-completions') bash_files = files( 'completions/bash/swaylock', ) - bash_install_dir = datadir + '/bash-completion/completions' + if bash_comp.found() + bash_install_dir = bash_comp.get_pkgconfig_variable('completionsdir') + else + bash_install_dir = datadir + '/bash-completion/completions' + endif install_data(bash_files, install_dir: bash_install_dir) endif @@ -205,7 +211,11 @@ if get_option('fish-completions') fish_files = files( 'completions/fish/swaylock.fish', ) - fish_install_dir = datadir + '/fish/completions' + if fish_comp.found() + fish_install_dir = fish_comp.get_pkgconfig_variable('completionsdir') + else + fish_install_dir = datadir + '/fish/completions' + endif install_data(fish_files, install_dir: fish_install_dir) endif