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!
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!