diff --git a/Advanced-use-cases.md b/Advanced-use-cases.md index 6fbbbe4..b956910 100644 --- a/Advanced-use-cases.md +++ b/Advanced-use-cases.md @@ -122,6 +122,31 @@ StartupWMClass=NNN `--class "NNN"` is used to group all `nnn` instances together and `StartupWMClass=NNN` to tell launcher which windows should be associated with this icon. +### Browser Integration + +#### Chromium + +To use `nnn` as the file picker dialog for chromium browsers, create a script `kdialog` in your path: + +```sh +#!/bin/sh +while :; do case $1 in + --getsavefilename) file="$2" break ;; + --*) shift ;; + *) break ;; +esac done +file="${file##/*/}" +st -c picker sh -c "nnn -S -s picker -p - | awk '{ print system(\"[ -d \" \$0 \" ]\") ? \$0: \$0\"/${file##/*/}\" }' > /proc/$$/fd/1" +``` + +Then create a browser wrapper that launches your browser with `XDG_CURRENT_DESKTOP=KDE`: +```sh +#!/bin/sh +XDG_CURRENT_DESKTOP=KDE "$@" +``` + +This will cause chromium to look for `kdialog` to open files, make sure the `kdialog` script comes in your `PATH` before the `kdialog` package binary if you have this installed. + ## Launch `nnn` with a keyboard shortcut ### On a Desktop Environment (KDE, GNOME, XFCE) @@ -314,4 +339,4 @@ list of supported commands: help on a particular command: - lftp :~> help put \ No newline at end of file + lftp :~> help put