- Copy the contents of kdialog to
/usr/local/bin/kdialog
- Copy the contents of
chrome_chooser.py
to~/.config/ranger/plugins/chrome_chooser.py
- Optionally map appropriately
- Run chrome with
XDG_CURRENT_DESKTOP=KDE
Last active
February 29, 2024 13:48
-
-
Save vn-ki/e592daa2e429377a0640ba71051175e0 to your computer and use it in GitHub Desktop.
Use ranger as chrome file chooser
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
XDG_CURRENT_DESKTOP=KDE google-chrome-beta $@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import sys | |
from ranger.core.loader import CommandLoader | |
from ranger.api.commands import Command | |
class chrome_choose(Command): | |
def execute(self): | |
""" Extract copied files to current directory """ | |
filename = self.arg(1) | |
cwd = self.fm.thisdir | |
if filename == '.': | |
with open('/tmp/ranger-chrome-choosed', 'w') as f: | |
f.write(cwd.path + '/') | |
sys.exit(0) | |
with open('/tmp/ranger-chrome-choosed', 'w') as f: | |
f.write(os.path.join(cwd.path, filename)) | |
sys.exit(0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
for ((i=1;i<=$#;i++)); | |
do | |
if [ ${!i} = "--getsavefilename" ] | |
then ((i++)) | |
filename=${!i}; | |
fi | |
if [ ${!i} = "--version" ] | |
then | |
echo "someversion" | |
exit | |
fi | |
done; | |
path=$( echo ${filename%/*} ) | |
file=$( echo ${filename##/*/} ) | |
rm /tmp/ranger-chrome-choosed | |
termite -e "ranger" -t file-chooser-ranger | |
selected=$(cat /tmp/ranger-chrome-choosed 2> /dev/null) | |
if [ ! $? = 0 ] | |
then | |
exit 1 | |
fi | |
if [ -d $selected ] | |
then | |
echo "$selected$file" | |
else | |
echo $selected | |
fi | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
map dh chrome_choose . | |
map dn console chrome_choose |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How do I open with Chromium?