Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env bash
- #Generic installation script for BE::Shell
- #themes and configs by Hombremaledicto.
- #Initial release V.0.1
- #This script should not be executed as root
- if [ "$(id -u)" == "0" ]; then
- echo -e 'This script must be executed as normal user!!!\nI will now exit.'
- exit 1
- fi
- #Setting distro indipendent paths
- declare -r scriptDir="$( cd "$( dirname ${BASH_SOURCE[0]} )" && pwd )"
- declare -r kdeDir="`kde4-config --localprefix`/share/"
- declare -r themesDir="${kdeDir}/apps/be.shell/Themes"
- declare -r configFile="${kdeDir}/config/be.shell"
- #Test functions
- declare -f confirm
- declare -f copy
- declare -f isRunning
- declare -f choice
- declare -f main
- choice(){
- declare -a confList="$( ls -l "$scriptDir" | grep 'be.shell' | sed 's/.*\.//' )"
- echo -e "Please, select a theme from the list below:\n"
- for element in "${confList[@]}"; do
- printf "%s\n" "${confList[@]}"
- done
- echo -n "Enter your choice:"
- read -r -p "${1} " response
- case $response in
- Vertex|Lullaby)
- chosenConf="${scriptDir}/be.shell.$response"
- chosenTheme="${scriptDir}/Themes/$response"
- ;;
- *) return
- ;;
- esac
- }
- confirm (){
- read -r -p "${1} " response
- case $response in
- [yY][eE][sS]|[yY])
- true
- ;;
- *)
- false
- ;;
- esac
- }
- copy(){
- echo -e "$chosenConf\n$chosenTheme"
- local dateHour="$( date "+%Y%m%d%H%M%S" )"
- local oldTheme="$( cat "$configFile" | grep -Po "(?<=Theme=)[ A-Za-z0-9]*" )"
- #tar cvzf "${oldTheme}.${dateHour}" "${themesDir}/${oldTheme}" "${configFile}"
- if [[ ! -f "$configFile" ]]; then
- `cp "${scriptDir}/be.shell" "$configFile"`
- else
- confirm "Do you want to backup the existing theme and config? y/N:" && `tar -cf "${kdeDir}/apps/be.shell/$oldTheme.$dateHour" ${themesDir}/${oldTheme} ${configFile} &> /dev/null`
- fi
- if [[ ! -d "$themesDir" ]]; then
- `mkdir "$themesDir"`
- else
- if [[ ! -d "$themesDir/Vertex" ]]; then
- `cp -r "$chosenTheme" "$themesDir"`
- else
- echo "Theme is installed :-)"
- fi
- fi
- if [[ ! -f "$configFile" ]]; then
- echo "$configFile does not exist"
- else
- echo "$configFile exists in filesystem"
- fi
- }
- isRunning(){
- local pShell="plasma-desktop"
- local bShell="be.shell"
- if [[ -z `pidof "$pShell"` ]]; then
- if [[ ! -z `pidof "$bShell"` ]]; then
- confirm "I will now reload be.shell. Continue? [y/N]:" && `kquitapp "$bShell"; sleep 2; "$bShell" &> /dev/null`
- else
- confirm "Starting be.shell. Continue? [y/N]:" &&`"$bShell"`
- fi
- else
- confirm "I will now stop Plasma and start be.shell. Continue? [y/N]:" && `kquitapp "$pShell"; sleep 2; "$bShell" &> /dev/null`
- fi
- }
- main(){
- echo -e "\nInstallation Script for BE::Shell themes and configs by
- Hombremaledicto - https://github.com/Hombremaledicto/be.shell\n"
- choice
- copy
- isRunning
- echo "Done"
- }
- main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement