diff options
author | dec05eba <dec05eba@protonmail.com> | 2025-05-31 22:54:14 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2025-05-31 23:00:42 +0200 |
commit | 4d7526d21ed78f61eefcb88631762127fb0d4e97 (patch) | |
tree | 0d0121c5acee59813eb66b8eb7ba0b095a8060f5 /src/Utils.cpp | |
parent | fded9b8d57facde1a01e9456d9fd9c3b6955dd23 (diff) |
Add x11 window capture (video and screenshot)
Diffstat (limited to 'src/Utils.cpp')
-rw-r--r-- | src/Utils.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/Utils.cpp b/src/Utils.cpp index f23a330..c36a64a 100644 --- a/src/Utils.cpp +++ b/src/Utils.cpp @@ -32,6 +32,28 @@ namespace gsr { return str.size() >= len && memcmp(str.data() + str.size() - len, substr, len) == 0; } + std::string strip(const std::string &str) { + int start_index = 0; + int str_len = str.size(); + + for(int i = 0; i < str_len; ++i) { + if(str[i] != ' ') { + start_index += i; + str_len -= i; + break; + } + } + + for(int i = str_len - 1; i >= 0; --i) { + if(str[i] != ' ') { + str_len = i + 1; + break; + } + } + + return str.substr(start_index, str_len); + } + std::string get_home_dir() { const char *home_dir = getenv("HOME"); if(!home_dir) { |