paper-icon-theme/install-icon-theme.sh

169 lines
4.1 KiB
Bash
Raw Normal View History

2015-01-28 11:33:36 -05:00
#!/bin/bash
# -*- Mode: sh; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
#
# Authors:
2015-04-28 16:29:14 -04:00
# Sam Hewitt <sam@snwh.org>
2015-01-28 11:33:36 -05:00
#
# Description:
# An installation bash script for Paper Icon Theme
#
# Legal Stuff:
#
# This file is part of the Paper Icon Theme and is free software; you can redistribute it and/or modify it under
# the terms of the GNU Lesser General Public License as published by the Free Software
# Foundation; version 3.
#
# This file is part of the Paper Icon Theme and 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 Lesser 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 <https://www.gnu.org/licenses/lgpl-3.0.txt>
2015-12-02 11:42:30 -05:00
tabs 4
2015-01-28 11:33:36 -05:00
clear
2015-12-02 11:23:12 -05:00
echo '#-----------------------------------------#'
echo '# Paper Icon Theme Install Script #'
echo '#-----------------------------------------#'
2015-03-11 01:58:14 -04:00
show_question() {
echo -e "\033[1;34m$@\033[0m"
}
2015-12-02 11:42:30 -05:00
show_info() {
echo -e "\033[1;33m$@\033[0m"
}
show_success() {
2015-03-11 01:58:14 -04:00
echo -e "\033[1;32m$@\033[0m"
}
show_error() {
2015-12-02 11:42:30 -05:00
echo -e "\033[1;31m$@\033[m" 1>&2
2015-03-11 01:58:14 -04:00
}
2015-01-28 11:33:36 -05:00
function continue {
2015-03-11 01:58:14 -04:00
echo
show_question '\tDo you want to continue? (Y)es, (N)o : '
echo
read INPUT
2015-01-28 11:33:36 -05:00
case $INPUT in
[Yy]* ) main;;
[Nn]* ) exit 99;;
* ) echo; echo "Sorry, try again."; continue;;
esac
}
function main {
if [ "$UID" -eq "$ROOT_UID" ]; then
if [ -d /usr/share/icons/Paper ]; then
echo
2015-03-11 01:58:14 -04:00
show_question '\tFound an existing installation. Replace it? (Y)es, (N)o : '
echo
read INPUT
2015-01-28 11:33:36 -05:00
case $INPUT in
[Yy]* ) rm -Rf /usr/share/icons/Paper 2>/dev/null;;
[Nn]* );;
2015-12-02 11:42:30 -05:00
* ) show_error '\tSorry, try again.'; main;;
2015-01-28 11:33:36 -05:00
esac
fi
2015-03-11 01:58:14 -04:00
echo "Installing..."
2015-12-02 11:42:30 -05:00
cp -RH ./Paper/ /usr/share/icons/
2015-03-11 01:58:14 -04:00
chmod -R 755 /usr/share/icons/Paper
2015-12-02 11:42:30 -05:00
show_success "Installation complete!"
echo
2015-03-11 02:00:11 -04:00
echo "You will have to set your theme manually."
2015-03-11 01:58:14 -04:00
end
2015-01-28 11:33:36 -05:00
elif [ "$UID" -ne "$ROOT_UID" ]; then
if [ -d $HOME/.local/share/icons/Paper ]; then
echo
2015-03-11 01:58:14 -04:00
show_question '\tFound an existing installation. Replace it? (Y)es, (N)o : '
echo
read INPUT
2015-01-28 11:33:36 -05:00
case $INPUT in
[Yy]* ) rm -Rf "$HOME/.local/share/icons/Paper" 2>/dev/null;;
[Nn]* );;
2015-12-02 11:42:30 -05:00
* ) show_error '\tSorry, try again.'; main;;
2015-01-28 11:33:36 -05:00
esac
fi
2015-03-11 01:58:14 -04:00
echo "Installing..."
# .local/share/icons
if [ -d $HOME/.local/share/icons ]; then
2015-12-02 11:42:30 -05:00
cp -RH ./Paper/ $HOME/.local/share/icons/
2015-03-11 01:58:14 -04:00
else
mkdir -p $HOME/.local/share/icons
2015-12-02 11:42:30 -05:00
cp -RH ./Paper/ $HOME/.local/share/icons/
2015-02-24 19:47:40 -05:00
fi
2015-12-02 11:42:30 -05:00
show_success "Installation complete!"
echo
2015-12-02 11:23:12 -05:00
useicons
2015-01-28 11:33:36 -05:00
fi
}
2015-03-11 01:58:14 -04:00
2015-12-02 11:23:12 -05:00
function useicons {
2015-03-11 01:58:14 -04:00
echo
show_question '\tDo you want to set Paper as your icon theme? (Y)es, (N)o : '
echo
read INPUT
2015-01-28 11:33:36 -05:00
case $INPUT in
2015-12-02 11:23:12 -05:00
[Yy]* )
echo "Setting Paper as desktop icon theme..."
gsettings reset org.gnome.desktop.interface icon-theme
gsettings set org.gnome.desktop.interface icon-theme "Paper"
2015-12-02 11:42:30 -05:00
show_success "Complete."
2015-12-02 11:23:12 -05:00
usecursors
;;
[Nn]* ) usecursors;;
2015-12-02 11:42:30 -05:00
* ) echo; show_error "\aUh oh, invalid response. Please retry."; useicons;;
2015-01-28 11:33:36 -05:00
esac
}
2015-12-02 11:23:12 -05:00
function usecursors {
echo
show_question '\tDo you want to set Paper as your cursor theme? (Y)es, (N)o : '
echo
read INPUT
case $INPUT in
2015-12-02 11:42:30 -05:00
[Yy]* )
2015-12-02 11:23:12 -05:00
echo "Setting Paper as desktop cursor theme..."
gsettings reset org.gnome.desktop.interface cursor-theme
gsettings set org.gnome.desktop.interface cursor-theme "Paper"
2015-12-02 11:42:30 -05:00
show_success "Complete."
show_info "You may need to log out & back in for the cursor change to take effect."
2015-12-02 11:23:12 -05:00
end
;;
[Nn]* ) end;;
2015-12-02 11:42:30 -05:00
* ) echo; show_error "\aUh oh, invalid response. Please retry."; usecursors;;
2015-12-02 11:23:12 -05:00
esac
2015-01-28 11:33:36 -05:00
}
function end {
2015-12-02 11:42:30 -05:00
echo
show_info "\tAll done. Press any key to exit."
echo
read -n1
2015-01-28 11:33:36 -05:00
exit 0
}
ROOT_UID=0
if [ "$UID" -ne "$ROOT_UID" ]; then
echo
2015-12-02 11:42:30 -05:00
echo "Paper will be installed in your home directory:"
2015-03-11 01:58:14 -04:00
echo
2015-12-02 11:42:30 -05:00
show_info '\t$HOME/.local/share/icons'
2015-03-11 01:58:14 -04:00
echo
2015-01-28 11:33:36 -05:00
echo "To make them available to all users, run this script as root."
continue
else
echo
2015-12-02 11:42:30 -05:00
echo "Paper will be installed in for system-wide use:"
2015-03-11 01:58:14 -04:00
echo
2015-12-02 11:42:30 -05:00
show_info '\t/usr/share/icons'
2015-03-11 01:58:14 -04:00
echo
2015-01-28 11:33:36 -05:00
echo "It will be available to all users."
continue
2015-12-04 14:13:52 -05:00
fi