aboutsummaryrefslogtreecommitdiff
path: root/conkerorrc
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2016-09-25 16:10:18 +0200
committerKarel Kočí <cynerd@email.cz>2016-09-25 16:10:18 +0200
commit068dcc920490e38ea5885831cb900466d9f0b85b (patch)
treeec43f290b42fea7facdd669d0d48b3b106425865 /conkerorrc
parent40a0d4d05dbb3c68b26db85beecb92edecd4210b (diff)
downloadmyconfigs-068dcc920490e38ea5885831cb900466d9f0b85b.tar.gz
myconfigs-068dcc920490e38ea5885831cb900466d9f0b85b.tar.bz2
myconfigs-068dcc920490e38ea5885831cb900466d9f0b85b.zip
Update conkeror password management using pass
Diffstat (limited to 'conkerorrc')
-rw-r--r--conkerorrc48
1 files changed, 26 insertions, 22 deletions
diff --git a/conkerorrc b/conkerorrc
index e710322..afe3a48 100644
--- a/conkerorrc
+++ b/conkerorrc
@@ -94,14 +94,15 @@ interactive("revive-buffer",
});
/////////////////////////////////////////////////////////////////////////////////
// pass password management
-define_key(default_global_keymap, "C-j", "pass-chose-account");
+define_key(default_global_keymap, "C-j", "pass-get-name");
define_key(default_global_keymap, "C-J", "pass-get-password");
+// Extract first and second domain by this hack
function get_domain(I) {
var domain = I.buffer.document.location.href;
var tmp_a = I.buffer.document.createElement('a');
tmp_a.href = domain;
- domain = tmp_a.hostname.replace(/^www\./, '');
+ domain = tmp_a.hostname.match(/[^.]+\.[^.]+$/);
yield co_return(domain);
}
@@ -123,26 +124,13 @@ function shell(cmd, input) {
var pass_domain = "";
var pass_account = "";
-function pass_get_password(I) {
- var domain = yield get_domain(I);
- if (pass_account == "" || pass_domain != domain) {
- I.window.minibuffer.message("pass: Please use C-j first to set account for domain: " + domain);
- } else {
- if (I.buffer.focused_element) {
- var res = yield shell("pass " + pass_account, "");
- dumpln(res.stdout);
- I.buffer.focused_element.value = res.stdout;
- I.window.minibuffer.message("pass: Inserted password for account: " + pass_account);
- }
- }
-};
-
function pass_chose_account(I) {
- var domain = yield get_domain(I);
- var res = yield shell("cd ~/.password-store && find -path '*" + domain + "*' -type f", "");
+ pass_domain = yield get_domain(I);
+ var res = yield shell("cd ~/.password-store && find -path '*" + pass_domain + "*' -type f", "");
var accs = res.stdout.split('\n');
if (accs.length == 0 || accs.length == 1) {
- I.window.minibuffer.message("pass: No accounts detected for domain: " + domain);
+ I.window.minibuffer.message("pass: No accounts detected for domain: " + pass_domain);
+ pass_account = "";
return;
// Note that accs has empty line at end so all this is bupped by one
} else if (accs.length == 2) {
@@ -153,7 +141,7 @@ function pass_chose_account(I) {
accs_list.push(accs[i].replace(/\.\//, '').replace(/\.gpg$/, ''));
}
pass_account = yield I.minibuffer.read(
- $prompt = "Chose account for " + domain + ":",
+ $prompt = "Chose account for " + pass_domain + ":",
$completer = new all_word_completer($completions = accs_list),
$default_completion = accs_list[accs_list.length - 1],
$auto_complete = "url",
@@ -161,7 +149,23 @@ function pass_chose_account(I) {
$auto_complete_delay = 0,
$require_match = true);
}
- pass_domain = domain;
+}
+
+function pass_get_password(I) {
+ var domain = yield get_domain(I);
+ if (pass_account == "" || pass_domain != domain) {
+ yield pass_chose_account(I);
+ }
+ if (pass_account != "" && I.buffer.focused_element) {
+ var res = yield shell("pass " + pass_account, "");
+ dumpln(res.stdout);
+ I.buffer.focused_element.value = res.stdout;
+ I.window.minibuffer.message("pass: Inserted password for account: " + pass_account);
+ }
+};
+
+function pass_get_name(I) {
+ yield pass_chose_account(I);
I.window.minibuffer.message("pass: Chosen account: " + pass_account);
if (I.buffer.focused_element){
var regexp = /[^\/]*$/;
@@ -171,6 +175,6 @@ function pass_chose_account(I) {
// TODO iterate trough all pass to chose account
-interactive("pass-chose-account", "Choses account for to be loged as. As result name of account is outputed.", pass_chose_account);
+interactive("pass-get-name", "Choses account for to be loged as. As result name of account is outputed.", pass_get_name);
interactive("pass-get-password", "Receives password from pass for currently selected account.", pass_get_password);
/////////////////////////////////////////////////////////////////////////////////