First create open-tui (and set chmod +x on it):
#!/bin/bash
tool=$1
loc="$2"
loc=${loc#"file://"}
if [[ ! -e $loc ]]; then
loc=$(dirname "$loc")
fi
i3-msg exec 'urxvt -e '$tool' "'$loc'"'
You need to modify i3-msg if you are using Gnome or something else rather than i3wm.
Finally create a ~/.local/share/applications/xranger.desktop file to register ranger as a desktop app:
[Desktop Entry]
Version=1.0
Name=xranger
GenericName=File Manager
Comment=Launches the ranger file manager
# needs full path to bin
Exec=/home/path-to/open-tui ranger %F
Icon=utilities-terminal
Terminal=false
X-MultipleArgs=false
Type=Application
MimeType=inode/directory;
StartupNotify=true
Categories=System;FileTools;FileManager
I used xranger instead of ranger to avoid conflicts with the default desktop item that may have been installed by ranger.
Then in your GUI use the new desktop link or set the default handler for directories to ranger:
xdg-mime default xranger.desktop inode/directory # sets ~/.config/mimeapps.list