added support for theming in the install script
This commit is contained in:
@@ -1,10 +1,34 @@
|
||||
#!/bin/zsh
|
||||
|
||||
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
|
||||
|
||||
}
|
||||
|
||||
help() {
|
||||
@@ -28,14 +52,30 @@ error_missing_dependencies() {
|
||||
|
||||
success() {
|
||||
NAME=$1
|
||||
EXECUTABLE=$2
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
install_python() {
|
||||
NAME=$(name_executable $1)
|
||||
NAME=$1
|
||||
EXECUTABLE=$(name_executable $1)
|
||||
|
||||
# Get the current working directory and the virtual environment
|
||||
CWD=$(pwd)
|
||||
@@ -53,13 +93,27 @@ install_python() {
|
||||
|
||||
|
||||
# Create the executable
|
||||
sudo echo "#!/bin/zsh" > /usr/local/bin/$NAME
|
||||
sudo echo "\nsource $ENV" >> /usr/local/bin/$NAME
|
||||
sudo echo "$COMMAND" >> /usr/local/bin/$NAME
|
||||
sudo echo "#!/bin/zsh" > /usr/local/bin/$EXECUTABLE
|
||||
sudo echo "\nsource $ENV" >> /usr/local/bin/$EXECUTABLE
|
||||
sudo echo "$COMMAND" >> /usr/local/bin/$EXECUTABLE
|
||||
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() {
|
||||
@@ -77,19 +131,16 @@ install() {
|
||||
|
||||
case $PROJECT_TYPE in
|
||||
1)
|
||||
echo "C"
|
||||
echo "Need to implement"
|
||||
install_c "$PROJECT_NAME"
|
||||
;;
|
||||
2)
|
||||
install_python "$PROJECT_NAME"
|
||||
;;
|
||||
3)
|
||||
echo "Java"
|
||||
echo "Need to implement"
|
||||
install_java "$PROJECT_NAME"
|
||||
;;
|
||||
4)
|
||||
echo "Other"
|
||||
echo "Need to implement: have user specify the command/commands to run the project"
|
||||
install_other "$PROJECT_NAME"
|
||||
;;
|
||||
*)
|
||||
echo "Invalid option"
|
||||
@@ -133,8 +184,40 @@ check_sudo() {
|
||||
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_sudo
|
||||
check_theme
|
||||
|
||||
if [[ $# -gt 1 ]]; then
|
||||
echo "ERROR: There were too many arguments.\n"
|
||||
|
||||
Reference in New Issue
Block a user