Add meson build

This commit is contained in:
dec05eba
2024-08-05 04:24:59 +02:00
parent 2aa81b741c
commit f0bcf73ba3
10 changed files with 99 additions and 34 deletions

View File

@@ -1,2 +1,8 @@
# GPU Screen Recorder Overlay # GPU Screen Recorder Overlay
A fullscreen overlay UI for [GPU Screen Recorder](https://git.dec05eba.com/gpu-screen-recorder/about/), in the style of NVIDIA ShadowPlay. A fullscreen overlay UI for [GPU Screen Recorder](https://git.dec05eba.com/gpu-screen-recorder/about/), in the style of NVIDIA ShadowPlay.
# Dependencies
x11, xrandr, xrender, xfixes, opengl
# Installation
Run `sudo ./install.sh`. This will install gsr-overlay to `/usr/bin/gsr-overlay`. You can run meson commands manually to install gsr-overlay to another directory.

View File

@@ -1,10 +0,0 @@
#!/bin/sh
[ $# -ne 1 ] && echo "usage: build.sh debug|release" && exit 1
script_dir=$(dirname "$0")
cd "$script_dir"
sibs build --"$1" gpu-screen-recorder-overlay-daemon
sibs build --"$1"
echo "Successfully built"

View File

@@ -101,10 +101,7 @@ int main(void) {
if(overlay_pid == -1) { if(overlay_pid == -1) {
fprintf(stderr, "launch overlay\n"); fprintf(stderr, "launch overlay\n");
// TODO: window_with_input_focus // TODO: window_with_input_focus
const char *args[] = { const char *args[] = { "gsr-overlay", NULL };
"/home/dec05eba/git/gpu-screen-recorder-overlay/sibs-build/linux_x86_64/debug/gpu-screen-recorder-overlay",
NULL
};
exec_program(args, &overlay_pid); exec_program(args, &overlay_pid);
} }
} }

View File

@@ -4,5 +4,8 @@ type = "executable"
version = "0.1.0" version = "0.1.0"
platforms = ["posix"] platforms = ["posix"]
[config]
ignore_dirs = ["build"]
[dependencies] [dependencies]
x11 = ">=1" x11 = ">=1"

13
install.sh Executable file
View File

@@ -0,0 +1,13 @@
#!/bin/sh -e
script_dir=$(dirname "$0")
cd "$script_dir"
[ $(id -u) -ne 0 ] && echo "You need root privileges to run the install script" && exit 1
rm -rf build
meson setup build
meson configure --prefix=/usr --buildtype=release -Dstrip=true build
ninja -C build install
echo "Successfully installed gsr-overlay"

43
meson.build Normal file
View File

@@ -0,0 +1,43 @@
project('gsr-overlay', ['cpp'], version : '1.0.0', default_options : ['warning_level=2', 'cpp_std=c++17'], subproject_dir : 'depends')
if get_option('buildtype') == 'debug'
add_project_arguments('-g3', language : ['cpp'])
elif get_option('buildtype') == 'release'
add_project_arguments('-DNDEBUG', language : ['cpp'])
endif
src = [
'src/Theme.cpp',
'src/gui/ScrollablePage.cpp',
'src/gui/Button.cpp',
'src/gui/Entry.cpp',
'src/gui/ComboBox.cpp',
'src/gui/Page.cpp',
'src/gui/StaticPage.cpp',
'src/gui/Widget.cpp',
'src/gui/List.cpp',
'src/gui/Utils.cpp',
'src/gui/DropdownButton.cpp',
'src/gui/Label.cpp',
'src/GsrInfo.cpp',
'src/Process.cpp',
'src/main.cpp',
]
mglpp_proj = subproject('mglpp')
mglpp_dep = mglpp_proj.get_variable('mglpp_dep')
dep = [
mglpp_dep,
]
executable(
meson.project_name(),
src,
install : true,
dependencies : dep,
)
prefix = get_option('prefix')
datadir = get_option('datadir')
install_subdir('images', install_dir : join_paths(prefix, datadir, 'gsr-overlay'))

View File

@@ -1,5 +1,5 @@
[package] [package]
name = "gpu-screen-recorder-overlay" name = "gsr-overlay"
type = "executable" type = "executable"
version = "0.1.0" version = "0.1.0"
platforms = ["posix"] platforms = ["posix"]
@@ -8,4 +8,4 @@ platforms = ["posix"]
version = "c++17" version = "c++17"
[config] [config]
ignore_dirs = ["gpu-screen-recorder-overlay-daemon"] ignore_dirs = ["build", "gpu-screen-recorder-overlay-daemon"]

View File

@@ -383,10 +383,11 @@ int main(int argc, char **argv) {
gsr::init_theme(gsr_info); gsr::init_theme(gsr_info);
std::string program_root_dir = dirname(argv[0]); std::string project_dir;
if(!program_root_dir.empty() && program_root_dir.back() != '/') if(access("images/gpu_screen_recorder_logo.png", F_OK) == 0)
program_root_dir += '/'; project_dir = "./";
program_root_dir += "../../../"; else
project_dir = "/usr/share/gsr-overlay/";
mgl::Init init; mgl::Init init;
Display *display = (Display*)mgl_get_context()->connection; Display *display = (Display*)mgl_get_context()->connection;
@@ -432,26 +433,26 @@ int main(int argc, char **argv) {
mgl::Font top_bar_font; mgl::Font top_bar_font;
if(!top_bar_font.load_from_file(title_font_file, window_create_params.size.y * 0.03f)) if(!top_bar_font.load_from_file(title_font_file, window_create_params.size.y * 0.03f))
startup_error("failed to load font: fonts/Orbitron-Bold.ttf"); startup_error("failed to load font: fonts/NotoSans-Bold.ttf");
mgl::Font title_font; mgl::Font title_font;
if(!title_font.load_from_file(title_font_file, window_create_params.size.y * 0.019f)) if(!title_font.load_from_file(title_font_file, window_create_params.size.y * 0.019f))
startup_error("failed to load font: fonts/Orbitron-Bold.ttf"); startup_error("failed to load font: fonts/NotoSans-Regular.ttf");
mgl::Font font; mgl::Font font;
if(!font.load_from_file(font_file, window_create_params.size.y * 0.015f)) if(!font.load_from_file(font_file, window_create_params.size.y * 0.015f))
startup_error("failed to load font: fonts/Orbitron-Regular.ttf"); startup_error("failed to load font: fonts/NotoSans-Regular.ttf");
mgl::Texture replay_button_texture; mgl::Texture replay_button_texture;
if(!replay_button_texture.load_from_file((program_root_dir + "images/replay.png").c_str())) if(!replay_button_texture.load_from_file((project_dir + "images/replay.png").c_str()))
startup_error("failed to load texture: images/replay.png"); startup_error("failed to load texture: images/replay.png");
mgl::Texture record_button_texture; mgl::Texture record_button_texture;
if(!record_button_texture.load_from_file((program_root_dir + "images/record.png").c_str())) if(!record_button_texture.load_from_file((project_dir + "images/record.png").c_str()))
startup_error("failed to load texture: images/record.png"); startup_error("failed to load texture: images/record.png");
mgl::Texture stream_button_texture; mgl::Texture stream_button_texture;
if(!stream_button_texture.load_from_file((program_root_dir + "images/stream.png").c_str())) if(!stream_button_texture.load_from_file((project_dir + "images/stream.png").c_str()))
startup_error("failed to load texture: images/stream.png"); startup_error("failed to load texture: images/stream.png");
// TODO: Get size from monitor, get region specific to the monitor // TODO: Get size from monitor, get region specific to the monitor
@@ -642,9 +643,10 @@ int main(int argc, char **argv) {
main_buttons[1].button->set_item_label(id, "Start"); main_buttons[1].button->set_item_label(id, "Start");
// TODO: Show this with a slight delay to make sure it doesn't show up in the video // TODO: Show this with a slight delay to make sure it doesn't show up in the video
const std::string record_image_filepath = project_dir + "images/record.png";
const char *notification_args[] = { const char *notification_args[] = {
"gpu-screen-recorder-notification", "--text", "Recording has been saved", "--timeout", "3.0", "gsr-notify", "--text", "Recording has been saved", "--timeout", "3.0",
"--icon", "./images/record.png", "--icon", record_image_filepath.c_str(),
"--icon-color", "ffffff", "--bg-color", tint_color_as_hex.c_str(), "--icon-color", "ffffff", "--bg-color", tint_color_as_hex.c_str(),
nullptr nullptr
}; };
@@ -677,9 +679,10 @@ int main(int argc, char **argv) {
// TODO: Do not run this is a daemon. Instead get the pid and when launching another notification close the current notification // TODO: Do not run this is a daemon. Instead get the pid and when launching another notification close the current notification
// program and start another one. This can also be used to check when the notification has finished by checking with waitpid NOWAIT // program and start another one. This can also be used to check when the notification has finished by checking with waitpid NOWAIT
// to see when the program has exit. // to see when the program has exit.
const std::string record_image_filepath = project_dir + "images/record.png";
const char *notification_args[] = { const char *notification_args[] = {
"gpu-screen-recorder-notification", "--text", "Recording has started", "--timeout", "3.0", "gsr-notify", "--text", "Recording has started", "--timeout", "3.0",
"--icon", "./images/record.png", "--icon", record_image_filepath.c_str(),
"--icon-color", tint_color_as_hex.c_str(), "--bg-color", tint_color_as_hex.c_str(), "--icon-color", tint_color_as_hex.c_str(), "--bg-color", tint_color_as_hex.c_str(),
nullptr nullptr
}; };
@@ -757,7 +760,7 @@ int main(int argc, char **argv) {
} }
mgl::Texture close_texture; mgl::Texture close_texture;
if(!close_texture.load_from_file("images/cross.png")) if(!close_texture.load_from_file((project_dir + "images/cross.png").c_str()))
startup_error("failed to load texture: images/cross.png"); startup_error("failed to load texture: images/cross.png");
mgl::Sprite close_sprite(&close_texture); mgl::Sprite close_sprite(&close_texture);
@@ -765,7 +768,7 @@ int main(int argc, char **argv) {
close_sprite.set_position(mgl::vec2f(window.get_size().x - close_sprite.get_size().x - 50.0f, top_bar_background.get_size().y * 0.5f - close_sprite.get_size().y * 0.5f).floor()); close_sprite.set_position(mgl::vec2f(window.get_size().x - close_sprite.get_size().x - 50.0f, top_bar_background.get_size().y * 0.5f - close_sprite.get_size().y * 0.5f).floor());
mgl::Texture logo_texture; mgl::Texture logo_texture;
if(!logo_texture.load_from_file("images/gpu_screen_recorder_logo.png")) if(!logo_texture.load_from_file((project_dir + "images/gpu_screen_recorder_logo.png").c_str()))
startup_error("failed to load texture: images/gpu_screen_recorder_logo.png"); startup_error("failed to load texture: images/gpu_screen_recorder_logo.png");
mgl::Sprite logo_sprite(&logo_texture); mgl::Sprite logo_sprite(&logo_texture);

10
uninstall.sh Executable file
View File

@@ -0,0 +1,10 @@
#!/bin/sh -e
script_dir=$(dirname "$0")
cd "$script_dir"
[ $(id -u) -ne 0 ] && echo "You need root privileges to run the uninstall script" && exit 1
ninja -C build uninstall
echo "Successfully uninstalled gsr-overlay"