diff --git a/doc/help/commands.asciidoc b/doc/help/commands.asciidoc index 3c3a8bd8f..012522909 100644 --- a/doc/help/commands.asciidoc +++ b/doc/help/commands.asciidoc @@ -261,7 +261,7 @@ Start hinting. - With `spawn`: The executable and arguments to spawn. `{hint-url}` will get replaced by the selected URL. - - With `userscript`: The userscript to execute. Either store the userscript in your data directory or use an absolute path. + - With `userscript`: The userscript to execute. - With `fill`: The command to fill the statusbar with. `{hint-url}` will get replaced by the selected URL. @@ -580,7 +580,7 @@ Note the {url} variable which gets replaced by the current URL might be useful h * +'cmdline'+: The commandline to execute. ==== optional arguments -* +*-u*+, +*--userscript*+: Run the command as a userscript. Either store it in your data directory or use an absolute path. +* +*-u*+, +*--userscript*+: Run the command as a userscript. * +*-v*+, +*--verbose*+: Show notifications when the command started/exited. * +*-d*+, +*--detach*+: Whether the command should be detached from qutebrowser. diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py index 5307d0c8e..dac9edd9a 100644 --- a/qutebrowser/browser/commands.py +++ b/qutebrowser/browser/commands.py @@ -948,7 +948,9 @@ class CommandDispatcher: useful here. Args: - userscript: Run the command as a userscript. + userscript: Run the command as a userscript. Either store the + userscript in ~/.local/share/qutebrowser/userscripts + (or $XDG_DATA_DIR), or use an absolute path. verbose: Show notifications when the command started/exited. detach: Whether the command should be detached from qutebrowser. cmdline: The commandline to execute. diff --git a/qutebrowser/browser/hints.py b/qutebrowser/browser/hints.py index fdc2014a4..46eca6b7e 100644 --- a/qutebrowser/browser/hints.py +++ b/qutebrowser/browser/hints.py @@ -749,7 +749,10 @@ class HintManager(QObject): - With `spawn`: The executable and arguments to spawn. `{hint-url}` will get replaced by the selected URL. - - With `userscript`: The userscript to execute. + - With `userscript`: The userscript to execute. Either store + the userscript in + ~/.local/share/qutebrowser/userscripts (or + $XDG_DATA_DIR), or use an absolute path. - With `fill`: The command to fill the statusbar with. `{hint-url}` will get replaced by the selected URL. diff --git a/qutebrowser/commands/userscripts.py b/qutebrowser/commands/userscripts.py index 564e2f366..88ad04d93 100644 --- a/qutebrowser/commands/userscripts.py +++ b/qutebrowser/commands/userscripts.py @@ -345,12 +345,11 @@ def run(cmd, *args, win_id, env, verbose=False): env['QUTE_USER_AGENT'] = user_agent cmd = os.path.expanduser(cmd) - # check if userscript is in absolute path or in $XDG_DATA_DIRS + # if cmd is not given as an absolute path, look it up + # ~/.local/share/qutebrowser/userscripts (or $XDG_DATA_DIR) if not os.path.isabs(cmd): - log.misc.debug("{} is no absoulte path".format(cmd)) - c = os.path.join(standarddir.data(), "userscripts", cmd) - if os.path.isfile(c): - cmd = c + log.misc.debug("{} is no absolute path".format(cmd)) + cmd = os.path.join(standarddir.data(), "userscripts", cmd) runner.run(cmd, *args, env=env, verbose=verbose) runner.finished.connect(commandrunner.deleteLater)