|
|
|
#!/bin/bash
|
|
|
|
###
|
|
|
|
# This file is part of the code-cloppers openbox setup. Use at your own risk.
|
|
|
|
#
|
|
|
|
# This script should setup openbox for a user on ubuntu
|
|
|
|
|
|
|
|
set -eo pipefail
|
|
|
|
|
|
|
|
is-in-path() {
|
|
|
|
which "$1" &>>/dev/null
|
|
|
|
}
|
|
|
|
|
|
|
|
install-apt-dependencies() {
|
|
|
|
echo "=> Installing apt dependencies"
|
|
|
|
set -x
|
|
|
|
sudo apt-get update && \
|
|
|
|
sudo apt-get install xcompmgr openbox albert plank dunst numix-icon-theme-circle
|
|
|
|
set +x
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
are-in-path() {
|
|
|
|
[[ $# -gt 0 ]] || return 0
|
|
|
|
is-in-path "$1" || return 1
|
|
|
|
shift
|
|
|
|
are-in-path "$@"
|
|
|
|
}
|
|
|
|
|
|
|
|
install-dependencies() {
|
|
|
|
echo "=> Checking dependencies"
|
|
|
|
if ! are-in-path xcompmgr openbox dunst || ! [[ -d /usr/share/icons/Numix-Circle ]]; then
|
|
|
|
install-apt-dependencies
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
here() {
|
|
|
|
dirname "$(readlink -f "${BASH_SOURCE[0]}")"
|
|
|
|
}
|
|
|
|
|
|
|
|
config-dir() {
|
|
|
|
if ! [[ $# -ge 1 ]]; then
|
|
|
|
echo "$(caller) Expected argument" >&2
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
declare app="$1"
|
|
|
|
echo "$HOME/.config/$app"
|
|
|
|
}
|
|
|
|
|
|
|
|
create-dir-if-not-exists() {
|
|
|
|
[[ -d $1 ]] || mkdir -p "$1"
|
|
|
|
}
|
|
|
|
|
|
|
|
copy-files-in-dir-to() {
|
|
|
|
declare source="$1" destination="$2"
|
|
|
|
create-dir-if-not-exists "$destination"
|
|
|
|
cp -r "$source/"* "$destination"/
|
|
|
|
}
|
|
|
|
|
|
|
|
copy-config() {
|
|
|
|
echo "=> Copying config"
|
|
|
|
|
|
|
|
copy-files-in-dir-to "$(here)/config/albert" "$(config-dir albert)"
|
|
|
|
copy-files-in-dir-to "$(here)/config/openbox" "$(config-dir openbox)"
|
|
|
|
copy-files-in-dir-to "$(here)/config/dunst" "$(config-dir dunst)"
|
|
|
|
}
|
|
|
|
|
|
|
|
add-custom-startup() {
|
|
|
|
declare startup_file=''
|
|
|
|
read -rep "Please provide a path to a custom startup script for your sessions (default: ~/.startup):" \
|
|
|
|
startup_file
|
|
|
|
|
|
|
|
[[ -z $startup_file ]] && startup_file="$HOME/.startup"
|
|
|
|
printf 'source "%s"\n' "$startup_file" >> "$(config-dir openbox)/autostart.sh"
|
|
|
|
}
|
|
|
|
|
|
|
|
ppa-has-been-added() {
|
|
|
|
declare ppa="$1"
|
|
|
|
grep -q "^deb .*$ppa" /etc/apt/sources.list /etc/apt/sources.list.d/*
|
|
|
|
}
|
|
|
|
|
|
|
|
add-ppa-if-not-added() {
|
|
|
|
declare ppa="$1"
|
|
|
|
if ! ppa-has-been-added "$ppa"; then
|
|
|
|
printf 'Adding ppa "%s"\n' "$ppa"
|
|
|
|
sudo add-apt-repository "ppa:$ppa"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
add-ppas() {
|
|
|
|
add-ppa-if-not-added 'nilarimogard/webupd8'
|
|
|
|
add-ppa-if-not-added 'numix/ppa'
|
|
|
|
}
|
|
|
|
|
|
|
|
setup-openbox-for-user() {
|
|
|
|
add-ppas
|
|
|
|
install-dependencies
|
|
|
|
copy-config
|
|
|
|
add-custom-startup
|
|
|
|
|
|
|
|
echo "=> Finished"
|
|
|
|
}
|
|
|
|
|
|
|
|
setup-openbox-for-user
|