- 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
-
-
Save the-anonymous-raven/cbf1a0c082914896aee0e735afe10517 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 """ | |
s = "" | |
for word in range(1, len(self.args)): | |
s += self.arg(word) | |
s += " " | |
filename = s[0 : len(s) - 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 d. chrome_choose . | |
map ds chrome_choose %s |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How do I open with Chromium?