diff --git a/misc/userscripts/add-nextcloud-bookmarks b/misc/userscripts/add-nextcloud-bookmarks index 2a480ccff..1c9a5af5c 100755 --- a/misc/userscripts/add-nextcloud-bookmarks +++ b/misc/userscripts/add-nextcloud-bookmarks @@ -13,16 +13,20 @@ userscript setup: [nextcloud] HOST=https://nextcloud.example.com USER=username -;PASSWORD=lamepassword +PASSWORD=lamepassword +PASS=password_command +;PASS=pass bookmarks/user +;PASS=NONE DESCRIPTION=None ;TAGS=just-one TAGS=read-me-later,added-by-qutebrowser, Another-One If settings aren't in the configuration file, the user will be prompted during bookmark creation. If DESCRIPTION and TAGS are set to None, they will be left - blank. If the user does not want to be prompted for a password, it is recommended + blank. If the user does not want to use his password, it is recommended to set up an 'app password'. See the following for instructions: https://docs.nextcloud.com/server/latest/user_manual/en/session_management.html#managing-devices # noqa: E501 + pass option has been added to avoid clear password in a conf file. qutebrowser setup: add bookmark via hints @@ -37,6 +41,8 @@ troubleshooting: """ import configparser +import subprocess + from json import dumps from os import environ, path from sys import argv, exit @@ -95,20 +101,28 @@ if path.isfile(config_file): config = configparser.ConfigParser() config.read(config_file) settings = dict(config.items("nextcloud")) + if settings["pass"] != "": + passcommand= settings["pass"] + process = subprocess.run(passcommand.split(), capture_output=True, text=True) + output = process.stdout + password=output.partition('\n')[0] + settings["password"]=password else: settings = {} + settings_info = [ ("host", "host information.", "required"), ("user", "username.", "required"), ("password", "password.", "required"), + ("pass", "pass command.", "noinput"), ("description", "description or leave blank", "optional"), ("tags", "tags (comma separated) or leave blank", "optional"), ] # check for settings that need user interaction and clear optional setting if need be for setting in settings_info: - if setting[0] not in settings: + if setting[0] not in settings and setting[2] != "noinput": userInput = get_text(setting[0], setting[1]) settings[setting[0]] = userInput if setting[2] == "optional":