diff --git a/file_previews.c b/file_previews.c index 32c4dce..0097fb4 100644 --- a/file_previews.c +++ b/file_previews.c @@ -100,7 +100,7 @@ char* generic(char *path){ } } #if SETTINGS_UEBERZUG_IMAGE_PREVIEW != 0 -void images_clear() { +void images_clear(){ if (previewd == 1) { fprintf(ueberzug, "{\"action\": \"remove\", \ \"identifier\": \"preview\"}\n"); @@ -108,7 +108,7 @@ void images_clear() { previewd = 0; } } -void images_print(char *file_name) { +void images_print(char *file_name){ char *path=getcwd(NULL, 0); fprintf(ueberzug, "{\"action\":\"add\", \ @@ -129,4 +129,8 @@ void ueberzug_init(){ ueberzug = popen("ueberzug layer -s --no-cache ", "w"); #endif } +void ueberzug_close(){ + images_clear(); + pclose(ueberzug); +} #endif diff --git a/file_previews.h b/file_previews.h index 2e153ff..fbb9cc4 100644 --- a/file_previews.h +++ b/file_previews.h @@ -1,9 +1,13 @@ #ifndef PREVIEW_GUARD #define PREVIEW_GUARD #include "file_previews.c" +#include "config.h" #endif char* preview_file(char *file_name, unsigned long file_size); char* get_mimetype(char *path); void images_clear(); void ueberzug_init(); +#if SETTINGS_UEBERZUG_IMAGE_PREVIEW != 0 +void ueberzug_close(); +#endif diff --git a/interactions.c b/interactions.c index ba8b5c8..abaf795 100644 --- a/interactions.c +++ b/interactions.c @@ -343,6 +343,10 @@ void open_with(){ cmd = concat(cmd, mid_content[selected_file_current].file_name); cmd = concat(cmd, "\""); + #if SETTINGS_UEBERZUG_IMAGE_PREVIEW != 0 + images_clear(); + #endif + if (system(cmd) == -1) { FAIL("open_with", "creating subcommand failed unhandled"); } @@ -523,6 +527,9 @@ void update(){ void enter_shell(int passes, int index){ (void)passes; + #if SETTINGS_UEBERZUG_IMAGE_PREVIEW != 0 + images_clear(); + #endif endwin(); if (system(key_binding[index].black_magic) != 0) { /*do nothing*/ diff --git a/main.c b/main.c index 65e4474..db2d654 100644 --- a/main.c +++ b/main.c @@ -107,10 +107,13 @@ int main(){ #endif } + #if SETTINGS_UEBERZUG_IMAGE_PREVIEW != 0 + ueberzug_close(); + #endif threading_free(); free(start_path); - if (threading) { + if (threading) { pthread_join(thread_l, NULL); pthread_join(thread_r, NULL); pthread_join(thread_m, NULL);