aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2024-09-01 20:24:44 +0200
committerdec05eba <dec05eba@protonmail.com>2024-09-01 20:24:44 +0200
commit636df184fba582c2261e4e0518771b92be68d9b1 (patch)
treea2105ec9223a9687c4bb26f88a91a3fd9fa3e2b2
parent453eb91c90a46652bd3f453b9041ffbfc0daf3e5 (diff)
Find noto fonts, update readme
-rw-r--r--README.md13
-rw-r--r--src/main.cpp20
2 files changed, 31 insertions, 2 deletions
diff --git a/README.md b/README.md
index 79c50ba..60ab4df 100644
--- a/README.md
+++ b/README.md
@@ -2,7 +2,18 @@
Notification in the style of ShadowPlay.
# Dependencies
-x11, xrandr, xrender, xfixes, opengl
+GPU Screen Recorder overlay uses meson build system so you need to install `meson` to build GPU Screen Recorder overlay.
+
+## Build dependencies
+These are the dependencies needed to build GPU Screen Recorder Notification:
+
+* x11 (libx11, libxrandr, libxrender, libxfixes)
+* libglvnd (which provides libgl, libglx and libegl)
+
+## Runtime dependencies
+There are also additional dependencies needed at runtime:
+
+* Noto fonts
# Installation
Run `sudo ./install.sh`. This will install gsr-notify to `/usr/bin/gsr-notify`. You can run meson commands manually to install gsr-notify to another directory.
diff --git a/src/main.cpp b/src/main.cpp
index 411ab48..a3503c9 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -15,6 +15,7 @@
#include <map>
#include <assert.h>
#include <unistd.h>
+#include <limits.h>
#include <X11/Xlib.h>
#include <X11/extensions/Xfixes.h>
@@ -155,6 +156,17 @@ static const mgl_monitor* find_monitor_by_cursor_position(mgl::Window &window) {
return &win->monitors[0];
}
+static std::string find_noto_font_filepath(const char *filename) {
+ const char *directories[] = { "/usr/share/fonts/noto", "/usr/share/fonts/truetype/noto" };
+ char filepath[PATH_MAX];
+ for(const char *directory : directories) {
+ snprintf(filepath, sizeof(filepath), "%s/%s", directory, filename);
+ if(access(filepath, F_OK) == 0)
+ return filepath;
+ }
+ return "";
+}
+
int main(int argc, char **argv) {
std::string resources_path;
if(access("images/stream.png", F_OK) == 0) {
@@ -221,6 +233,12 @@ int main(int argc, char **argv) {
const mgl::Color icon_color = parse_hex_color(icon_color_str ? icon_color_str : "FFFFFF", resources_path);
const mgl::Color bg_color = parse_hex_color(bg_color_str ? bg_color_str : "76b900", resources_path);
+ const std::string noto_sans_bold_filepath = find_noto_font_filepath("NotoSans-Bold.ttf");
+ if(noto_sans_bold_filepath.empty()) {
+ fprintf(stderr, "error: failed to find NotoSans-Bold.ttf. Make sure noto fonts are installed on your system\n");
+ exit(2);
+ }
+
mgl::Init init;
mgl::Window::CreateParams window_create_params;
@@ -246,7 +264,7 @@ int main(int argc, char **argv) {
const mgl_monitor *focused_monitor = find_monitor_by_cursor_position(window);
mgl::MemoryMappedFile font_file;
- if(!font_file.load("/usr/share/fonts/noto/NotoSans-Bold.ttf", mgl::MemoryMappedFile::LoadOptions{true, false}))
+ if(!font_file.load(noto_sans_bold_filepath.c_str(), mgl::MemoryMappedFile::LoadOptions{true, false}))
return 1;
mgl::Font font;