Updated Advanced use cases (markdown)

luukvbaal 2021-11-04 12:11:18 +01:00
parent a652ca3ad6
commit 52f6e13470

@ -126,7 +126,7 @@ StartupWMClass=NNN
#### Chromium
To use `nnn` as the file picker dialog for chromium browsers, create a script `kdialog` in your path:
To use `nnn` as the file picker dialog for chromium browsers, create a script `kdialog` in your `PATH` along the lines of:
```sh
#!/bin/sh
@ -139,6 +139,8 @@ file="${file##/*/}"
st -c picker sh -c "nnn -S -s picker -p - | awk '{ print system(\"[ -d \" \$0 \" ]\") ? \$0: \$0\"/${file##/*/}\" }' > /proc/$$/fd/1"
```
This example sets the class for `st` to `picker` and `nnn` uses a named session `picker`. This allows you to for example have the picker window float by default in your window manager and `nnn` remembers where your previous "Save as..." target was. Replace with your preferred terminal and `nnn` options if applicable.
Then create a browser wrapper that launches your browser with `XDG_CURRENT_DESKTOP=KDE`:
```sh
#!/bin/sh
@ -147,6 +149,10 @@ XDG_CURRENT_DESKTOP=KDE <browser binary> "$@"
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.
Chromium will now open `nnn` in picker mode, allowing you to:
* Select a directory(<kbd>Space</kbd>) and quit(<kbd>q</kbd>) to save the file with its given name in the target directory.
* Create a new file(<kbd>n</kbd>) and select it(<kbd>Enter</kbd>) to save the file with a different name.
## Launch `nnn` with a keyboard shortcut
### On a Desktop Environment (KDE, GNOME, XFCE)