2021-10-30 11:27:37 -07:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2021-10-31 13:24:41 -07:00
|
|
|
# Setup script to move the rofi theme files to the correct location
|
|
|
|
# As well as set up the history database
|
2021-11-26 17:54:52 -08:00
|
|
|
######################
|
|
|
|
# DO NOT RUN AS ROOT #
|
|
|
|
######################
|
2022-01-03 00:00:03 -08:00
|
|
|
VERBOSE=0
|
2021-10-31 13:24:41 -07:00
|
|
|
|
2021-11-26 17:54:52 -08:00
|
|
|
log() {
|
2022-01-02 09:53:16 -08:00
|
|
|
if [[ "$VERBOSE" -eq 1 ]]; then
|
|
|
|
printf "%s\n" "$*"
|
|
|
|
fi
|
2021-11-26 17:54:52 -08:00
|
|
|
}
|
2021-11-01 11:57:22 -07:00
|
|
|
|
2022-01-03 00:00:03 -08:00
|
|
|
if [[ $# -ge 1 ]]; then
|
|
|
|
if [[ "$1" == "-v" || "$1" == "--verbose" ]]; then
|
|
|
|
VERBOSE=1
|
|
|
|
log "VERBOSE LOGGING ENABLED"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2022-01-02 23:18:38 -08:00
|
|
|
DB="history.sqlite3"
|
|
|
|
|
|
|
|
DIR="${XDG_CONFIG_HOME:-$HOME/.config}/aniwrapper"
|
|
|
|
MPV_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/mpv"
|
|
|
|
|
|
|
|
log "CONFIG DIR:" "$DIR"
|
|
|
|
log "MPV DIR:" "$MPV_DIR"
|
|
|
|
|
2021-11-26 17:54:52 -08:00
|
|
|
# executes aniwrapper setup
|
|
|
|
# 1. create the aniwrapper directory in $XDG_CONFIG_HOME
|
|
|
|
# 2. create history databases in $DIR
|
2022-01-06 02:00:37 -08:00
|
|
|
# 3. move theme files to $DIR/themes/
|
2021-11-26 17:54:52 -08:00
|
|
|
# 4. move skip-intro.lua into mpv/scripts folder
|
2021-12-30 11:57:53 -08:00
|
|
|
# 5. move the aniwrapper icon to $XDG_CONFIG_HOME/aniwrapper/ directory
|
2021-11-26 17:54:52 -08:00
|
|
|
run_setup() {
|
2022-01-02 09:53:16 -08:00
|
|
|
log "INSTALL DIR: $DIR"
|
2021-10-30 11:27:37 -07:00
|
|
|
|
2022-01-02 09:53:16 -08:00
|
|
|
if [[ ! -d "$DIR" ]]; then
|
|
|
|
log "Creating directory $DIR"
|
|
|
|
mkdir -p "$DIR"
|
|
|
|
log "Directory created"
|
|
|
|
fi
|
2021-11-26 17:54:52 -08:00
|
|
|
|
2022-01-08 15:34:18 -08:00
|
|
|
if [[ ! -f "$DIR/$DB" ]]; then
|
|
|
|
log "CREATING HISTORY DATABASE"
|
|
|
|
sqlite3 "$DIR/$DB" < sql/search_history_tbl.sql
|
|
|
|
sqlite3 "$DIR/$DB" < sql/watch_history_tbl.sql
|
|
|
|
sqlite3 "$DIR/$DB" < sql/file_history.sql
|
|
|
|
log "FINISHED CREATING DB"
|
|
|
|
fi
|
2021-10-30 11:27:37 -07:00
|
|
|
|
2022-01-06 02:00:37 -08:00
|
|
|
if [[ ! -d "$DIR/themes" ]]; then
|
|
|
|
log "themes directory does not exist in filesystem... Creating and moving themes"
|
|
|
|
mkdir -p "$DIR/themes"
|
|
|
|
cp themes/* "$DIR/themes/"
|
2022-01-02 09:53:16 -08:00
|
|
|
log "Theme files moved..."
|
|
|
|
fi
|
2021-10-31 13:24:41 -07:00
|
|
|
|
2022-01-02 09:53:16 -08:00
|
|
|
log "Creating mpv/scripts/ directory if it doesn't exist..."
|
|
|
|
mkdir -p "$MPV_DIR/scripts/"
|
|
|
|
if [[ ! -f "$MPV_DIR/scripts/skip-intro.lua" ]]; then
|
|
|
|
log "Moving skip-intro.lua into mpv scripts directory..."
|
|
|
|
cp lua/skip-intro.lua "$MPV_DIR/scripts/"
|
|
|
|
log "Moved skip-intro.lua into scripts directory..."
|
|
|
|
else
|
2022-01-02 23:18:38 -08:00
|
|
|
log "skip-intro.lua already exists in $XDG_CONFIG_HOME/mpv/scripts/... skipping"
|
2022-01-02 09:53:16 -08:00
|
|
|
fi
|
2021-12-30 11:57:53 -08:00
|
|
|
|
2022-01-02 09:53:16 -08:00
|
|
|
if [[ ! -d "$DIR/icons" ]]; then
|
|
|
|
log "Creating icons directory"
|
|
|
|
mkdir -p "$DIR/icons"
|
|
|
|
fi
|
|
|
|
cp .assets/icons/* "$DIR/icons/"
|
|
|
|
log "Installed icons in config directory..."
|
2021-11-26 17:54:52 -08:00
|
|
|
}
|
2021-11-01 00:23:51 -07:00
|
|
|
|
2021-12-30 20:00:49 -08:00
|
|
|
if run_setup; then
|
2022-01-02 09:53:16 -08:00
|
|
|
log "Setup Complete...."
|
2021-11-26 17:54:52 -08:00
|
|
|
else
|
2022-01-02 09:53:16 -08:00
|
|
|
printf "%s\n" "There was an error during setup"
|
|
|
|
exit 1
|
2021-11-26 17:54:52 -08:00
|
|
|
fi
|