2828
2929# #==============================================================================
3030# #
31- setup ()
32- {
33- include () { source " $( cd $( dirname " ${BASH_SOURCE[0]} " ) > /dev/null 2>&1 && pwd ) / $1 " ; }
34- include ' bash-tools/bash-tools/user_io .sh'
35- include ' bash-tools/bash-tools/hook_script .sh'
36- include ' bash-tools/bash-tools/assemble_script.sh '
37-
38-
39- # # SWITCH BETWEEN AUTOMATIC AND USER INSTALLATION
40- if [ " $# " -eq 0 ] ; then
41- local output_script =" $HOME /.config/synth-shell/synth-shell-greeter.sh "
42- local output_config_dir= " $HOME /.config/ synth-shell"
43- cp " $output_config_dir /synth-shell-greeter.config " " $output_config_dir /synth-shell-greeter.config.backup"
44- printInfo " Installing script as $output_script "
45- local action =$( promptUser " Add hook your .bashrc file or equivalent?\n\tRequired for autostart on new terminals" " [Y]/[n]?" " yYnN" " y" )
46- case " $action " in
47- " " |y|Y ) hookScript $output_script ;;
48- n|N ) ;;
49- * ) printError " Invalid option" ; exit 1
50- esac
31+ include (){ { [ -z " $_IR " ] && _IR= " $PWD " && cd " $( dirname " $PWD / $0 " ) " && include " $1 " && cd " $_IR " && unset _IR ; } || { local d= $PWD & & cd " $( dirname " $PWD / $1 " ) " && . " $( basename " $1 " ) " && cd " $d " ; } || { echo " Include failed $PWD -> $1 " && exit 1 ; } ; }
32+
33+ include ' bash-tools/bash-tools/user_io.sh '
34+ include ' bash-tools/bash-tools/hook_script .sh'
35+ include ' bash-tools/bash-tools/assemble_script .sh'
36+
37+
38+ # # SWITCH BETWEEN AUTOMATIC AND USER INSTALLATION
39+ if [ " $# " -eq 0 ] ; then
40+ OUTPUT_SCRIPT= " $HOME /.config/synth-shell/synth-shell-greeter.sh "
41+ OUTPUT_CONFIG_DIR =" $HOME /.config/synth-shell"
42+ cp " $OUTPUT_CONFIG_DIR / synth-shell-greeter.config " \
43+ " $OUTPUT_CONFIG_DIR /synth-shell-greeter.config.backup"
44+ printInfo " Installing script as $OUTPUT_SCRIPT "
45+ USER_CHOICE =$( promptUser " Add hook your .bashrc file or equivalent?\n\tRequired for autostart on new terminals" " [Y]/[n]?" " yYnN" " y" )
46+ case " $USER_CHOICE " in
47+ " " |y|Y ) hookScript $OUTPUT_SCRIPT ;;
48+ n|N ) ;;
49+ * ) printError " Invalid option" ; exit 1
50+ esac
5151
52- else
53- local output_script=" $1 "
54- local output_config_dir=" $2 "
55- fi
56-
57-
58- # # DEFINE LOCAL VARIABLES
59- local dir=$( cd " $( dirname " ${BASH_SOURCE[0]} " ) " > /dev/null 2>&1 && pwd )
60- local input_script=" $dir /synth-shell-greeter/synth-shell-greeter.sh"
61- local input_config_dir=" $dir /config/"
62-
63-
64- # # HEADER TO BE ADDED AT THE TOP OF THE ASSEMBLED SCRIPT
65- local output_script_header=$( printf ' %s' \
66- " ##!/bin/bash\n" \
67- " \n" \
68- " ## +-----------------------------------+-----------------------------------+\n" \
69- " ## | |\n" \
70- " ## | Copyright (c) 2014-2020, Andres Gongora <[email protected] > |\n" \ 71- " ## | https://github.com/andresgongora/synth-shell-greeter |\n" \
72- " ## | Visit the above URL for details of license and authorship. |\n" \
73- " ## | |\n" \
74- " ## | This program is free software: you can redistribute it and/or modify |\n" \
75- " ## | it under the terms of the GNU General Public License as published by |\n" \
76- " ## | the Free Software Foundation, either version 3 of the License, or |\n" \
77- " ## | (at your option) any later version. |\n" \
78- " ## | |\n" \
79- " ## | This program is distributed in the hope that it will be useful, |\n" \
80- " ## | but WITHOUT ANY WARRANTY; without even the implied warranty of |\n" \
81- " ## | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |\n" \
82- " ## | GNU General Public License for more details. |\n" \
83- " ## | |\n" \
84- " ## | You should have received a copy of the GNU General Public License |\n" \
85- " ## | along with this program. If not, see <http://www.gnu.org/licenses/>. |\n" \
86- " ## | |\n" \
87- " ## +-----------------------------------------------------------------------+\n" \
52+ else
53+ OUTPUT_SCRIPT=" $1 "
54+ OUTPUT_CONFIG_DIR=" $2 "
55+ fi
56+
57+
58+ # # DEFINE LOCAL VARIABLES
59+ DIR=$( cd " $( dirname " ${BASH_SOURCE[0]} " ) " > /dev/null 2>&1 && pwd )
60+ INPUT_SCRIPT=" $DIR /synth-shell-greeter/synth-shell-greeter.sh"
61+ INPUT_CONFIG_DIR=" $DIR /config/"
62+
63+
64+ # # HEADER TO BE ADDED AT THE TOP OF THE ASSEMBLED SCRIPT
65+ OUTPUT_SCRIPT_HEADER=$( printf ' %s' \
8866 " ##\n" \
8967 " ##\n" \
9068 " ## =======================\n" \
@@ -93,43 +71,31 @@ setup()
9371 " ## =======================\n" \
9472 " ##\n" \
9573 " ## This file was generated by an installation script.\n" \
96- " ## If you edit this file, it might be overwritten without warning\n" \
97- " ## and you might lose all your changes.\n" \
74+ " ## It might be overwritten without warning at any time \n" \
75+ " ## and you will lose all your changes.\n" \
9876 " ##\n" \
9977 " ## Visit for instructions and more information:\n" \
10078 " ## https://github.com/andresgongora/synth-shell/\n" \
79+ " ##\n" \
10180 " ##\n\n\n" )
10281
10382
104- # # SETUP SCRIPT
105- assembleScript " $input_script " " $output_script " " $output_script_header "
106-
107-
108- # # SETUP CONFIGURATION FILES
109- [ -d " $output_config_dir " ] || mkdir -p " $output_config_dir "
110- cp -r " $input_config_dir /." " $output_config_dir /"
111-
83+ # # SETUP SCRIPT
84+ assembleScript " $INPUT_SCRIPT " " $OUTPUT_SCRIPT " " $OUTPUT_SCRIPT_HEADER "
11285
113- # # SETUP DEFAULT SYNTH-SHELL-GREETER CONFIG FILE
114- local config_file=" $output_config_dir /synth-shell-greeter.config"
115- if [ ! -f " $config_file " ]; then
116- local distro=$( cat /etc/os-release | grep " ID=" | sed ' s/ID=//g' | head -n 1)
117- case " $distro " in
118- ' arch' ) cp " $output_config_dir /os/synth-shell-greeter.archlinux.config" " $config_file " ;;
119- ' manjaro' ) cp " $output_config_dir /os/synth-shell-greeter.manjaro.config" " $config_file " ;;
120- * ) cp " $output_config_dir /synth-shell-greeter.config.default" " $config_file " ;;
121- esac
122- fi
123- }
12486
87+ # # SETUP CONFIGURATION FILES
88+ [ -d " $OUTPUT_CONFIG_DIR " ] || mkdir -p " $OUTPUT_CONFIG_DIR "
89+ cp -r " $INPUT_CONFIG_DIR /." " $OUTPUT_CONFIG_DIR /"
12590
12691
127-
128-
129-
130- # #==============================================================================
131- # # SCRIPT
132- # #==============================================================================
133-
134- setup $@
135-
92+ # # SETUP DEFAULT SYNTH-SHELL-GREETER CONFIG FILE
93+ CONFIG_FILE=" $OUTPUT_CONFIG_DIR /synth-shell-greeter.config"
94+ if [ ! -f " $CONFIG_FILE " ]; then
95+ DISTRO=$( cat /etc/os-release | grep " ID=" | sed ' s/ID=//g' | head -n 1)
96+ case " $DISTRO " in
97+ ' arch' ) cp " $OUTPUT_CONFIG_DIR /os/synth-shell-greeter.archlinux.config" " $CONFIG_FILE " ;;
98+ ' manjaro' ) cp " $OUTPUT_CONFIG_DIR /os/synth-shell-greeter.manjaro.config" " $CONFIG_FILE " ;;
99+ * ) cp " $OUTPUT_CONFIG_DIR /synth-shell-greeter.config.default" " $CONFIG_FILE " ;;
100+ esac
101+ fi
0 commit comments