Use Thunar as default Gnome file manager
Thunar is the new file manager of Xfce Desktop, it's very similar to the Gtk file selector and it's extremely fast and use less RAM than Nautilus.
I tried to replace "nautilus" with "thunar" in gconf-editor with no success so I investigated to find a smarter solution. The first idea I got was to replace /usr/bin/nautilus with thunar, but this lightweight fm doesn't draw the desktop so the option "--no-desktop" wasn't recornized.
So here what I did to use Thunar as much as possible(*)
Install Thunar as the default file manager
sudo mv /usr/bin/nautilus /usr/bin/nautilus.real
sudo gedit /usr/bin/nautilus
and this is the new /usr/bin/nautilus
#!/usr/bin/ruby
if ARGV[0].nil? or ARGV[0][0..0]=='/'
system("thunar #{ARGV[0]}")
elsif ARGV[1][0..6]=='file://'
system("thunar #{ARGV[1]}")
else system("nautilus.real #{ARGV.join(" ")}")
end
#system("zenity --info --text=\"#{ARGV.join(" ")}\"") #DEBUG
In this way all common URLs are passed to Thunar, but special ones are forwarded to nautilus.real
Notes
- If Nautilus draws the desktop, that icons will open with the REAL Nautilus (you can disable nautilus in the session)
- Sorry for the ruby dependency but I'm not a bash hacker (You are free to post a bash version)
(*) Thunar doesn't support gnome-vfs filesystem, like smb:// webdav:// ssh:// computer:///, so you have to use nautilus in that circumstance..
non funziona con il desktop
dopo aver modificato il file /usr/bin/nautilus con quelli qui sopra il desktop di gnome apre sempre le cortelle con nautilus.
non c'è un modo per far in modo che le apra solo con thunar ?
Precisazione su Thunar
Thunar apre direttamente le cartelle se le clicchi dal gnome-panel. Thunar non disegna il desktop, ma lo fa solo nautilus, quindi se clicchi sulle cartelle del desktop sarà sempre nautilus ad aprirle :(
Actually, a better way to do
Actually, a better way to do it for Python or Ruby would be to use the exec functions. That way the interpreter (and its overhead) isn't hanging around in the background, and you see the program correctly in the program list instead of just the interpreter. Also, nautilus.real should be passed '--nodesktop' and there should be some bounds checking on argv.
========
Python version:
#!/usr/bin/python
import os, sys
## we need the explicit path to tell exec* in arg 0
## so that when thunar/nautilus takes control of
## the process, the right name is shown in the
## process list / pidof / &c, else 'pidof thunar'
## returns null
## set the path explicitly
thunar_bin = '/usr/bin/thunar'
## else uncomment below
#pipe = os.popen('which thunar')
#thunar_bin = pipe.read().strip()
#pipe.close()
## set the path explicitly
nautil_bin = '/usr/bin/nautilus.real'
## else uncomment below
#pipe = os.popen('which nautilus.real')
#nautil_bin = pipe.read().strip()
#pipe.close()
if (len(sys.argv) == 1):
os.execl(thunar_bin, thunar_bin)
elif (not sys.argv[1] or sys.argv[1][0] == '/'):
os.execl(thunar_bin, thunar_bin, sys.argv[1])
elif (len(sys.argv) > 2 and sys.argv[2][0:7] == 'file://'):
os.execl(thunar_bin, thunar_bin, sys.argv[2])
else:
os.execv(nautil_bin, [nautil_bin, '--no-desktop'] + sys.argv[1:])
========
Ruby version:
#!/usr/bin/ruby
## we need the explicit path to tell exec in arg 0
## so that when thunar/nautilus takes control of
## the process, the right name is shown in the
## process list / pidof / &c, else 'pidof thunar'
## returns null
## set the path explicitly
thunar_bin = '/usr/bin/thunar'
## else uncomment below
#thunar_bin = `which thunar`.chomp()
## set the path explicitly
nautil_bin = '/usr/bin/nautilus.real'
## else uncomment below
#nautil_bin = `which nautilus.real`.chomp()
if (ARGV.empty?)
exec([thunar_bin, thunar_bin])
elsif (ARGV[0].nil? or ARGV[0][0,1] == '/')
exec([thunar_bin, thunar_bin], ARGV[0])
elsif (ARGV.length > 1 and ARGV[1][0..6] == 'file://')
exec([thunar_bin, thunar_bin], ARGV[1])
else
exec([nautil_bin, nautil_bin], *(['--no-desktop'] + ARGV))
end
Jordan Callicoat
BTW, you also need to chmod the /usr/bin/nautilus script:
su chmod 0755 /usr/bin/nautilus
Thanks for the new versions
I already had noticed that the ruby process remained in background.
Thanks for the python and bash version
Here is what I ended up with
Hi assente,
Here is what I ended up with after a few days of playing with it. Using Ruby of course, because Ruby is the best. ;)
#!/usr/bin/ruby
# nautilus - Replacement shell script to use Thunar
# in place of nautilus as much as possible - thanks assente
$KODE='U'
# searches for a binary in $PATH
def which(app)
dirnames = ENV['PATH'].split(':')
dirnames.each { |dirname|
filename = File.join(dirname, app)
if (File.executable?(filename) and
File.file?(filename))
return filename
end
}
return nil
end
## we need the explicit path to tell exec in arg 0
## so that when thunar/nautilus takes control of
## the process, the right name is shown in the
## process list / pidof / &c, else 'pidof thunar'
## returns null
## set the path explicitly
thunar_bin = '/usr/bin/thunar'
## else uncomment below
#thunar_bin = File.which('thunar')
## set the path explicitly
nautil_bin = '/usr/bin/nautilus.real'
## else uncomment below
#nautil_bin = File.which('nautilus.real')
args = []
if (ARGV.empty?):
exec([thunar_bin, thunar_bin])
else
ARGV.each { |arg|
if (['--no-desktop', '--browser'].include?(arg))
args.push(arg)
end
}
args.each { |arg| ARGV.delete(arg) }
end
if (ARGV.empty?):
exec([thunar_bin, thunar_bin])
elsif (ARGV[0][0,1] == '/')
exec([thunar_bin, thunar_bin], ARGV[0])
elsif (ARGV.length > 1 and ARGV[1][0..6] == 'file://')
exec([thunar_bin, thunar_bin], ARGV[1])
else
unless (args.include?('--no-desktop'))
args = ['--no-dekstop'] + args
end
exec([nautil_bin, nautil_bin], *(args + ARGV))
end
So far it has worked very well. Hope it helps.
Nota bene: Forgive my ignornce of your blog. I'm a stupid american, so I don't understand Italian too well!
nice script
What don't you understand my englishizated-italian o my italianizeted-english?
It's a pleasure to see another gnome/ruby fan
No problem
Thanks assente,
Your English is fine my friend. I was putting my name (Jordan Callicoat) as the reply header, doh; but I looked up "Soggetto" to see "Subject" (duh!). BTW, I don't think I've said thank you for the tip to use Thunar yet. So, thanks! I really like it. I never used thunar before, but your post got me curious, so I installed it. Now I like it more than Nautilus. And yes, always good to see another ruby/gnome fan! People underestimate Ruby compared with Python and other scripting languages. They don't understand how easy and fun it is to use ruby!
Il dio tu benedice
Jordan
Jordan Callicoat
Here are two other versions of the script in case somebody doesn't have ruby installed.
========
Python version:
#!/usr/bin/python
import os, sys
if (not sys.argv[1] or sys.argv[1][0] == '/'):
os.system('thunar %s' % sys.argv[1])
elif (sys.argv[2][0:7] == 'file://'):
os.system('thunar %s' % sys.argv[2])
else:
os.system('nautilus.real %s' % ' '.join(sys.argv[1:]))
#os.system('zenity --info --text="%s"' % ' '.join(sys.argv[1:])) #DEBUG
========
Shell script version:
#!/bin/bash
if [ -z "${1}" ] || [ "${1:0:1}" == "/" ]; then
thunar "${1}"
elif [ "${2:0:7}" == "file://" ]; then
thunar "${2}"
else
nautilus.real "${@}"
fi
#zenity --info --text="${@}" #DEBUG
Improvement
The above (bash) script doesn't work when clicking on "home" under "places", it seems that when you do it only calls nautilus with just the --no-desktop argument and no file path. In the script this simply calls nautilus.real
Here's a modified version which fixes the problem and simply calls thunar instead of nautilus.real in the aforementioned situation:
[code]
#!/bin/bash
#zenity --info --text="${1}/${@}" #DEBUG
if [ -z "${1}" ] || [ "${1:0:1}" == "/" ]; then
thunar "${1}"
elif [ "${1}" == "--no-desktop" ]; then
thunar
elif [ "${2:0:7}" == "file://" ]; then
thunar "${2}"
else
nautilus.real "${@}"
fi
[/code]
RE: Improvement
I've worked out your code, changing some "if-else" statements. You can find my edited version here (see point #3):
http://www.lineheight.net/blog/aprire-percorsi-con-thunar-da-gnome
... Hoping that this can be useful for somebody. :)
I'm trying to implement this
I'm trying to implement this script on a Fedora 11 machine. But I'm having a problem with the desktop not being drawn, any ideas? Thanks! It looks like a good idea.