forked from external/yambar
cmake: initial support for building wayland-only, or x11-only
This commit is contained in:
parent
f3b225adf7
commit
727d7b343f
7 changed files with 162 additions and 90 deletions
|
@ -12,19 +12,25 @@ endif ()
|
|||
|
||||
set(CMAKE_SHARED_${lib_type}_PREFIX module_)
|
||||
|
||||
set(enabled "")
|
||||
|
||||
pkg_check_modules(alsa REQUIRED IMPORTED_TARGET alsa)
|
||||
add_library(alsa ${lib_type} alsa.c)
|
||||
target_link_libraries(alsa module-sdk PkgConfig::alsa)
|
||||
list(APPEND enabled alsa)
|
||||
|
||||
pkg_check_modules(udev REQUIRED IMPORTED_TARGET libudev)
|
||||
add_library(backlight ${lib_type} backlight.c)
|
||||
target_link_libraries(backlight module-sdk PkgConfig::udev)
|
||||
list(APPEND enabled backlight)
|
||||
|
||||
add_library(battery ${lib_type} battery.c)
|
||||
target_link_libraries(battery module-sdk PkgConfig::udev)
|
||||
list(APPEND enabled battery)
|
||||
|
||||
add_library(clock ${lib_type} clock.c)
|
||||
target_link_libraries(clock module-sdk)
|
||||
list(APPEND enabled clock)
|
||||
|
||||
pkg_check_modules(json REQUIRED IMPORTED_TARGET json-c)
|
||||
find_file(I3_IPC_H i3/ipc.h)
|
||||
|
@ -33,41 +39,43 @@ if (NOT I3_IPC_H)
|
|||
endif ()
|
||||
add_library(i3 ${lib_type} i3.c)
|
||||
target_link_libraries(i3 module-sdk dynlist PkgConfig::json)
|
||||
if (ENABLE_X11)
|
||||
target_link_libraries(i3 xcb-stuff)
|
||||
endif ()
|
||||
list(APPEND enabled i3)
|
||||
|
||||
add_library(label ${lib_type} label.c)
|
||||
target_link_libraries(label module-sdk)
|
||||
list(APPEND enabled label)
|
||||
|
||||
pkg_check_modules(mpd REQUIRED IMPORTED_TARGET libmpdclient)
|
||||
add_library(mpd ${lib_type} mpd.c)
|
||||
target_link_libraries(mpd module-sdk PkgConfig::mpd)
|
||||
list(APPEND enabled mpd)
|
||||
|
||||
add_library(network ${lib_type} network.c)
|
||||
target_link_libraries(network module-sdk)
|
||||
list(APPEND enabled network)
|
||||
|
||||
add_library(removables ${lib_type} removables.c)
|
||||
target_link_libraries(removables module-sdk dynlist PkgConfig::udev)
|
||||
list(APPEND enabled removables)
|
||||
|
||||
pkg_check_modules(xkb REQUIRED IMPORTED_TARGET xcb-xkb)
|
||||
add_library(xkb ${lib_type} xkb.c)
|
||||
target_link_libraries(xkb module-sdk PkgConfig::xkb)
|
||||
if (ENABLE_X11)
|
||||
pkg_check_modules(xkb REQUIRED IMPORTED_TARGET xcb-xkb)
|
||||
add_library(xkb ${lib_type} xkb.c)
|
||||
target_link_libraries(xkb module-sdk PkgConfig::xcb PkgConfig::xkb)
|
||||
list(APPEND enabled xkb)
|
||||
endif ()
|
||||
|
||||
add_library(xwindow ${lib_type} xwindow.c)
|
||||
target_link_libraries(xwindow module-sdk)
|
||||
if (ENABLE_X11)
|
||||
add_library(xwindow ${lib_type} xwindow.c)
|
||||
target_link_libraries(xwindow module-sdk xcb-stuff)
|
||||
list(APPEND enabled xwindow)
|
||||
endif ()
|
||||
|
||||
if (CORE_PLUGINS_AS_SHARED_LIBRARIES)
|
||||
install(
|
||||
TARGETS
|
||||
alsa
|
||||
backlight
|
||||
battery
|
||||
clock
|
||||
i3
|
||||
label
|
||||
mpd
|
||||
network
|
||||
removables
|
||||
xkb
|
||||
xwindow
|
||||
|
||||
DESTINATION lib/f00bar)
|
||||
install(TARGETS ${enabled} DESTINATION lib/f00bar)
|
||||
endif ()
|
||||
|
||||
set(enabled_modules ${enabled} PARENT_SCOPE)
|
||||
|
|
21
modules/i3.c
21
modules/i3.c
|
@ -10,8 +10,11 @@
|
|||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
|
||||
#include <xcb/xcb.h>
|
||||
#include <xcb/xcb_aux.h>
|
||||
#if defined(ENABLE_X11)
|
||||
#include <xcb/xcb.h>
|
||||
#include <xcb/xcb_aux.h>
|
||||
#endif
|
||||
|
||||
#include <i3/ipc.h>
|
||||
|
||||
#include <json-c/json_tokener.h>
|
||||
|
@ -26,7 +29,10 @@
|
|||
#include "../config-verify.h"
|
||||
#include "../particles/dynlist.h"
|
||||
#include "../plugin.h"
|
||||
#include "../xcb.h"
|
||||
|
||||
#if defined(ENABLE_X11)
|
||||
#include "../xcb.h"
|
||||
#endif
|
||||
|
||||
struct ws_content {
|
||||
char *name;
|
||||
|
@ -371,6 +377,7 @@ handle_workspace_event(struct private *m, const struct json_object *json)
|
|||
return true;
|
||||
}
|
||||
|
||||
#if defined(ENABLE_X11)
|
||||
static bool
|
||||
get_socket_address_x11(struct sockaddr_un *addr)
|
||||
{
|
||||
|
@ -419,6 +426,7 @@ get_socket_address_x11(struct sockaddr_un *addr)
|
|||
xcb_disconnect(conn);
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
static bool
|
||||
get_socket_address(struct sockaddr_un *addr)
|
||||
|
@ -426,8 +434,13 @@ get_socket_address(struct sockaddr_un *addr)
|
|||
*addr = (struct sockaddr_un){.sun_family = AF_UNIX};
|
||||
|
||||
const char *sway_sock = getenv("SWAYSOCK");
|
||||
if (sway_sock == NULL)
|
||||
if (sway_sock == NULL) {
|
||||
#if defined(ENABLE_X11)
|
||||
return get_socket_address_x11(addr);
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
strncpy(addr->sun_path, sway_sock, sizeof(addr->sun_path));
|
||||
return true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue