From ccb4e7afbb7bcd95acdb5e163753d27b958f7d0c Mon Sep 17 00:00:00 2001 From: Sam Hewitt Date: Wed, 11 Mar 2015 01:53:39 -0400 Subject: [PATCH] Updated install script --- install.sh | 83 +++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 64 insertions(+), 19 deletions(-) diff --git a/install.sh b/install.sh index f717bdb..e3990db 100755 --- a/install.sh +++ b/install.sh @@ -26,9 +26,24 @@ echo '#-----------------------------------------#' echo '# Paper GTK Theme Install Script #' echo '#-----------------------------------------#' + +show_question() { +echo -e "\033[1;34m$@\033[0m" +} + +show_dir() { +echo -e "\033[1;32m$@\033[0m" +} + +show_error() { +echo -e "\033[1;31m$@\033[0m" +} + function continue { -echo "" -read -p "Do you want to continue? (Y)es, (N)o : " INPUT +echo +show_question '\tDo you want to continue? (Y)es, (N)o : ' +echo +read INPUT case $INPUT in [Yy]* ) main;; [Nn]* ) exit 99;; @@ -40,33 +55,32 @@ function main { if [ "$UID" -eq "$ROOT_UID" ]; then if [ -d /usr/share/themes/Paper ]; then echo - read -p "Found an existing installation. Replace it? (Y)es, (N)o : " INPUT + show_question '\tFound an existing installation. Replace it? (Y)es, (N)o : ' + echo + read INPUT case $INPUT in [Yy]* ) rm -Rf /usr/share/themes/Paper 2>/dev/null;; [Nn]* );; - * ) - clear && echo 'Sorry, try again.' - main - ;; + * ) clear; show_error '\tSorry, try again.'; main;; esac fi + echo "Installing..." cp -R ./Paper/ /usr/share/themes/ chmod -R 755 /usr/share/themes/Paper echo "Installation complete!" - set elif [ "$UID" -ne "$ROOT_UID" ]; then if [ -d $HOME/.local/share/themes/Paper ]; then echo - read -p "Found an existing installation. Replace it? (Y)es, (N)o : " INPUT + show_question '\tFound an existing installation. Replace it? (Y)es, (N)o : ' + echo + read INPUT case $INPUT in [Yy]* ) rm -Rf "$HOME/.local/share/themes/Paper" 2>/dev/null;; [Nn]* );; - * ) - clear && echo 'Sorry, try again.' - main - ;; + * ) clear; show_error '\tSorry, try again.'; main;; esac fi + echo "Installing..." # .local/share/themes if [ -d $HOME/.local/share/themes ]; then cp -R ./Paper/ $HOME/.local/share/themes/ @@ -82,25 +96,49 @@ elif [ "$UID" -ne "$ROOT_UID" ]; then cp -R ./Paper/ $HOME/.local/share/themes/ fi echo "Installation complete!" + set fi } + + function set { -echo "" -read -p "Do you want to set Paper as desktop theme? (Y)es, (N)o : " INPUT +echo +show_question '\tDo you want to set Paper as desktop theme? (Y)es, (N)o : ' +echo +read INPUT case $INPUT in [Yy]* ) settheme;; [Nn]* ) end;; - * ) echo; echo "Uh oh, invalid response. Please retry."; set;; + * ) echo; show_error "\aUh oh, invalid response. Please retry."; set;; esac } function settheme { echo "Setting Paper as desktop GTK theme..." +gsettings reset org.gnome.desktop.interface gtk-theme +gsettings reset org.gnome.desktop.wm.preferences theme gsettings set org.gnome.desktop.interface gtk-theme "Paper" gsettings set org.gnome.desktop.wm.preferences theme "Paper" echo "Done." -end +setthemegnome +} + +function setthemegnome { +if [ -d /usr/share/gnome-shell/extensions/user-theme@gnome-shell-extensions.gcampax.github.com/ ]; then + echo + show_question '\tWould you like to use Paper as your GNOME Shell theme? (Y)es, (N)o : ' + echo + read INPUT + case $INPUT in + [Yy]* ) gsettings set org.gnome.shell.extensions.user-theme name "Paper";; + [Nn]* ) end;; + * ) echo; show_error "\aUh oh, invalid response. Please retry."; set;; + esac + end +else + end +fi } function end { @@ -108,15 +146,22 @@ function end { exit 0 } + ROOT_UID=0 if [ "$UID" -ne "$ROOT_UID" ]; then echo - echo "Paper GTK Theme will be installed in '$HOME/.local/share/themes/Paper'." + echo "Paper GTK Theme will be installed in:" + echo + show_dir '\t$HOME/.local/share/themes' + echo echo "To make them available to all users, run this script as root." continue else echo - echo "Paper GTK Theme will be installed in '/usr/share/themes'" + echo "Paper GTK Theme will be installed in:" + echo + show_dir '\t/usr/share/themes' + echo echo "It will be available to all users." continue fi \ No newline at end of file