#! /bin/bash # Fg42 - Emacs Editor for advance users # # Copyright (c) 2010-2022 Sameer Rahmani # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, version 2. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . set -e current=$(cd "$(dirname "$0")/." >/dev/null 2>&1 ; pwd -P) fg42_home="$current/.." # Coloring Functions info() { if [ "$1" ] then echo "[\033[01;32mINFO\033[00m]: $1" fi } error() { if [ "$1" ] then echo "[\033[01;31mERR\033[00m]: $1" fi } warn() { if [ "$1" ] then echo "[\033[01;33mWARN\033[00m]: $1" fi } install_fonts() { info "Downloading and installing fonts..." mkdir -p ~/.fonts wget "https://dl.fg42.org/fonts/0.1.0.tar.gz" -O ~/.fonts/fg42.tar.gz tar zxf ~/.fonts/fg42.tar.gz -C ~/.fonts --strip 1 cp -r "$fg42_home/share/fonts/vazir/*" ~/.fonts/ info "Font installation is done." } install_runners() { info "Creating the runner scripts..." cp "$current/templates/fg42" "$current/../fg42" cp "$current/templates/fg42-wm" "$current/../fg42-wm" if [[ "$OSTYPE" == "linux-gnu"* ]]; then sed -i "s'___FG42_HOME___'$fg42_home'" "$fg42_home/fg42" sed -i "s'___FG42_HOME___'$fg42_home'" "$fg42_home/fg42-wm" fi if [[ "$OSTYPE" == "darwin"* ]]; then sed -i'' -e "s'___FG42_HOME___'$fg42_home'" "$fg42_home/fg42" sed -i'' -e "s'___FG42_HOME___'$fg42_home'" "$fg42_home/fg42-wm" fi chmod +x "$fg42_home/fg42" chmod +x" $fg42_home/fg42-wm" info "Copying conifg file to ~/.fg42.el..." cp "$fg42_home/config/fg42.user.el" ~/.fg42.el info "Installing the runners..." sudo mkdir -p /usr/local/bin/ sudo rm -f /usr/local/bin/fg42 sudo rm -f /usr/local/bin/fg42-wm sudo ln -s "$fg42_home/fg42" /usr/local/bin/fg42 sudo ln -s "$fg42_home/fg42-wm" /usr/local/bin/fg42-wm if [[ "$OSTYPE" == "linux-gnu"* ]]; then info "Copying share files..." sudo mkdir -p /usr/share/fg42/ sudo mkdir -p /usr/local/share/applications sudo cp "$fg42_home/share/applications/fg42.desktop" /usr/local/share/applications sudo cp -r "$fg42_home/share/icons/hicolor/" /usr/local/share/icons sudo cp -r "$fg42_home/share/*" /usr/share/fg42/ sudo mkdir -p /usr/share/xsessions/ sudo cp -r "$fg42_home/share/xsessions/fg42.desktop" /usr/share/xsessions/ else info "Skipping share files since this is not a Linux env..." fi } install_extras() { if [[ "$OSTYPE" == "linux-gnu"* ]]; then info "Copying share files..." sudo mkdir -p /usr/share/fg42/ sudo cp "$fg42_home/share/applications/fg42.desktop" /usr/local/share/applications sudo cp -r "$fg42_home/share/icons/hicolor/" /usr/local/share/icons sudo cp -r "$fg42_home/share/*" /usr/share/fg42/ sudo cp -r "$fg42_home/share/xsessions/fg42.desktop" /usr/share/xsessions/ else info "Skipping share files since this is not a Linux env..." fi } eval "install_$1"