Menu
nautilus2thunar.sh
![Default Default](https://www.linux.com/images/stories/41373/File-template.png)
Nautilus (Ubuntu): nautilus. Thunar (XFCE): thunar. PcManFM (LXDE): pcmanfm. You don’t have to know your file manager in other to do this. The command below works in all desktop environments using the default file manager: xdg-open.
#!/bin/bash |
## Originally written by aysiu from the Ubuntu Forums |
## This is GPL'ed code |
## So improve it and re-release it |
## Define portion to make Thunar the default if that appears to be the appropriate action |
makethunardefault() |
{ |
## I went with --no-install-recommends because |
## I didn't want to bring in a whole lot of junk, |
## and Jaunty installs recommended packages by default. |
echo -e 'nMaking sure Thunar is installedn' |
sudo apt-get update && sudo apt-get install thunar --no-install-recommends |
## Does it make sense to change to the directory? |
## Or should all the individual commands just reference the full path? |
echo -e 'nChanging to application launcher directoryn' |
cd /usr/share/applications |
echo -e 'nMaking backup directoryn' |
## Does it make sense to create an entire backup directory? |
## Should each file just be backed up in place? |
sudo mkdir nonautilusplease |
echo -e 'nModifying folder handler launchern' |
sudo cp nautilus-folder-handler.desktop nonautilusplease/ |
## Here I'm using two separate sed commands |
## Is there a way to string them together to have one |
## sed command make two replacements in a single file? |
sudo sed -i -n 's/nautilus --no-desktop/thunar/g' nautilus-folder-handler.desktop |
sudo sed -i -n 's/TryExec=nautilus/TryExec=thunar/g' nautilus-folder-handler.desktop |
echo -e 'nModifying browser launchern' |
sudo cp nautilus-browser.desktop nonautilusplease/ |
sudo sed -i -n 's/nautilus --no-desktop --browser/thunar/g' nautilus-browser.desktop |
sudo sed -i -n 's/TryExec=nautilus/TryExec=thunar/g' nautilus-browser.desktop |
echo -e 'nModifying computer icon launchern' |
sudo cp nautilus-computer.desktop nonautilusplease/ |
sudo sed -i -n 's/nautilus --no-desktop/thunar/g' nautilus-computer.desktop |
sudo sed -i -n 's/TryExec=nautilus/TryExec=thunar/g' nautilus-computer.desktop |
echo -e 'nModifying home icon launchern' |
sudo cp nautilus-home.desktop nonautilusplease/ |
sudo sed -i -n 's/nautilus --no-desktop/thunar/g' nautilus-home.desktop |
sudo sed -i -n 's/TryExec=nautilus/TryExec=thunar/g' nautilus-home.desktop |
echo -e 'nModifying general Nautilus launchern' |
sudo cp nautilus.desktop nonautilusplease/ |
sudo sed -i -n 's/Exec=nautilus/Exec=thunar/g' nautilus.desktop |
## This last bit I'm not sure should be included |
## See, the only thing that doesn't change to the |
## new Thunar default is clicking the files on the desktop, |
## because Nautilus is managing the desktop (so technically |
## it's not launching a new process when you double-click |
## an icon there). |
## So this kills the desktop management of icons completely |
## Making the desktop pretty useless... would it be better |
## to keep Nautilus there instead of nothing? Or go so far |
## as to have Xfce manage the desktop in Gnome? |
echo -e 'nChanging base Nautilus launchern' |
sudo dpkg-divert --divert /usr/bin/nautilus.old --rename /usr/bin/nautilus && sudo ln -s /usr/bin/thunar /usr/bin/nautilus |
echo -e 'nRemoving Nautilus as desktop managern' |
killall nautilus |
echo -e 'nThunar is now the default file manager. To return Nautilus to the default, run this script again.n' |
} |
restorenautilusdefault() |
{ |
echo -e 'nChanging to application launcher directoryn' |
cd /usr/share/applications |
echo -e 'nRestoring backup filesn' |
sudo cp nonautilusplease/nautilus-folder-handler.desktop . |
sudo cp nonautilusplease/nautilus-browser.desktop . |
sudo cp nonautilusplease/nautilus-computer.desktop . |
sudo cp nonautilusplease/nautilus-home.desktop . |
sudo cp nonautilusplease/nautilus.desktop . |
echo -e 'nRemoving backup foldern' |
sudo rm -r nonautilusplease |
echo -e 'nRestoring Nautilus launchern' |
sudo rm /usr/bin/nautilus && sudo dpkg-divert --rename --remove /usr/bin/nautilus |
echo -e 'nMaking Nautilus manage the desktop againn' |
nautilus --no-default-window & |
## The only change that isn't undone is the installation of Thunar |
## Should Thunar be removed? Or just kept in? |
## Don't want to load the script with too many questions? |
} |
## Make sure that we exit if any commands do not complete successfully. |
## Thanks to nanotube for this little snippet of code from the early |
## versions of UbuntuZilla |
set -o errexit |
trap'echo 'Previous command did not complete successfully. Exiting.'' ERR |
## This is the main code |
## Is it necessary to put an elseif in here? Or is |
## redundant, since the directory pretty much |
## either exists or it doesn't? |
## Is there a better way to keep track of whether |
## the script has been run before? |
if [[ -e /usr/share/applications/nonautilusplease ]];then |
restorenautilusdefault |
else |
makethunardefault |
fi; |
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment
It’s been a while since posting here, but I haven’t forgotten about you :). I’ve still been mulling over (read: procrastinating) on some things, but a lot of that has been put on hold due to some positive developments in my life which I will not go into. However, I do have some other news:
- Development on my inverter project continues, look for more information sometime in the future (who knows).
- I recently received my Raspberry Pi, and am looking at making it into the server for this site.
- I’ve also been considering ways to make the Pi run at least partially on solar power. As I’ve mentioned before this would be a neat thing to have my server do, although there are some logistical obstacles.
That said, the rest of this post is not about anything mentioned in the above list. Rather, it deals with my frustrations regarding Gnome. I upgraded to Gnome 3 on my Gentoo machine, and for the most part was happy with it. That is, once I got used to the layout. I understand why people might not like it, but it didn’t bother me too much. However, eventually it started getting unstable, as in certain things would make it crash. At first it was not much of a problem, but then it started to get more and more random. I switched to Fallback Mode, which I actually kind of liked too. However, this too proved to crash a little too often. (Note: I was also having some issues with the clutter-gst package and introspection USE flag not compiling, but I think my stability problems are related to the current nVidia drivers.)
The other day, a crash happened while playing around with the excellent EDA software KiCad, and that was it: time to migrate to something else. I’d used Xfce in the past, and had been happy with it, although I usually stuck to Gnome because I was familiar with it most of all. Desperate, I emerged it. It’s a great environment as is, but it just felt lacking. I wanted to manage my desktop like I did under Gnome, with my wallpapers and the like. Actually, I wanted Gnome, but it just wasn’t working out. This post will explain how I made this environment more like Gnome by using Xfce with Gnome’s Nautilus file manager. It’s not difficult, and hopefully it will help someone out.
Xfce is a lightweight desktop, and I should point out that doing this sort of defeats the purpose of having it. That said, I had the hardware resources to use Gnome more than comfortably, so this really isn’t an issue. Also, if you really like it, you might consider a distribution that uses it by default, which will probably integrate it fairly well.
Anyway, assuming you’re switching from something else (Gnome in my case), to start with you’ll need to install Xfce. To do this on Gentoo, I used the following command (as root):
emerge -avt xfce4-meta
(Note: The Gentoo Xfce Configuration Guide is a great place to check out if using this distro.)
Next, logout and log back in with Xfce selected as your desktop. You should have a vanilla looking desktop, and now we want to have Nautilus manage the folders and icons. Open the Settings Manager (Applications Menu->Settings), and click on Session and Startup. Now, before I go on, I should say that we are going to determine what gets started when you log in to your Xfce desktop. So, close everything you don’t want open (leave the Settings manager open though). In the Session tab, you should see a list of running applications. Select the xfdesktop program, and kill it. Now click the Save Session button.
So now, Xfce isn’t managing the desktop. Click the Application Autostart tab, and you will see a bunch of different services, some Xfce-related, some Gnome-related. In my case there was one called Files, which I checked. This basically runs the command nautilus -n, which has Nautilus manage the desktop. (If you’re unsure, you can select it, hit Edit, and look at the command.) I also activated some other things, like the SSH Key Agent.
Logging out and logging in again, you should now have Xfce panels, but with a desktop managed by Gnome that responds like it did before. If you want, play with the Xfce panels, and you can make it look fairly Gnome-like. It’s a little weird, but I’m happy with it. It doesn’t have all the 3D effects of Gnome, but it’s responsive, and so far has been fairly stable.