mirror of
https://github.com/hyprwm/Hyprland.git
synced 2024-10-30 05:51:44 +00:00
Added hyprctl version
This commit is contained in:
parent
94811485c9
commit
e3b19e0131
@ -7,6 +7,22 @@ set(CMAKE_MESSAGE_LOG_LEVEL "STATUS")
|
||||
|
||||
message(STATUS "Configuring Hyprland!")
|
||||
|
||||
# Get git info
|
||||
# hash and branch
|
||||
execute_process(
|
||||
COMMAND git rev-parse --abbrev-ref HEAD
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE GIT_BRANCH
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
execute_process(
|
||||
COMMAND git rev-parse HEAD
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE GIT_COMMIT_HASH
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
#
|
||||
#
|
||||
|
||||
include_directories(.)
|
||||
add_compile_options(-std=c++20 -DWLR_USE_UNSTABLE )
|
||||
add_compile_options(-Wall -Wextra -Wno-unused-parameter -Wno-unused-value -Wno-missing-field-initializers -Wno-narrowing)
|
||||
@ -36,6 +52,9 @@ ELSE()
|
||||
message(STATUS "Configuring Hyprland in Release with CMake!")
|
||||
ENDIF(CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES DEBUG)
|
||||
|
||||
target_compile_definitions(Hyprland PRIVATE "-DGIT_COMMIT_HASH=\"${GIT_COMMIT_HASH}\"")
|
||||
target_compile_definitions(Hyprland PRIVATE "-DGIT_BRANCH=\"${GIT_BRANCH}\"")
|
||||
|
||||
target_link_libraries(Hyprland rt)
|
||||
|
||||
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
|
||||
|
@ -24,6 +24,7 @@ usage: hyprctl [command] [(opt)args]
|
||||
layers
|
||||
dispatch
|
||||
keyword
|
||||
version
|
||||
)#";
|
||||
|
||||
void request(std::string arg) {
|
||||
@ -134,6 +135,7 @@ int main(int argc, char** argv) {
|
||||
else if (!strcmp(argv[1], "workspaces")) request("workspaces");
|
||||
else if (!strcmp(argv[1], "activewindow")) request("activewindow");
|
||||
else if (!strcmp(argv[1], "layers")) request("layers");
|
||||
else if (!strcmp(argv[1], "version")) request("version");
|
||||
else if (!strcmp(argv[1], "dispatch")) dispatchRequest(argc, argv);
|
||||
else if (!strcmp(argv[1], "keyword")) keywordRequest(argc, argv);
|
||||
else {
|
||||
|
@ -71,6 +71,22 @@ std::string layersRequest() {
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string versionRequest() {
|
||||
std::string result = "Hyprland, built from branch " + std::string(GIT_BRANCH) + " at commit " + GIT_COMMIT_HASH + ", flags: (if any)\n";
|
||||
|
||||
#ifdef LEGACY_RENDERER
|
||||
result += "legacyrenderer\n";
|
||||
#endif
|
||||
#ifndef NDEBUG
|
||||
result += "debug\n";
|
||||
#endif
|
||||
#ifdef NO_XWAYLAND
|
||||
result += "no xwayland\n";
|
||||
#endif
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string dispatchRequest(std::string in) {
|
||||
// get rid of the dispatch keyword
|
||||
in = in.substr(in.find_first_of(' ') + 1);
|
||||
@ -131,6 +147,8 @@ void HyprCtl::tickHyprCtl() {
|
||||
reply = activeWindowRequest();
|
||||
else if (request == "layers")
|
||||
reply = layersRequest();
|
||||
else if (request == "version")
|
||||
reply = versionRequest();
|
||||
else if (request.find("dispatch") == 0)
|
||||
reply = dispatchRequest(request);
|
||||
else if (request.find("keyword") == 0)
|
||||
|
@ -50,3 +50,11 @@
|
||||
#endif
|
||||
|
||||
#define ASSERT(expr) RASSERT(expr, "?")
|
||||
|
||||
// git stuff
|
||||
#ifndef GIT_COMMIT_HASH
|
||||
#define GIT_COMMIT_HASH "?"
|
||||
#endif
|
||||
#ifndef GIT_BRANCH
|
||||
#define GIT_BRANCH "?"
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user