Skip to content

Commit

Permalink
Search for plugins in both /usr and /usr/local (#404)
Browse files Browse the repository at this point in the history
  • Loading branch information
serebit committed Jul 10, 2023
1 parent 5f64148 commit f95a9c6
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 4 deletions.
26 changes: 22 additions & 4 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ datadir = join_paths(prefix, get_option('datadir'))
localedir = join_paths(prefix, get_option('localedir'))
podir = join_paths(meson.source_root(), 'po')

cdata.set_quoted('DATADIR', datadir)
cdata.set_quoted('SYSCONFDIR', confdir)
cdata.set_quoted('LOCALEDIR', localedir)
cdata.set_quoted('PACKAGE_URL', 'https://buddiesofbudgie.org')

# Handle i18n on the .desktop file
# Originally stolem from TingPing:
# https://github.com/vinszent/gnome-twitch/blob/master/data/meson.build
Expand All @@ -106,10 +111,23 @@ cdata.set_quoted('MODULEDIR', plugin_libdir)
cdata.set_quoted('MODULE_DATA_DIR', plugin_datadir)
cdata.set_quoted('RAVEN_PLUGIN_LIBDIR', raven_plugin_libdir)
cdata.set_quoted('RAVEN_PLUGIN_DATADIR', raven_plugin_datadir)
cdata.set_quoted('DATADIR', datadir)
cdata.set_quoted('SYSCONFDIR', confdir)
cdata.set_quoted('LOCALEDIR', localedir)
cdata.set_quoted('PACKAGE_URL', 'https://buddiesofbudgie.org')

if prefix == '/usr' or prefix == '/usr/local'
cdata.set('HAS_SECONDARY_PLUGIN_DIRS', true)

if prefix == '/usr'
secondary_libdir_root = join_paths(prefix, 'local', get_option('libdir'), meson.project_name())
secondary_datadir_root = join_paths(prefix, 'local', get_option('datadir'), meson.project_name())
else
secondary_libdir_root = join_paths('/usr', get_option('libdir'), meson.project_name())
secondary_datadir_root = join_paths('/usr', get_option('datadir'), meson.project_name())
endif

cdata.set_quoted('MODULEDIR_SECONDARY', join_paths(secondary_libdir_root, 'plugins'))
cdata.set_quoted('MODULE_DATA_DIR_SECONDARY', join_paths(secondary_datadir_root, 'plugins'))
cdata.set_quoted('RAVEN_PLUGIN_LIBDIR_SECONDARY', join_paths(secondary_libdir_root, 'raven-plugins'))
cdata.set_quoted('RAVEN_PLUGIN_DATADIR_SECONDARY', join_paths(secondary_datadir_root, 'raven-plugins'))
endif

with_bluetooth = get_option('with-bluetooth')
if with_bluetooth == true
Expand Down
16 changes: 16 additions & 0 deletions src/config/budgie-config.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#ifndef CONFIG_H_INCLUDED
#include "config.h"
#include <stdbool.h>

/**
* All this is to keep Vala happy & configured..
Expand All @@ -19,6 +20,21 @@ const char* BUDGIE_MODULE_DIRECTORY = MODULEDIR;
const char* BUDGIE_MODULE_DATA_DIRECTORY = MODULE_DATA_DIR;
const char* BUDGIE_RAVEN_PLUGIN_LIBDIR = RAVEN_PLUGIN_LIBDIR;
const char* BUDGIE_RAVEN_PLUGIN_DATADIR = RAVEN_PLUGIN_DATADIR;

#ifdef HAS_SECONDARY_PLUGIN_DIRS
const bool BUDGIE_HAS_SECONDARY_PLUGIN_DIRS = true;
const char* BUDGIE_MODULE_DIRECTORY_SECONDARY = MODULEDIR_SECONDARY;
const char* BUDGIE_MODULE_DATA_DIRECTORY_SECONDARY = MODULE_DATA_DIR_SECONDARY;
const char* BUDGIE_RAVEN_PLUGIN_LIBDIR_SECONDARY = RAVEN_PLUGIN_LIBDIR_SECONDARY;
const char* BUDGIE_RAVEN_PLUGIN_DATADIR_SECONDARY = RAVEN_PLUGIN_DATADIR_SECONDARY;
#else
const bool BUDGIE_HAS_SECONDARY_PLUGIN_DIRS = false;
const char* BUDGIE_MODULE_DIRECTORY_SECONDARY = NULL;
const char* BUDGIE_MODULE_DATA_DIRECTORY = NULL;
const char* BUDGIE_RAVEN_PLUGIN_LIBDIR = NULL;
const char* BUDGIE_RAVEN_PLUGIN_DATADIR = NULL;
#endif

const char* BUDGIE_DATADIR = DATADIR;
const char* BUDGIE_VERSION = PACKAGE_VERSION;
const char* BUDGIE_WEBSITE = PACKAGE_URL;
Expand Down
8 changes: 8 additions & 0 deletions src/config/budgie-config.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#ifndef _BUDGIE_CONFIG_H_
#define _BUDGIE_CONFIG_H_

#include <stdbool.h>

/* i.e. /usr/lib/budgie-desktop */
extern const char* BUDGIE_MODULE_DIRECTORY;

Expand All @@ -24,6 +26,12 @@ extern const char* BUDGIE_RAVEN_PLUGIN_LIBDIR;
/* i.e. /usr/share/budgie-desktop/raven-plugins */
extern const char* BUDGIE_RAVEN_PLUGIN_DATADIR;

extern const bool BUDGIE_HAS_SECONDARY_PLUGIN_DIRS;
extern const char* BUDGIE_MODULE_DIRECTORY_SECONDARY;
extern const char* BUDGIE_MODULE_DATA_DIRECTORY_SECONDARY;
extern const char* BUDGIE_RAVEN_PLUGIN_LIBDIR_SECONDARY;
extern const char* BUDGIE_RAVEN_PLUGIN_DATADIR_SECONDARY;

/* i.e. /usr/share/ */
extern const char* BUDGIE_DATADIR;

Expand Down
15 changes: 15 additions & 0 deletions src/config/budgie-config.vapi
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,21 @@ namespace Budgie {
[CCode (cheader_filename="budgie-config.h")]
public extern const string RAVEN_PLUGIN_DATADIR;

[CCode (cheader_filename="budgie-config.h")]
public extern const bool HAS_SECONDARY_PLUGIN_DIRS;

[CCode (cheader_filename="budgie-config.h")]
public extern const string? MODULE_DIRECTORY_SECONDARY;

[CCode (cheader_filename="budgie-config.h")]
public extern const string? MODULE_DATA_DIRECTORY_SECONDARY;

[CCode (cheader_filename="budgie-config.h")]
public extern const string? RAVEN_PLUGIN_LIBDIR_SECONDARY;

[CCode (cheader_filename="budgie-config.h")]
public extern const string? RAVEN_PLUGIN_DATADIR_SECONDARY;

[CCode (cheader_filename="budgie-config.h")]
public extern const string DATADIR;

Expand Down
3 changes: 3 additions & 0 deletions src/panel/plugin_manager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ namespace Budgie {
/* System path */
var dir = Environment.get_user_data_dir();
engine.add_search_path(Budgie.MODULE_DIRECTORY, Budgie.MODULE_DATA_DIRECTORY);
if (Budgie.HAS_SECONDARY_PLUGIN_DIRS) {
engine.add_search_path(Budgie.MODULE_DIRECTORY_SECONDARY, Budgie.MODULE_DATA_DIRECTORY_SECONDARY);
}

/* User path */
var user_mod = Path.build_path(Path.DIR_SEPARATOR_S, dir, "budgie-desktop", "plugins");
Expand Down
3 changes: 3 additions & 0 deletions src/raven/plugin_manager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ namespace Budgie {
/* System path */
var dir = Environment.get_user_data_dir();
engine.add_search_path(Budgie.RAVEN_PLUGIN_LIBDIR, Budgie.RAVEN_PLUGIN_DATADIR);
if (Budgie.HAS_SECONDARY_PLUGIN_DIRS) {
engine.add_search_path(Budgie.RAVEN_PLUGIN_LIBDIR_SECONDARY, Budgie.RAVEN_PLUGIN_DATADIR_SECONDARY);
}

/* User path */
var user_mod = Path.build_path(Path.DIR_SEPARATOR_S, dir, "budgie-desktop", "raven-plugins");
Expand Down

0 comments on commit f95a9c6

Please sign in to comment.