aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2023-10-23 13:04:03 +0200
committerdec05eba <dec05eba@protonmail.com>2023-10-23 13:04:03 +0200
commitbe1e3bad3fe5ce3eca7c0670ed98dada2ec1bd86 (patch)
tree901c78890d761c04d1c29bc68a92905986e78329
parent39b4f8d4caa0025565f5c79115445263faab8756 (diff)
Use XDG_VIDEOS_DIR if available
-rw-r--r--src/config.hpp11
-rw-r--r--src/main.cpp10
2 files changed, 15 insertions, 6 deletions
diff --git a/src/config.hpp b/src/config.hpp
index f812c5a..be3fbf3 100644
--- a/src/config.hpp
+++ b/src/config.hpp
@@ -86,6 +86,17 @@ static std::string get_config_dir() {
return config_dir;
}
+static std::string get_videos_dir() {
+ std::string videos_dir;
+ const char *xdg_videos_dir = getenv("XDG_VIDEOS_DIR");
+ if(xdg_videos_dir) {
+ videos_dir = xdg_videos_dir;
+ } else {
+ videos_dir = get_home_dir() + "/Videos";
+ }
+ return videos_dir;
+}
+
static int create_directory_recursive(char *path) {
int path_len = strlen(path);
char *p = path;
diff --git a/src/main.cpp b/src/main.cpp
index d5de334..4e0d304 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -2283,8 +2283,7 @@ static GtkWidget* create_common_settings_page(GtkStack *stack, GtkApplication *a
static GtkWidget* create_replay_page(GtkApplication *app, GtkStack *stack) {
int row = 0;
- std::string video_filepath = get_home_dir();
- video_filepath += "/Videos";
+ std::string video_filepath = get_videos_dir();
GtkGrid *grid = GTK_GRID(gtk_grid_new());
gtk_stack_add_named(stack, GTK_WIDGET(grid), "replay");
@@ -2395,8 +2394,7 @@ static GtkWidget* create_replay_page(GtkApplication *app, GtkStack *stack) {
static GtkWidget* create_recording_page(GtkApplication *app, GtkStack *stack) {
int row = 0;
- std::string video_filepath = get_home_dir();
- video_filepath += "/Videos";
+ std::string video_filepath = get_videos_dir();
GtkGrid *grid = GTK_GRID(gtk_grid_new());
gtk_stack_add_named(stack, GTK_WIDGET(grid), "recording");
@@ -2665,10 +2663,10 @@ static void load_config(const gpu_info &gpu_inf) {
gtk_label_set_text(stream_key_label, "Url: ");
if(config.record_config.save_directory.empty() || !is_directory(config.record_config.save_directory.c_str()))
- config.record_config.save_directory = get_home_dir() + "/Videos";
+ config.record_config.save_directory = get_videos_dir();
if(config.replay_config.save_directory.empty() || !is_directory(config.replay_config.save_directory.c_str()))
- config.replay_config.save_directory = get_home_dir() + "/Videos";
+ config.replay_config.save_directory = get_videos_dir();
if(config.replay_config.replay_time < 5)
config.replay_config.replay_time = 5;