summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFurkan Sahin <furkan-dev@proton.me>2024-08-07 18:34:59 +0200
committerFurkan Sahin <furkan-dev@proton.me>2024-08-07 18:34:59 +0200
commit1146517dbc7b9aefe98bd7df50a576e6577e1b9e (patch)
treedfb86e4fc47caa4a17a5cb8e6c78ac73cb20811a
parenta24c5dcee81b168a4416564c24d6172d3c87415e (diff)
commands/output/color_profile: allows use of relative path for ICC profile
(cherry picked from commit 6576b99c243e2b66d077db0a99ec9683747e3fe9)
-rw-r--r--sway/commands/output/color_profile.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/sway/commands/output/color_profile.c b/sway/commands/output/color_profile.c
index 792bd55f..98481329 100644
--- a/sway/commands/output/color_profile.c
+++ b/sway/commands/output/color_profile.c
@@ -5,6 +5,7 @@
#include <wlr/render/color.h>
#include "sway/commands.h"
#include "sway/config.h"
+#include "stringop.h"
static bool read_file_into_buf(const char *path, void **buf, size_t *size) {
/* Why not use fopen/fread directly? glibc will succesfully open directories,
@@ -70,12 +71,23 @@ struct cmd_results *output_cmd_color_profile(int argc, char **argv) {
return cmd_results_new(CMD_INVALID,
"Invalid color profile specification: icc type requires a file");
}
+
+ char *icc_path = strdup(argv[1]);
+ if (!expand_path(&icc_path)) {
+ struct cmd_results *cmd_res = cmd_results_new(CMD_INVALID,
+ "Invalid color profile specification: invalid file path");
+ free(icc_path);
+ return cmd_res;
+ }
+
void *data = NULL;
size_t size = 0;
- if (!read_file_into_buf(argv[1], &data, &size)) {
+ if (!read_file_into_buf(icc_path, &data, &size)) {
+ free(icc_path);
return cmd_results_new(CMD_FAILURE,
"Failed to load color profile: could not read ICC file");
}
+ free(icc_path);
struct wlr_color_transform *tmp =
wlr_color_transform_init_linear_to_icc(data, size);