add dracula type theme and update script to accept theme arg

This commit is contained in:
ksyasuda 2022-01-06 02:00:37 -08:00
parent ddf2de4fe8
commit 952519de8b
5 changed files with 293 additions and 32 deletions

View File

@ -186,13 +186,19 @@ aniwrapper -q
# Enable verbose logging
aniwrapper -v
# Choose rofi theme from presets
aniwrapper -t [aniwrapper (default)|dracula|hidpi]
# Specify starting directory for play_from_file mode, bypassing main menu
aniwrapper -f <starting_directory> (no trailing slash in path)
# Use ani-cli command-line mode (rofi disabled)
aniwrapper -c
# Download anime in command-line mode
aniwrapper -d
# All flags can be used in command-line mode as well
# All flags can be used in command-line mode as well (except -f)
# ex. The following command will launch aniwrapper in command-line download mode with quality selection
aniwrapper -cqd
```
@ -234,6 +240,9 @@ At the moment, the requirements are as follows:
# watch anime
ani-cli <query>
# verbose logging
ani-cli -v
# download anime
ani-cli -d <download_directory>
@ -243,6 +252,15 @@ ani-cli -H
# sync history across devices
ani-cli -s
# choose quality
ani-cli -q [high|normal (default)|low]
# choose rofi theme from presets
ani-cli -t [aniwrapper (default)|dracula|hidpi]
# Specify starting directory for play_from_file mode (does not work with -c)
ani-cli -f <starting_directory> (no trailing slash in path)
# run ani-cli in command-line mode (rofi disabled)
ani-cli -c
```

41
ani-cli
View File

@ -7,8 +7,10 @@ CFG_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/aniwrapper"
HISTORY_DB="$CFG_DIR/history.sqlite3"
ANIWRAPPER_ICON_PATH="$CFG_DIR/icons/icon-64.png"
MAISAN_ICON_PATH="$CFG_DIR/icons/MYsan.png"
ROFI_CFG="aniwrapper.rasi"
PLAYER_CMD="mpv -config-dir ${XDG_CONFIG_HOME:-$HOME/.config}/mpv"
ROFI_THEME="aniwrapper.rasi"
ROFI_CFG="$CFG_DIR/themes/$ROFI_THEME"
PLAYER_CMD="mpv"
THEMES="aniwrapper (default)|dracula|hidpi"
# dependencies: grep, sed, curl, video_player, rofi, sqlite3
# video_player ( needs to be able to play urls )
@ -378,7 +380,7 @@ find_media() {
span=$(generate_span "Current directory: $inp")
inputlist=$(generate_inputlist "$inp")
selection=$(rofi -dmenu -only-match -config "$CFG_DIR/$ROFI_CFG" \
selection=$(rofi -dmenu -only-match -config "$ROFI_CFG" \
-l 13 -i -sep '|' -mesg "$span" -p "Enter selection" <<< "${inputlist[@]}")
if [ -z "$selection" ] || [ "$selection" = "Quit" ]; then
@ -408,7 +410,7 @@ get_search_query() {
if [ -z "$*" ] && [ "$is_rofi" -eq 1 ]; then
query=$(rofi -dmenu -l 12 -p "Search Anime:" \
-mesg "$span" \
-config "$CFG_DIR/$ROFI_CFG" <<< "${hist[@]}")
-config "$ROFI_CFG" <<< "${hist[@]}")
# Remove the id from the query
query="${query//[1-9]*\. /}"
# query="${query// /}"
@ -469,7 +471,7 @@ anime_selection() {
# get the anime from indexed list
msg="<span foreground='peachpuff' style='italic' size='small' weight='normal'>Query: $query</span>"
user_input=$(printf "${menu[@]}" |
rofi -dmenu -config "$CFG_DIR/${ROFI_CFG}" \
rofi -dmenu -config "$ROFI_CFG" \
-a "$searched" \
-l 12 -i -p "Enter selection:" \
-mesg "$msg" -only-match)
@ -571,7 +573,7 @@ episode_selection() {
-a "$watch_history" \
-p "Select Episode [1, $last_ep_number]:" \
-mesg "$msg" \
-config "$CFG_DIR/${ROFI_CFG}"
-config "$ROFI_CFG"
)
ep_choice_start=$(printf '%s\n' "${choice}" | awk '{print $1}')
ep_choice_end=$(printf '%s\n' "${choice}" | awk '{print $NF}')
@ -704,7 +706,7 @@ is_rofi=1
is_download=0
download_dir="."
half_ep=0
while getopts 'hd:Hsvq:c-:f:' OPT; do
while getopts 'hd:Hsvq:c-:f:t:' OPT; do
case "$OPT" in
h)
help_text
@ -746,7 +748,30 @@ while getopts 'hd:Hsvq:c-:f:' OPT; do
scrape="file"
play_dir="$OPTARG"
;;
t)
theme="$OPTARG"
case "$theme" in
aniwrapper)
ROFI_THEME=aniwrapper.rasi
;;
dracula)
ROFI_THEME=aniwrapper-dracula.rasi
;;
hidpi)
ROFI_THEME=aniwrapper-hidpi.rasi
;;
default)
ROFI_THEME=aniwrapper.rasi
;;
*)
log "$1 not a valid theme file. Themes: [$THEMES]"
ROFI_THEME=aniwrapper.rasi
;;
esac
log "Setting theme for ani-cli -> $ROFI_THEME"
ROFI_CFG="$CFG_DIR/themes/$ROFI_THEME"
log "ROFI_CFG: $ROFI_CFG"
;;
*)
printf "%s\n" "Invalid option"
exit 1

View File

@ -8,9 +8,11 @@ set -Eeo pipefail
CMD="/usr/bin/ani-cli"
DEFAULT_DOWNLOAD="$HOME/Videos/sauce"
CFG_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/aniwrapper"
CFG_FILE="aniwrapper.rasi"
ROFI_THEME="aniwrapper.rasi"
CFG_FILE="$CFG_DIR/themes/$ROFI_THEME"
QUALITIES="1. high|2. normal (default)|3. low"
QUALITY=normal
THEMES="aniwrapper (default)|dracula|hidpi"
GET_QUALITY=0
VERBOSE=0
IS_ROFI=1
@ -19,6 +21,7 @@ IS_PLAY_FROM_FILE=0
quit="6. Quit"
options="1. Stream|2. Download|3. Continue|4. Play from File|5. Sync History|$quit"
theme=default
#############
# Functions #
@ -40,15 +43,17 @@ quit() {
}
run() {
if [[ "$GET_QUALITY" -eq 1 ]]; then
get_quality
else
log "QUALITY flag not set... using default -> $QUALITY"
if [[ "$IS_PLAY_FROM_FILE" -eq 0 ]]; then
if [[ "$GET_QUALITY" -eq 1 ]]; then
get_quality
else
log "QUALITY flag not set... using default -> $QUALITY"
fi
fi
if [[ "$VERBOSE" -eq 0 ]]; then
"$CMD" -q "$QUALITY" "$*"
"$CMD" -q "$QUALITY" -t "$theme" "$*"
else
"$CMD" -q "$QUALITY" -v "$*"
"$CMD" -q "$QUALITY" -t "$theme" -v "$*"
fi
}
@ -61,7 +66,7 @@ create_default_download() {
get_quality() {
if [ "$IS_ROFI" -eq 1 ]; then
selection=$(rofi -dmenu -config "$CFG_DIR/$CFG_FILE" \
selection=$(rofi -dmenu -config "$CFG_FILE" \
-l 3 -selected-row 1 \
-theme-str 'listview {columns: 1;}' -p "Choose video quality:" \
-sep '|' <<< "$QUALITIES")
@ -84,7 +89,7 @@ generate_span() {
########
# Main #
########
while getopts 'vhqcdf:-:' OPT; do
while getopts 'vhqcdf:-:t:' OPT; do
case "$OPT" in
h)
help_text
@ -110,6 +115,28 @@ while getopts 'vhqcdf:-:' OPT; do
log "Play from file flag set... skipping main menu"
log "PLAY_PATH: $play_path"
;;
t)
theme="$OPTARG"
log "custom theme provided: $theme"
case "$theme" in
aniwrapper)
log "Default theme chosen... doing nothing"
theme=default
;;
dracula)
log "Chaning theme to dracula..."
ROFI_THEME=aniwrapper-dracula.rasi
;;
hidpi)
ROFI_THEME=aniwrapper-hidpi.rasi
;;
*)
log "$1 not a valid theme file. Themes: [$THEMES]"
theme=default
;;
esac
CFG_FILE="$CFG_DIR/themes/$ROFI_THEME"
;;
*)
log "Invalid option"
exit 1
@ -118,6 +145,7 @@ while getopts 'vhqcdf:-:' OPT; do
done
log "CONFIG DIR: $CFG_DIR"
log "ROFI CFG: $CFG_FILE"
# Check if command-line flag is set
if [[ "$IS_ROFI" -eq 0 ]] && [[ "$IS_DOWNLOAD" -eq 0 ]]; then
@ -139,7 +167,7 @@ fi
# Main
# -------------------------------------------------------------------------------
choice=$(echo "${options[@]}" | rofi -dmenu -only-match -sep '|' \
-config "$CFG_DIR/$CFG_FILE" -l 6 -i -p "Aniwrapper")
-config "$CFG_FILE" -l 6 -i -p "Aniwrapper")
[ "$choice" == "$quit" ] && quit
@ -158,7 +186,7 @@ case "$selection" in
# download
# ---------------------------------------------------------------------------
log "Download anime"
dl_dir=$(rofi -dmenu -config "$CFG_DIR/$CFG_FILE" \
dl_dir=$(rofi -dmenu -config "$CFG_FILE" \
-l 1 -p "Enter download dir:")
# if dl_dir is none set to current directory
[ "$dl_dir" == "" ] && dl_dir="$DEFAULT_DOWNLOAD"
@ -178,10 +206,11 @@ case "$selection" in
# play
# ---------------------------------------------------------------------------
log "Play from file selected"
IS_PLAY_FROM_FILE=1
msg="Provide a valid path to a directory or leave blank to go with the default: $HOME/Videos/sauce/"
msg="$(printf '%s\n%s\n' "$msg" "The program will begin searching for media files from the supplied directory")"
span=$(generate_span "$msg")
play_dir=$(rofi -dmenu -config "$CFG_DIR/$CFG_FILE" \
play_dir=$(rofi -dmenu -config "$CFG_FILE" \
-l 1 -mesg "$span" -p "Enter path to starting directory:")
if [ -z "$play_dir" ]; then
create_default_download
@ -192,24 +221,24 @@ case "$selection" in
;;
5.)
log "Sync history database"
username=$(rofi -dmenu -config "$CFG_DIR/$CFG_FILE" \
username=$(rofi -dmenu -config "$CFG_FILE" \
-l 1 -p "Enter the username of the remote user:")
if [[ -z "$username" ]] || [[ "$username" == "" ]]; then
log "No username provided... exiting"
exit 1
fi
host=$(rofi -dmenu -config "$CFG_DIR/$CFG_FILE" \
host=$(rofi -dmenu -config "$CFG_FILE" \
-l 1 -p "Enter the host for the remote machine (eg 192.168.1.99):")
if [[ -z "$host" ]] || [[ "$host" == "" ]]; then
log "No host provided... exiting"
exit 1
fi
port=$(rofi -dmenu -config "$CFG_DIR/$CFG_FILE" \
port=$(rofi -dmenu -config "$CFG_FILE" \
-l 1 -p "Enter in the ssh port for remote machine or leave blank for default [22]:")
if [[ -z "$port" ]] || [[ "$port" == "" ]]; then
port=22
fi
keypath=$(rofi -dmenu -config "$CFG_DIR/$CFG_FILE" \
keypath=$(rofi -dmenu -config "$CFG_FILE" \
-l 1 -p "Enter path to private key (leave blank if not needed or if unsure):")
if [[ -z "$keypath" ]]; then

View File

@ -31,7 +31,7 @@ log "MPV DIR:" "$MPV_DIR"
# executes aniwrapper setup
# 1. create the aniwrapper directory in $XDG_CONFIG_HOME
# 2. create history databases in $DIR
# 3. move theme files to $DIR
# 3. move theme files to $DIR/themes/
# 4. move skip-intro.lua into mpv/scripts folder
# 5. move the aniwrapper icon to $XDG_CONFIG_HOME/aniwrapper/ directory
run_setup() {
@ -44,7 +44,6 @@ run_setup() {
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
@ -56,10 +55,10 @@ run_setup() {
log "file_history table created"
fi
# Move theme files and skip-intro script to correct locations
if [[ ! -f "$DIR/aniwrapper.rasi" ]]; then
log "aniwrapper.rasi does not exist in filesystem... Moving theme files"
cp themes/* "$DIR"/
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/"
log "Theme files moved..."
fi
@ -77,7 +76,6 @@ run_setup() {
log "Creating icons directory"
mkdir -p "$DIR/icons"
fi
# install aniwrapper icons
cp .assets/icons/* "$DIR/icons/"
log "Installed icons in config directory..."
}

View File

@ -0,0 +1,191 @@
configuration {
font: "Open Sans 15";
display-drun: "Dmenu";
scroll-method: 0;
disable-history: false;
sidebar-mode: true;
steal-focus: true;
}
* {
selected-normal-foreground: rgba ( 255, 147, 5, 100 % );
selected-normal-foreground: rgba ( 255, 147, 5, 100 % );
/* foreground: rgba ( 196, 203, 212, 100 % ); */
foreground: #ecbe7b;
normal-foreground: @foreground;
alternate-normal-background: rgba ( 45, 48, 59, 1 % );
red: #ff6c6b;
selected-urgent-foreground: rgba ( 249, 249, 249, 100 % );
blue: #1E90FF;
urgent-foreground: rgba ( 204, 102, 102, 100 % );
alternate-urgent-background: rgba ( 75, 81, 96, 90 % );
active-foreground: #bd93f9;
lightbg: rgba ( 238, 232, 213, 100 % );
selected-active-foreground: #1E90FF;
alternate-active-background: rgba ( 45, 48, 59, 95 % );
background: #282a36;
alternate-normal-foreground: @foreground;
normal-background: rgba ( 45, 48, 59, 1 % );
lightfg: rgba ( 88, 104, 117, 100 % );
selected-normal-background: rgba ( 24, 26, 32, 80 % );
spacing: 2;
separatorcolor: #44475a;
urgent-background: rgba ( 45, 48, 59, 15 % );
selected-urgent-background: rgba ( 165, 66, 66, 100 % );
alternate-urgent-foreground: @urgent-foreground;
background-color: rgba ( 0, 0, 0, 0 % );
alternate-active-foreground: @active-foreground;
active-background: rgba ( 29, 31, 33, 24 % );
selected-active-background: rgba ( 26, 28, 35, 100 % );
black: #464b55;
blackwidget: #262626;
magenta: #c678dd;
blue2: #51afef;
element-border: #44475a;
element-text: #bd93f9;
element-selected-background: #44475a;
element-selected-border: #ffb86c;
normal-active: #8be9fd;
prompt-text: #ff79c6;
input-text: #50fa7b;
}
window {
background-color: @background;
border: 5px;
border-radius: 7px;
border-color: #282a36;
anchor: center;
location: center;
padding: 25;
width: 80%;
}
listview {
lines: 12;
columns: 2;
}
mainbox {
border: 0;
padding: 2px;
}
message {
border: 0;
border-color: @separatorcolor;
padding: 1px ;
text-color: @active-foreground;
}
textbox {
border: 0;
text-color: @foreground;
background-color: @blackwidget;
}
listview {
border: 0;
dynamic: true;
fixed-height: 0;
spacing: 10px ;
scrollbar: false;
padding: 2px 0px 0px 0px;
margin: 0px 0px 1px 0px;
}
element {
border: 4px;
border-color: @element-border;
padding: 2px 15px;
margin: 1px;
}
element-text {
background-color: inherit;
text-color: @element-text;
}
element.normal.normal {
background-color: @normal-background;
text-color: @normal-foreground;
}
element.normal.urgent {
background-color: @urgent-background;
text-color: @urgent-foreground;
}
element.normal.active {
background-color: @active-background;
border-color: @normal-active;
text-color: @element-selected-border;
}
element.selected.normal {
background-color: @element-selected-background;
border-color: @element-selected-border;
text-color: @element-selected-border;
}
element.selected.urgent {
background-color: @selected-urgent-background;
text-color: @selected-urgent-foreground;
}
element.selected.active {
background-color: @element-selected-background;
text-color: @normal-active;
border-color: @element-selected-border;
}
scrollbar {
width: 4px ;
border: 0;
handle-color: @normal-foreground;
handle-width: 8px ;
padding: 0;
}
mode-switcher {
border: 2px 0px 0px ;
border-color: @separatorcolor;
}
button {
spacing: 0;
text-color: @normal-foreground;
}
button.selected {
background-color: @selected-normal-background;
text-color: @selected-normal-foreground;
}
inputbar {
spacing: 0;
text-color: @normal-foreground;
padding: 6px;
}
case-indicator {
spacing: 0;
text-color: @normal-foreground;
}
entry {
padding: 4px 8px;
spacing: 0;
text-color: @input-text;
}
prompt {
spacing: 0;
text-color: @prompt-text;
padding: 4px 0px;
}
inputbar {
children: [ prompt,textbox-prompt-colon,entry,case-indicator ];
padding: 15px 0px;
}
textbox-prompt-colon {
expand: false;
str: ":";
margin: 0px 0.3em 0em 0em ;
text-color: @prompt-text;
padding: 4px 0px;
}