Skip to content

Instantly share code, notes, and snippets.

@MOZGIII
Last active December 11, 2015 11:59
Show Gist options
  • Save MOZGIII/4598091 to your computer and use it in GitHub Desktop.
Save MOZGIII/4598091 to your computer and use it in GitHub Desktop.
Disable Ubuntu user direcories localization. Just run it and press Update Names to change the names to english.
#!/bin/bash
if [ ! -f "${HOME}/.config/user-dirs.dirs" ]; then
echo "No user-dirs.dirs found, will not proceed"
exit
fi
if [ ! -f "${HOME}/.config/user-dirs.locale" ]; then
echo "No user-dirs.locale found, forcing generation of current-locale one"
xdg-user-dirs-update --force
fi
if [ "$(cat ${HOME}/.config/user-dirs.locale)x" == "Cx" ]; then
echo "User-dirs are already in C locale, no need to migrate"
exit
fi
source "${HOME}/.config/user-dirs.dirs"
TARGET_DESKTOP=Desktop
TARGET_DOWNLOAD=Downloads
TARGET_TEMPLATES=Templates
TARGET_PUBLICSHARE=Public
TARGET_DOCUMENTS=Documents
TARGET_MUSIC=Music
TARGET_PICTURES=Pictures
TARGET_VIDEOS=Videos
function migrate_user_dir {
echo Moving "$1" to "$2"
mv "$1/*" "$2" 2> /dev/null
rmdir "$1"
}
migrate_user_dir "$XDG_DESKTOP_DIR" "$HOME/$TARGET_DESKTOP"
migrate_user_dir "$XDG_DOWNLOAD_DIR" "$HOME/$TARGET_DOWNLOAD"
migrate_user_dir "$XDG_TEMPLATES_DIR" "$HOME/$TARGET_TEMPLATES"
migrate_user_dir "$XDG_PUBLICSHARE_DIR" "$HOME/$TARGET_PUBLICSHARE"
migrate_user_dir "$XDG_DOCUMENTS_DIR" "$HOME/$TARGET_DOCUMENTS"
migrate_user_dir "$XDG_MUSIC_DIR" "$HOME/$TARGET_MUSIC"
migrate_user_dir "$XDG_PICTURES_DIR" "$HOME/$TARGET_PICTURES"
migrate_user_dir "$XDG_VIDEOS_DIR" "$HOME/$TARGET_VIDEOS"
rm "${HOME}/.config/user-dirs.locale" "${HOME}/.config/user-dirs.dirs"
LC_ALL=C xdg-user-dirs-update --force
# Remove locale to preserve changes
rm "${HOME}/.config/user-dirs.locale"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment