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 #
|
|
|
|
######################
|
|
|
|
VERBOSE=0
|
2021-10-30 11:27:37 -07:00
|
|
|
|
|
|
|
DB="history.sqlite3"
|
2021-10-31 13:24:41 -07:00
|
|
|
|
2021-11-02 10:09:02 -07:00
|
|
|
# Set the XDG_CONFIG_HOME locally if not set
|
2021-11-01 03:16:38 -07:00
|
|
|
if [[ -z "$XDG_CONFIG_HOME" ]]; then
|
2021-11-02 10:09:02 -07:00
|
|
|
XDG_CONFIG_HOME="$HOME/.config"
|
2021-11-01 03:16:38 -07:00
|
|
|
fi
|
2021-10-31 13:24:41 -07:00
|
|
|
|
2021-11-08 00:37:24 -08:00
|
|
|
DIR="$XDG_CONFIG_HOME/aniwrapper"
|
2021-11-02 10:09:02 -07:00
|
|
|
MPV_DIR="$XDG_CONFIG_HOME/mpv"
|
2021-10-31 13:24:41 -07:00
|
|
|
|
2021-11-26 17:54:52 -08:00
|
|
|
log() {
|
|
|
|
if [[ "$VERBOSE" -eq 1 ]]; then
|
|
|
|
printf "%s\n" "$*"
|
|
|
|
fi
|
|
|
|
}
|
2021-11-01 11:57:22 -07:00
|
|
|
|
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
|
|
|
|
# 3. move theme files to $DIR
|
|
|
|
# 4. move skip-intro.lua into mpv/scripts folder
|
|
|
|
run_setup() {
|
|
|
|
log "INSTALL DIR: $DIR"
|
2021-10-30 11:27:37 -07:00
|
|
|
|
2021-11-26 17:54:52 -08:00
|
|
|
if [[ ! -d "$DIR" ]]; then
|
|
|
|
log "Creating directory $DIR"
|
|
|
|
mkdir -p "$DIR"
|
|
|
|
log "Directory created"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ ! -f "$DIR"/"$DB" ]]; then
|
|
|
|
# Create the DB if not exists
|
|
|
|
log "Creating history database..."
|
|
|
|
sqlite3 "$DIR"/"$DB" <sql/watch_history_tbl.sql
|
|
|
|
sqlite3 "$DIR"/"$DB" <sql/search_history_tbl.sql
|
|
|
|
log "History database created..."
|
|
|
|
fi
|
2021-10-30 11:27:37 -07:00
|
|
|
|
2021-11-26 17:54:52 -08:00
|
|
|
# Move theme files and skip-intro script to correct locations
|
|
|
|
log "Moving theme files..."
|
|
|
|
cp themes/* "$DIR"/
|
|
|
|
log "Theme files moved..."
|
2021-10-31 13:24:41 -07:00
|
|
|
|
2021-11-26 17:54:52 -08:00
|
|
|
log "Creating mpv/scripts/ directory if it doesn't exist..."
|
|
|
|
mkdir -p "$MPV_DIR/scripts/"
|
|
|
|
log "Created mpv scripts directory..."
|
|
|
|
log "Moving .lua into mpv scripts directory..."
|
|
|
|
cp lua/* "$MPV_DIR/scripts/"
|
|
|
|
# cp skip-intro.lua "$MPV_DIR/scripts/skip-intro.lua"
|
|
|
|
log "Moved skip-intro.lua into scripts directory..."
|
|
|
|
}
|
2021-11-01 00:23:51 -07:00
|
|
|
|
2021-11-26 17:54:52 -08:00
|
|
|
if [[ ! -d "$DIR" ]]; then
|
|
|
|
if run_setup; then
|
|
|
|
log "Setup Complete...."
|
|
|
|
else
|
|
|
|
printf "%s\n" "There was an error during setup"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
log "Directory exists... skipping setup"
|
|
|
|
exit 0
|
|
|
|
fi
|