||<
><>|| = Default File Manager in Gnome = == Introduction == The default file manager in Ubuntu is Nautilus. Some people prefer other file managers. Unfortunately, it's difficult to make other file managers the default, especially since Nautilus manages the desktop icons in Gnome (Ubuntu's desktop environment). == Disclaimer == The first version of this script has been written by a non-programmer. It has been tested and works but, as you can see from the comments in the script, it could still be tweaked to be "better". The "Manual Method", below, actually has fewer steps and used no imported bash scripts, but possibly might not work for all cases. There are a lot of file managers. == Script to change Thunar to be the default file manager == To run this script, paste this block of code into a text file and save it as a file named '''defaultthunar''' in your home folder. {{{#!python #!/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 installed\n" 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 directory\n" cd /usr/share/applications echo -e "\nMaking backup directory\n" ## 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 launcher\n" 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 launcher\n" 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 launcher\n" 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 launcher\n" 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 launcher\n" 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 launcher\n" 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 manager\n" 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 directory\n" cd /usr/share/applications echo -e "\nRestoring backup files\n" 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 folder\n" sudo rm -r nonautilusplease echo -e "\nRestoring Nautilus launcher\n" sudo rm /usr/bin/nautilus && sudo dpkg-divert --rename --remove /usr/bin/nautilus echo -e "\nMaking Nautilus manage the desktop again\n" 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; }}} Then paste these commands into [[https://help.ubuntu.com/community/UsingTheTerminal#Starting%20a%20Terminal|the terminal]] {{{ chmod +x defaultthunar ./defaultthunar }}} == Restoring Nautilus as a default == Just run the script again {{{ ./defaultthunar }}} == Script to change Dolphin to be the default file manager == ''To do later when the Thunar script has been improved upon'' = Alternative method = Same thing can be done adding the new .desktop files to `~/.local/share/applications/` instead of modifying the installation files in `/usr/share/applications`. == Using Midnight Commander == First copy this script to `/usr/local/bin/mcterm` {{{#!python #!/usr/bin/env python # mcterm 1.0 # Daniel Gonzalez Gasull # License: GPL # # Handles packages with Midnight Commander. # Opens a gnome-terminal with Midnight Commander in it. # mcterm can be used inside Firefox in Edit -> Preferences -> Aplications # with zip files, bz2 files, rar files and 7z files. import os import subprocess import sys def main(): if len(sys.argv) > 1: filename = sys.argv[1] file_output, dummy = subprocess.Popen('/usr/bin/file -b %s' % filename, shell=True, stdout=subprocess.PIPE).communicate() filetype = file_output.strip().split()[0] # switch statement try: dirname = { 'Zip': lambda: '%s#uzip' % filename, 'gzip': lambda: '%s#utar' % filename, '7-zip': lambda: '%s#u7z' % filename, 'RAR': lambda: '%s#urar' % filename, 'bzip2': lambda: '%s#utar' % filename, }[filetype]() except KeyError: dirname = filename else: dirname = '' os.system('gnome-terminal --hide-menubar -x mc -s %s' % dirname) if __name__ == "__main__": main() }}} Give yourself permission to execute the script: {{{ sudo chmod 755 /usr/local/bin/mcterm }}} Now copy this file to `~/.local/share/applications/nautilus-browser.desktop` {{{ [Desktop Entry] Encoding=UTF-8 Name=File Browser Comment=Browse the file system with the file manager TryExec=mcterm Exec=mcterm %U Icon=system-file-manager Terminal=false StartupNotify=true Type=Application NoDisplay=true Categories=GNOME;GTK;System;Utility;Core; OnlyShowIn=GNOME; X-GNOME-Bugzilla-Bugzilla=GNOME X-GNOME-Bugzilla-Product=nautilus X-GNOME-Bugzilla-Component=general X-GNOME-Bugzilla-Version=2.28.1 X-Ubuntu-Gettext-Domain=nautilus }}} This other file to `~/.local/share/applications/nautilus-folder-handler.desktop`: {{{ [Desktop Entry] Encoding=UTF-8 Name=Open Folder TryExec=mcterm Exec=mcterm %U NoDisplay=true Terminal=false Icon=folder-open StartupNotify=true Type=Application MimeType=x-directory/gnome-default-handler;x-directory/normal;inode/directory;application/x-gnome-saved-search; OnlyShowIn=GNOME; X-GNOME-Bugzilla-Bugzilla=GNOME X-GNOME-Bugzilla-Product=nautilus X-GNOME-Bugzilla-Component=general X-GNOME-Bugzilla-Version=2.28.1 X-Ubuntu-Gettext-Domain=nautilus }}} And this last file to `~/.local/share/applications/nautilus-home.desktop`: {{{ [Desktop Entry] Encoding=UTF-8 Name=Home Folder Comment=Open your personal folder TryExec=mcterm Exec=mcterm Icon=user-home Terminal=false StartupNotify=true Type=Application Categories=GNOME;GTK;Core; OnlyShowIn=GNOME; X-GNOME-Bugzilla-Bugzilla=GNOME X-GNOME-Bugzilla-Product=nautilus X-GNOME-Bugzilla-Component=general X-Ubuntu-Gettext-Domain=nautilus }}} = Manual Method = == Introduction == While many of you may be comfortable with just running the script above to fix your problem (I don't know if it works because I haven't tried it), others might want to '''know''' what needs to be done to solve it so that when they understand they can apply the solution to their specific need. For example, I'm not using GNOME at all, I'm using [[Openbox]] and [[AvantWindowNavigator|AWN]] but GNOME and all it's components are still installed so when I use applets in the Dock they open Nautilus where I'd rather have them use Thunar or Xfe. It's unlikely (although possible) that someone has the exact same setup as me but with this explanation hopefully you'll be able to solve your problem. {{attachment:IconsPage/note.png}}'''''To follow along you can use either the command-line or a graphical interface.''''' I like using the Terminal and the editor Vim to manipulate files but you might prefer to use the file browser Nautilus and the editor Gedit. == MIME Types == A quick word on MIME/Content Types because they're relevant. You can read more about about them at [[http://en.wikipedia.org/wiki/Internet_media_type|Wikipedia]] but basically they define what type of file a file is. There is a directory `/usr/share/applications` that contains a whole load of `.desktop` files; "shortcuts" to programs. If you copied one of them to your desktop you could double-click it to start the program. In the same directory is a file `defaults.list`, which lists which of those programs to use (via their shortcut) for every MIME Type or type of file. That's how Ubuntu knows which program to use to open a file when you double-click the file's icon. It also has Types for browsing directories, which is what we're interested in right now. There's a similar file `mimeapps.list` in ~/.local/share/applications. See below for a way to change just that file for a single user change, rather than a multi-user change for all users on the system. == Changing Your Default File Manager == This is the recommended method because it doesn't mess around with the files that were installed by your package manager. Also, if it is a shared computer (eg. family, library or lab computer) then this method is your ''only'' option. Default system settings in Ubuntu are overridden by settings in hidden files in a user's home directory (~), if you want to change settings, this is the place to do it. The files in `~/.local/share/applications` override the files in `/usr/share/applications` (mentioned above in [[https://help.ubuntu.com/community/DefaultFileManager#MIME%20Types|MIME Types]]). If the directory does not exist, create it. To change the default File Manager you'll have to edit the file `defaults.list` (or `mimeapps.list`) found in this directory but first we have to find the right `.desktop` file for the program you want to use. === getting the right .desktop file === You have read-access to `/usr/share/applications` so navigate to that directory and search through the `.desktop` files to find the one for your desired File Manager, for example the one for Xfe is `xfe.desktop`. To search for files in Nautilus start typing the name of the file. To search for files from the command line you can list the contents of the directory and search the output for the name of the file: {{{ ls /usr/share/applications | grep xfe }}} If you find it you can move on to the next step, otherwise, if it doesn't exist we'll have to create one. As far as I know there is no `.desktop` file for Thunar so we'll make one for that. Navigate to `~/.local/share/applications`, make a file `thunar.desktop` and write the following in it: {{{ [Desktop Entry] Name=Open Folder TryExec=thunar Exec=thunar %U NoDisplay=true Terminal=false Icon=folder-open StartupNotify=true Type=Application MimeType=x-directory/gnome-default-handler;x-directory/normal;inode/directory;application/x-gnome-saved-search; }}} There are lots of other things you can add if you want to but this should be enough. If you're making a file for another file manager replace the command `thunar` at `Exec` and `TryExec` to the command for your file manager and name it `whateverfilemaneger.desktop`. Just to remind you one last time this file is in sub-directory of your home directory (~), '''''not''''' somewhere in `/usr`! === editing the defaults.list or mimeapps.list file === If you're not in the directory `~/.local/share/applications` then navigate to it now and edit the `defaults.list` file. You can double-click it in Nautilus to open it with Gedit or from the commandline: {{{ editor defaults.list }}} It shouldn't contain much because it's only for the MIME Types which you're overriding. Add the following 2 lines to the file: {{{ inode/directory=thunar.desktop x-directory/normal=thunar.desktop }}} Replace `thunar.desktop` with `whateverfilemaneger.desktop` according to the file you found/created in the previous step. And that should take care of it. No need to reboot, changes should take effect ''immediately''! === Using the above Manual Method on Ubuntu Raring (13.04) to Use the nemo file manager: === Install the [[http://cinnamon.linuxmint.com/?p=198/|nemo file manager]]and give it a spin. I installed nemo [[http://www.webupd8.org/2012/12/how-to-install-nemo-file-manager-in.html|using these instructions]]. See if you like it. In ~/.local/share/applications, Ubuntu raring has `mimeapps.list`: 1. Create '''nemo.desktop''', similar to the above thunar.desktop. a. Use a text editor to change both exec mentions of 'thunar' to be 'nemo', without the quotes. 1. Open '''mimeapps.list''' (instead of 'defaults.list') and add those 2 lines on to the end of the file. With 'thunar.desktop' changed to 'nemo.desktop', of course. This works. So far, it works perfectly and immediately. == Changing the System-wide Default File Manager == {{attachment:IconsPage/warning.png}} '''This method is not recommended because it requires ''root access''!!!''' If you are the system administrator and you want to change the default file manager for all users of the system then follow this method otherwise it's recommended you follow the method above which will change your default file manager without affecting the rest of the system. The method for this is the same as the previous method except that files are created/modified in the `/usr/share/applications` directory (requires root access privileges for write-access) instead of in `~/.local/share/applications/ (in your home directory where you yourself have read/write access). By default you can not login as root in Ubuntu (because it's considered dangerous) so use the `sudo` command to gain root privelages: {{{ sudo -i }}} It will prompt you for your password before allowing you access. Now you can navigate to the applications directory: {{{ cd /usr/share/applications }}} edit the defaults list to include the 2 lines shown in the previous method: {{{ editor defaults.list }}} and if necessary create a `.desktop` file for your file manager: {{{ editor yourfilemanager.desktop }}} with the contents shown in the previous method. If you're not comfortable with using the terminal you can do this using Nautilus too. To gain root access type (either in a terminal or in the run dialogue `Alt+F2`): {{{ gksu nautilus }}} Type your password and you can perform the above tasks using mouse-clicks and the gedit file editor. = One more way - for "mousemonkeys", like me = Just do in terminal {{{ exo-preferred-applications }}} then switch to Utilities tab and select File Manager you prefer. And that's all! ---- CategoryThirdPartySoftware CategorySoftwareDefault