added support for theming in the install script
This commit is contained in:
@@ -1,10 +1,34 @@
|
|||||||
#!/bin/zsh
|
#!/bin/zsh
|
||||||
|
|
||||||
name_executable() {
|
name_executable() {
|
||||||
echo "The current name of the executable is $1"
|
read "?The current name of the executable is $1. Do you want to change it? (y/N)" CHOICE
|
||||||
|
|
||||||
|
if [[ $CHOICE == "y" || $CHOICE == "Y" ]]; then
|
||||||
|
read "?Enter the name of the executable: " NAME
|
||||||
|
echo $NAME
|
||||||
|
else
|
||||||
|
echo $1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
save_desktop_entry() {
|
||||||
|
if [[ "$OSTYPE" == "linux-gnu" ]]; then
|
||||||
|
NAME=$1
|
||||||
|
EXECUTABLE=$2
|
||||||
|
|
||||||
|
echo "Creating a desktop entry for the $NAME project...\n"
|
||||||
|
|
||||||
|
# Create the desktop entry
|
||||||
|
sudo echo "[Desktop Entry]" > /usr/share/applications/$NAME.desktop
|
||||||
|
sudo echo "Name=$NAME" >> /usr/share/applications/$NAME.desktop
|
||||||
|
sudo echo "Exec=$EXECUTABLE" >> /usr/share/applications/$NAME.desktop
|
||||||
|
sudo echo "Type=Application" >> /usr/share/applications/$NAME.desktop
|
||||||
|
sudo echo "\n# Auto-generated by the install script" >> /usr/share/applications/$NAME.desktop
|
||||||
|
else
|
||||||
|
echo "This operating system is not yet supported."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
read "?Enter the name of the executable: " NAME
|
|
||||||
echo $NAME
|
|
||||||
}
|
}
|
||||||
|
|
||||||
help() {
|
help() {
|
||||||
@@ -28,14 +52,30 @@ error_missing_dependencies() {
|
|||||||
|
|
||||||
success() {
|
success() {
|
||||||
NAME=$1
|
NAME=$1
|
||||||
|
EXECUTABLE=$2
|
||||||
|
|
||||||
echo "The $NAME project and it's dependencies have been successfully installed onto your system."
|
echo "The $NAME project and it's dependencies have been successfully installed onto your system."
|
||||||
echo "You can now run the project by typing $NAME into the terminal."
|
echo "You can now run the project by typing $EXECUTABLE into the terminal."
|
||||||
|
|
||||||
|
read "?Would you like to create a desktop entry for the $NAME project? (y/N): " CHOICE
|
||||||
|
|
||||||
|
if [[ $CHOICE == "y" || $CHOICE == "Y" ]]; then
|
||||||
|
save_desktop_entry $NAME $EXECUTABLE
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
install_c() {
|
||||||
|
NAME=$1
|
||||||
|
echo "\nOther languages and build systems are not yet supported."
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
install_python() {
|
install_python() {
|
||||||
NAME=$(name_executable $1)
|
NAME=$1
|
||||||
|
EXECUTABLE=$(name_executable $1)
|
||||||
|
|
||||||
# Get the current working directory and the virtual environment
|
# Get the current working directory and the virtual environment
|
||||||
CWD=$(pwd)
|
CWD=$(pwd)
|
||||||
@@ -53,13 +93,27 @@ install_python() {
|
|||||||
|
|
||||||
|
|
||||||
# Create the executable
|
# Create the executable
|
||||||
sudo echo "#!/bin/zsh" > /usr/local/bin/$NAME
|
sudo echo "#!/bin/zsh" > /usr/local/bin/$EXECUTABLE
|
||||||
sudo echo "\nsource $ENV" >> /usr/local/bin/$NAME
|
sudo echo "\nsource $ENV" >> /usr/local/bin/$EXECUTABLE
|
||||||
sudo echo "$COMMAND" >> /usr/local/bin/$NAME
|
sudo echo "$COMMAND" >> /usr/local/bin/$EXECUTABLE
|
||||||
sudo echo "\n# Auto-generated by the install script" >> /usr/local/bin/$NAME
|
sudo echo "\n# Auto-generated by the install script" >> /usr/local/bin/$NAME
|
||||||
sudo chmod +x /usr/local/bin/$NAME
|
sudo chmod +x /usr/local/bin/$EXECUTABLE
|
||||||
|
|
||||||
success $NAME
|
success "$NAME" "$EXECUTABLE"
|
||||||
|
}
|
||||||
|
|
||||||
|
install_java() {
|
||||||
|
NAME=$1
|
||||||
|
echo "Other languages and build systems are not yet supported."
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
install_other() {
|
||||||
|
NAME=$1
|
||||||
|
echo "Other languages and build systems are not yet supported."
|
||||||
|
|
||||||
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
install() {
|
install() {
|
||||||
@@ -77,19 +131,16 @@ install() {
|
|||||||
|
|
||||||
case $PROJECT_TYPE in
|
case $PROJECT_TYPE in
|
||||||
1)
|
1)
|
||||||
echo "C"
|
install_c "$PROJECT_NAME"
|
||||||
echo "Need to implement"
|
|
||||||
;;
|
;;
|
||||||
2)
|
2)
|
||||||
install_python "$PROJECT_NAME"
|
install_python "$PROJECT_NAME"
|
||||||
;;
|
;;
|
||||||
3)
|
3)
|
||||||
echo "Java"
|
install_java "$PROJECT_NAME"
|
||||||
echo "Need to implement"
|
|
||||||
;;
|
;;
|
||||||
4)
|
4)
|
||||||
echo "Other"
|
install_other "$PROJECT_NAME"
|
||||||
echo "Need to implement: have user specify the command/commands to run the project"
|
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Invalid option"
|
echo "Invalid option"
|
||||||
@@ -133,8 +184,40 @@ check_sudo() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
check_theme() {
|
||||||
|
if ! -d ~/.config
|
||||||
|
then
|
||||||
|
echo "Creating the ~/.config directory..."
|
||||||
|
su $SUDO_USER -c "mkdir ~/.config"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! -d ~/.config/theme
|
||||||
|
then
|
||||||
|
echo "Creating the ~/.config/theme directory..."
|
||||||
|
su $SUDO_USER -c "mkdir ~/.config/theme"
|
||||||
|
fi
|
||||||
|
|
||||||
|
THEME_DIR=~/.config/theme
|
||||||
|
|
||||||
|
if ! -f ~/.config/theme/active.theme
|
||||||
|
then
|
||||||
|
su $SUDO_USER -c "touch $THEME_DIR/light.theme"
|
||||||
|
echo "base=#C6CAED" > $THEME_DIR/light.theme
|
||||||
|
echo "accent=#4D5382" >> $THEME_DIR/light.theme
|
||||||
|
echo "hover=#262940" >> $THEME_DIR/light.theme
|
||||||
|
|
||||||
|
su $SUDO_USER -c "touch $THEME_DIR/dark.theme"
|
||||||
|
echo "base=#262940" > $THEME_DIR/dark.theme
|
||||||
|
echo "accent=#4D5382" >> $THEME_DIR/dark.theme
|
||||||
|
echo "hover=#C6CAED" >> $THEME_DIR/dark.theme
|
||||||
|
|
||||||
|
su $SUDO_USER -c "ln -s $THEME_DIR/dark.theme $THEME_DIR/active.theme"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
check_args() {
|
check_args() {
|
||||||
check_sudo
|
check_sudo
|
||||||
|
check_theme
|
||||||
|
|
||||||
if [[ $# -gt 1 ]]; then
|
if [[ $# -gt 1 ]]; then
|
||||||
echo "ERROR: There were too many arguments.\n"
|
echo "ERROR: There were too many arguments.\n"
|
||||||
|
|||||||
Reference in New Issue
Block a user