aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/implementation.c33
-rw-r--r--src/main.c5
2 files changed, 30 insertions, 8 deletions
diff --git a/src/implementation.c b/src/implementation.c
index 3ba2be7..7d19282 100644
--- a/src/implementation.c
+++ b/src/implementation.c
@@ -22,13 +22,36 @@ extern char *gPath_pass; // example: programming/github.com/joursoir.gpg
static void copyText(char *password)
{
- size_t size = (strlen(password) + strlen(BASH_EXEC_COPY) + 1) * sizeof(char);
- char *command = malloc(size);
+ size_t size = (strlen(gPath_rootdir) + 5 + 1) * sizeof(char);
+ char *simple_path = malloc(size);
+ snprintf(simple_path, size, "%s%s", gPath_rootdir, ".pass");
- snprintf(command, size, "%s %s", BASH_EXEC_COPY, password);
- system(command);
+ if(getenv("DISPLAY") != NULL)
+ {
+ FILE *f_pass;
+ f_pass = fopen(simple_path, "w");
+ if(f_pass == NULL) {
+ callError(130);
+ }
+ fputs(password, f_pass);
+ fclose(f_pass);
+
+ char *xclip[] = {"xclip", "-selection", "clipboard", "-i", simple_path, NULL};
+ easyFork("xclip", xclip);
- free(command);
+ remove(simple_path);
+ free(simple_path);
+ }
+ else if(getenv("WAYLAND_DISPLAY") != NULL)
+ {
+ char *wl_copy[] = {"wl-copy", password, NULL};
+ easyFork("wl-copy", wl_copy);
+ }
+ else printError("Error: No X11 or Wayland");
+
+ #if defined(DEBUG)
+ printf("Password copied to clipboard\n");
+ #endif
}
void checkForbiddenPaths(char *path) // check two dot in path
diff --git a/src/main.c b/src/main.c
index edcc517..fd1345b 100644
--- a/src/main.c
+++ b/src/main.c
@@ -18,9 +18,8 @@
#include "handerror.h"
#include "implementation.h"
-#define VERSION "1.0b"
-#define DATE_RELEASE "6 January, 2021"
-#define DEBUG
+#define VERSION "1.0c"
+#define DATE_RELEASE "14 January, 2021"
#define STANDARD_TEXTEDITOR "vim"
#define MAXLEN_TEXTEDITOR 16
#define MINLEN_PASSWORD 1