Saturday, November 24, 2012
I really miss a menu shortcut in Nautilus to toggle "Show folders before files" option. Going to preferences every time is too much hassle.
But there is other way to toggle it using dconf or gconftool. For Ubuntu 12.04 or newer I suggest using dconf, install it if you don't have it yet.
Create a script with the following content:
#!/bin/bash # Version: Sun Sep 8 2013 OLD_VALUE= LSB_RELEASE=$(lsb_release -sr) if [ $LSB_RELEASE \< '12.04' ]; then OLD_VALUE=$(gconftool --get /apps/nautilus/preferences/sort_directories_first) else OLD_VALUE=$(dconf read /org/gnome/nautilus/preferences/sort-directories-first) fi NEW_VALUE='false' if [ $OLD_VALUE == 'false' ]; then NEW_VALUE='true' fi if [ $LSB_RELEASE \< '12.04' ]; then gconftool --type Boolean --set /apps/nautilus/preferences/sort_directories_first $NEW_VALUE else dconf write /org/gnome/nautilus/preferences/sort-directories-first $NEW_VALUE fi
UPDATE 2013: the new version of the script works across all versions of Ubuntu.
Save the script somewhere, I prefer to keep mine in
~/.bin. Also give it execute permissions.
The next step may vary depending on Gnome version, I will describe it as it's in Ubuntu 12.04. Go to keyboard shortcut setting and add a new custom shortcut. The command field set to path to the script we just created, in my case it's
~/.bin/nautilus-folders-first.sh. You may also try to set full path if relative doesn't work. Right click on the shortcut and set an actual hotkey combination. Choose something that doesn't interferer with any other application, the shortcut is going to be system global. Ctrl+Alt+[some key] is good choice, I prefer Ctrl+Alt+F.
Now open Nautilus and browse where you have both files and folders, test the shortcut. If it doesn't work, try the script in terminal and see if there are any errors.