From a28f15109851a91acfd198a444289cbb6bdc2ce1 Mon Sep 17 00:00:00 2001 From: b3nj4m1n Date: Mon, 25 May 2020 15:02:37 +0200 Subject: [PATCH] Updated external-selection-menu --- .../external-selection-menu/manifest.json | 10 ++--- .../plugins/external-selection-menu/plugin.js | 38 ++++++++++++------- 2 files changed, 29 insertions(+), 19 deletions(-) diff --git a/docs/plugins/external-selection-menu/manifest.json b/docs/plugins/external-selection-menu/manifest.json index 576c36b..80daa2d 100644 --- a/docs/plugins/external-selection-menu/manifest.json +++ b/docs/plugins/external-selection-menu/manifest.json @@ -1,5 +1,5 @@ { - "version": "1.0.2", + "version": "1.1.0", "manifestVersion": "0.1.0", "name": "external-selection-menu", "description": "Use an external menu such as dmenu when prompted to select an entry for auto-type", @@ -9,10 +9,10 @@ "url": "https://github.com/b3nj5m1n" }, "resources": { - "js": "RvSZ2bbByyAOv5JPT13iq99mki0c7eYxDYzjlB0ZGREZiRVs/keybiVDjhqipxkn0mamzYjXCgZMAnXm0j7Vc6+9StQ37/3ImsdKIwsOmOepdVjuf7GhvEYeIKfLwNlG4D7b1mtn9QqnKyjE4gVhc/hm42xrmCgUQKySGfkqk5RWlcxSeG7DZJhgH7Rcs89d3WPWlPT9/JSosoBLl1NoXyuKKXT0lwMkUbQv6PIDheLB3rGb9AdcGS9pKi6AulimP4ApvpJuGcPcalrbgaWZ7n+VUdzI7xNp9JIziLS2BGhQCMKS16VkLCEXM4kRtGovIziaygm5KjiBbtnFtVVXYg==" + "js": "ZYKeaD1NlG5UJt0TOqdy6SIxOwFWRSwG4MXPHzNHuZy7f4jVo8AEjOINFa33o7dXYWWAqYmJVuhwfiXZgqn5EvL7i+QyICw9+2QxKfk8NH3BuymlgbNQUeCY0ck1fPetYPtMeBumvRCSsuufbw2HZXH44umXa4LXRmaU70VFwd8T/NUZAQLxJV9m8UbJVBOu6vzMJ2VV5Sq989PevTXHtjtBpHcQ/FUzB/fR0COvgRUim3mYYHj01SXxxDaS5zE+RLngg1bSnTpjywHlQR48bCQY0rYJciL3AMZims5WAWax0iybmoYgFBMO5ZMbOEK/EzkUWYK4wWgCUKxR6ydKWw==" }, "license": "MIT", - "url": "https://plugins.keeweb.info/plugins/external-selection-menu", - "publicKey": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnRq2k3TTx0ewTe6wDr6QVeB5diwiIWzsJD+ApfZu1KNPedcAgslAfjpNsYF1if6cYsPMJH70xJ2np6RQBl1VPdwShOuxkD7m0BD5Hw/Aar8Hdp5cvAdOOMdBO+0DbGeUMy+z66s+oUCJmqVp19T6PkkxbhN08rgtT7v+aFvrbqbO/vlsskbJpH2K2io+e1XmRGPnSr9q4KSqfGbTfe5gLwDIOFd66Z4mb5Utb5wWpsy6Gjh06Yf257AccGD3A1bkTNOyeeX0tqciYBePWMk0icP/aZ6hnErfhnUKf3tOgPLppSHiGcaSKekhChZ2xLUs3U64JwrXSmwHj+TzdO3S0QIDAQAB", + "url": "https://github.com/b3nj5m1n/keeweb-external-selection-menu", + "publicKey": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA6ibQ/D4FoT4AK0wQPalHvTLWKUMMa5oRL8jQi4fzRgCam/PhA/gzaaPZ/ttC/sjEBPOxhaQ4A76jWnMJ7E/f1zfHbPvpB+tvDGDKNHpjrldTOQIYcz4uU+y+qsFWSv0bJjDORxHbfQT3xXJ09wT7vjSXyD7ERuUIvm6jr+L5v168EZ8iscPnM3pUKp2wYJDR4AGWJ+WD7IHzDZZ8cUvMSsP7IPvVhSfHZZpkfakswgQ1kNWRNcFtmlxcR62xOiLIeJiAix1LXkkDJCT2MjH2XgCG3PNDSChPKr6rui90Wa5O5iGqn0bx6KAyxuP7/adM8ZzAW0HvDPGIV1RfevNpuQIDAQAB", "desktop": true -} +} \ No newline at end of file diff --git a/docs/plugins/external-selection-menu/plugin.js b/docs/plugins/external-selection-menu/plugin.js index 2b3815a..4ceda6d 100644 --- a/docs/plugins/external-selection-menu/plugin.js +++ b/docs/plugins/external-selection-menu/plugin.js @@ -4,8 +4,8 @@ * @license MIT */ -const Logger = require('util/logger'); -const logger = new Logger.Logger('external-selection-menu'); +// const Logger = require('util/logger'); +// const logger = new Logger.Logger('external-selection-menu'); const launcher = require('comp/launcher'); const Launcher = launcher.Launcher; @@ -29,14 +29,12 @@ let args = ['-c']; // Overwrite processEventWithFilter function autoType.AutoType.processEventWithFilter = function (evt) { - // Default code for when a matching entry can be found without having to select one; disabled for now + // Default code for when a matching entry can be found without having to select one // - // const initEntries = evt.filter.getEntries(); if (initEntries.length === 1 && AppSettingsModel.directAutotype) { - // this.hideWindow(() => { - // autoType.AutoType.runAndHandleResult({ entry: initEntries[0] }, evt.windowInfo.id); - // }); - // return; - // } + const initEntries = evt.filter.getEntries(); if (initEntries.length === 1) { + autoType.AutoType.runAndHandleResult({entry: initEntries[0]}, evt.windowInfo.id); + return; + } // Custom code replacing the selection menu // evt.filter.ignoreWindowInfo = true; /* Set filter to ignore windowInfo */ @@ -77,7 +75,7 @@ module.exports.getSettings = function() { type: 'text', maxlength: 50, placeholder: '', - value: 'dmenu' + value: 'rofi' }, { name: 'External menu command arguments', @@ -85,19 +83,31 @@ module.exports.getSettings = function() { type: 'text', maxlength: 50, placeholder: '', - value: '-c' + value: '--dmenu,-p,"> "' } ]; }; module.exports.setSettings = function(changes) { if (changes['External menu command']) { - cmd = changes['External menu command']; + cmd = changes['External menu command'] + ''; } if (changes['External menu command arguments']) { - args = changes['External menu command arguments'].split(' '); + args = changes['External menu command arguments']; + // Make sure there is actually 1+ arguments, otherwise set args to null + if (args === '' || args === ' ' || args === '-') { + args = null; + } + // If there are args, split them into an array (Using , as the delimiter) and remove any quotes around the input + if (args !== null) { + args = args.split(','); + for (let i = 0, len = args.length; i < len; i++) { + if (args[i][0] === '"' && args[i][args[i].length - 1] === '"') { + args[i] = args[i].replace(/"([^"]+(?="))"/g, '$1'); + } + } + } } - logger.info('Menu command changed to: ' + cmd + ' ' + args); }; module.exports.uninstall = function() {