automate.sh 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/bin/bash
  2. if [ -f Templates.tar.gz ];
  3. then
  4. # extract the dummy files
  5. echo "Extracting files..."
  6. tar -xvzf Templates.tar.gz
  7. # if .config/user-dirs.dirs does not exist, create it and append config settings to tell nautilus about our templates and
  8. # create the custom Templates directory in the home folder, if it does not exist
  9. if [[ ! -f ~/.config/user-dirs.dirs ]];
  10. then
  11. xdg-user-dirs-update
  12. echo -e "Config file created. Restarting script to add entries.\n\n"
  13. exec ./automateChanged.sh
  14. else
  15. # this config already exists; append the entry
  16. source ~/.config/user-dirs.dirs
  17. customPath=$XDG_TEMPLATES_DIR
  18. echo -e "\nYour Templates path for your language is" $customPath
  19. # check if the custom path already exists
  20. if [ -d "$customPath" ];
  21. then
  22. # directory exists; merge
  23. echo -e "Custom path already exists. Merging files...\n(If you already do have a file with the same file name in that target directory, you'll be prompted to choose which one to keep)"
  24. mv -i Templates/* $customPath
  25. rm -rf Templates
  26. else
  27. # directory doesn't exist; creating and moving files
  28. mkdir $customPath
  29. mv Templates/* $customPath
  30. rm -rf Templates
  31. echo "Created custom Templates folder and added files."
  32. fi
  33. fi
  34. else
  35. echo -e "\nTemplates.tar.gz not found.\nPlease ensure you have the compressed tarball from: https://github.com/angela-d/nautilus-right-click-new-file in the same directory as this script.\nExiting."
  36. exit 0
  37. fi
  38. echo "Context menu options created..."
  39. # restart nautilus and put it into the background
  40. nautilus -q && nautilus &
  41. echo -e "\nInstallation complete! You should now have context menu options for new files."