This repository was archived by the owner on Aug 11, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·66 lines (53 loc) · 1.75 KB
/
install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/bash
# Scripts are stored in ~/bin
# To access add the following line to .bashrc/bash_profile
# export PATH=~/bin:$PATH
sourceFolder="$(pwd)"
linkFolder="$HOME/.local/bin"
desktopSource="$sourceFolder/desktop_files"
desktopDest="$HOME/.local/share/applications"
iconSource="$sourceFolder/icons"
iconDest="$HOME/.local/share/icons"
# Takes full path then root path
between_root_and_ext () {
fullPath="$1"
rootPath="$2"
noRootWithExt="${fullPath#$rootPath}"
noRootOrExt="${noRootWithExt%.*}"
echo "$noRootOrExt"
}
install_scripts () {
mkdir -p "$linkFolder"
for script in ./*.sh
do
script=${script:2}
scriptTitle="$(between_root_and_ext '$script' '$sourceFolder')"
if [ "$script" != *install.sh ] ; then
echo -n "Do you want to link $script? [y/N]: "
read install
if [[ "$install" = Y ]] || [[ "$install" == y ]] ; then
ln -s "$sourceFolder/$script" "$linkFolder/$scriptTitle"
fi
fi
done
}
install_dot_desktop () {
mkdir -p "$desktopDest"
mkdir -p "$iconDest"
for desktop in "$desktopSource/"*.desktop
do
desktopTitle="$(between_root_and_ext '$desktop' '$desktopSource')"
desktopTitle="${desktopTitle:1}"
echo -n "Would you like to link $desktopTitle.desktop? [y/N]: "
read install
if [[ "$install" == Y ]] || [[ "$install" == y ]] ; then
ln -s "$desktopSource/$desktopTitle.desktop" \
"$desktopDest/$desktopTitle.desktop"
ln -s "$iconSource/$desktopTitle.png" "$iconDest/$desktopTitle.png"
fi
done
}
# main
install_scripts
install_dot_desktop
echo "Install complete. Note that \$PATH must include \$HOME/bin for scripts to be accessed."