add handling for default and custom themes in scripts

This commit is contained in:
ksyasuda 2022-01-06 19:34:24 -08:00
parent f52e0eeafd
commit 0b2e28f2fd
5 changed files with 58 additions and 360 deletions

33
ani-cli
View File

@ -10,7 +10,7 @@ MAISAN_ICON_PATH="$CFG_DIR/icons/MYsan.png"
ROFI_THEME="aniwrapper.rasi"
ROFI_CFG="$CFG_DIR/themes/$ROFI_THEME"
PLAYER_CMD="mpv"
THEMES="aniwrapper (default)|dracula|hidpi"
THEMES="aniwrapper (default)|dracula|fancy|flamingo|material|onedark"
# dependencies: grep, sed, curl, video_player, rofi, sqlite3
# video_player ( needs to be able to play urls )
@ -737,7 +737,7 @@ is_rofi=1
is_download=0
download_dir="."
half_ep=0
while getopts 'hd:Hsvq:c-:f:t:' OPT; do
while getopts 'hd:Hsvq:c-:f:t:T:' OPT; do
case "$OPT" in
h)
help_text
@ -785,24 +785,37 @@ while getopts 'hd:Hsvq:c-:f:t:' OPT; do
aniwrapper)
ROFI_THEME=aniwrapper.rasi
;;
dracula)
ROFI_THEME=aniwrapper-dracula.rasi
;;
hidpi)
ROFI_THEME=aniwrapper-hidpi.rasi
;;
default)
ROFI_THEME=aniwrapper.rasi
;;
dracula)
ROFI_THEME=aniwrapper-dracula.rasi
;;
fancy)
ROFI_THEME=aniwrapper-fancy.rasi
;;
flamingo)
ROFI_THEME=aniwrapper-flamingo.rasi
;;
material)
ROFI_THEME=aniwrapper-material.rasi
;;
onedark)
ROFI_THEME=aniwrapper-onedark.rasi
;;
*)
log "$1 not a valid theme file. Themes: [$THEMES]"
ROFI_THEME=aniwrapper.rasi
die "$theme not a valid theme file. Themes: [$THEMES]"
;;
esac
log "Setting theme for ani-cli -> $ROFI_THEME"
ROFI_CFG="$CFG_DIR/themes/$ROFI_THEME"
log "ROFI_CFG: $ROFI_CFG"
;;
T)
ROFI_CFG="$OPTARG"
[ ! -f "$ROFI_CFG" ] && die "$ROFI_CFG does not exist"
log "CUSTOM ROFI_CFG: $ROFI_CFG"
;;
*)
printf "%s\n" "Invalid option"
exit 1

View File

@ -12,12 +12,13 @@ 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"
THEMES="aniwrapper (default)|dracula|fancy|flamingo|material|onedark"
GET_QUALITY=0
VERBOSE=0
IS_ROFI=1
IS_DOWNLOAD=0
IS_PLAY_FROM_FILE=0
IS_CUSTOM_THEME=0
quit="6. Quit"
options="1. Stream|2. Download|3. Continue|4. Play from File|5. Sync History|$quit"
@ -43,17 +44,17 @@ quit() {
}
run() {
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
if [[ "$IS_PLAY_FROM_FILE" -eq 0 ]] && [[ "$GET_QUALITY" -eq 1 ]]; then
get_quality
fi
if [[ "$VERBOSE" -eq 0 ]]; then
"$CMD" -q "$QUALITY" -t "$theme" "$*"
if [[ "$IS_CUSTOM_THEME" -eq 1 ]] && [[ "$VERBOSE" -eq 0 ]]; then
"$CMD" -q "$QUALITY" -T "$CFG_FILE" "$@"
elif [[ "$IS_CUSTOM_THEME" -eq 1 ]] && [[ "$VERBOSE" -eq 1 ]]; then
"$CMD" -vq "$QUALITY" -T "$CFG_FILE" "$@"
elif [[ "$VERBOSE" -eq 0 ]]; then
"$CMD" -q "$QUALITY" -t "$theme" "$@"
else
"$CMD" -q "$QUALITY" -t "$theme" -v "$*"
"$CMD" -vq "$QUALITY" -t "$theme" "$@"
fi
}
@ -89,7 +90,7 @@ generate_span() {
########
# Main #
########
while getopts 'vhqcdf:-:t:' OPT; do
while getopts 'vhqcdf:-:t:T:' OPT; do
case "$OPT" in
h)
help_text
@ -124,19 +125,31 @@ while getopts 'vhqcdf:-:t:' OPT; do
theme=default
;;
dracula)
log "Chaning theme to dracula..."
ROFI_THEME=aniwrapper-dracula.rasi
;;
hidpi)
ROFI_THEME=aniwrapper-hidpi.rasi
fancy)
ROFI_THEME=aniwrapper-fancy.rasi
;;
flamingo)
ROFI_THEME=aniwrapper-flamingo.rasi
;;
material)
ROFI_THEME=aniwrapper-material.rasi
;;
onedark)
ROFI_THEME=aniwrapper-onedark.rasi
;;
*)
log "$1 not a valid theme file. Themes: [$THEMES]"
theme=default
seppuku "$theme not a valid theme file. Themes: [$THEMES]"
;;
esac
CFG_FILE="$CFG_DIR/themes/$ROFI_THEME"
;;
T)
CFG_FILE="$OPTARG"
[ ! -f "$CFG_FILE" ] && seppuku "config file $CFG_FILE does not exist"
IS_CUSTOM_THEME=1
;;
*)
log "Invalid option"
exit 1
@ -158,8 +171,11 @@ elif [[ "$IS_ROFI" -eq 0 ]] && [[ "$IS_DOWNLOAD" -eq 1 ]]; then
[ -d "$dl_dir" ] && mkdir -p "$dl_dir" || dir "Error creating directory: $dl_dir"
run "-cd $dl_dir"
exit $?
elif [[ "$IS_ROFI" -eq 1 ]] && [[ "$IS_PLAY_FROM_FILE" -eq 1 ]]; then
run -f"$play_path"
elif [[ "$IS_ROFI" -eq 1 ]] && [[ "$IS_PLAY_FROM_FILE" -eq 1 ]] && [[ "$IS_CUSTOM_THEME" -eq 1 ]]; then
run "-f$play_path" -T "$CFG_FILE"
exit $?
elif [[ "$IS_ROFI" -eq 1 ]] && [[ "$IS_PLAY_FROM_FILE" -eq 1 ]] && [[ "$IS_CUSTOM_THEME" -eq 0 ]]; then
run "-f$play_path"
exit $?
fi

View File

@ -49,7 +49,7 @@ run_setup() {
sqlite3 "$DIR/$DB" < sql/search_history_tbl.sql
sqlite3 "$DIR/$DB" < sql/file_history.sql
log "History database created..."
elif ! sqlite3 -noheader -batch "$DIR/$DB" ".tables" | grep 'file_history'; then
elif ! sqlite3 -noheader -batch "$DIR/$DB" ".tables" | grep -q 'file_history'; then
log "file_history table not found in database... creating table"
sqlite3 "$DIR/$DB" < sql/file_history.sql
log "file_history table created"

View File

@ -1,199 +0,0 @@
configuration {
font: "Open Sans 15";
display-drun: "Dmenu";
scroll-method: 0;
disable-history: false;
sidebar-mode: true;
steal-focus: true;
dpi: 196;
}
* {
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: #51afef;
lightbg: rgba ( 238, 232, 213, 100 % );
selected-active-foreground: #1E90FF;
alternate-active-background: rgba ( 45, 48, 59, 95 % );
background: #282c34;
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: rgba ( 45, 48, 59, 1 % );
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;
}
window {
background-color: @background;
border: 10px;
border-radius: 7px;
border-color: #2C4762;
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: 5px 0px 0px 0px;
margin: 0px 0px 1px 0px;
}
element {
border: 8px;
border-color: #d19a66;
padding: 5px 15px;
margin: 6px;
}
element-text {
background-color: inherit;
text-color: inherit;
}
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: @blue;
text-color: @blue;
}
element.selected.normal {
background-color: @selected-normal-background;
border-color: #ecbe7b;
text-color: #1E90FF;
}
element.selected.urgent {
background-color: @selected-urgent-background;
text-color: @selected-urgent-foreground;
}
element.selected.active {
background-color: @selected-active-background;
text-color: @blue2;
border-color: @blue2;
text-color: #1E90FF;
}
element.alternate.normal {
background-color: @alternate-normal-background;
text-color: @alternate-normal-foreground;
}
element.alternate.urgent {
background-color: @alternate-urgent-background;
text-color: @alternate-urgent-foreground;
}
element.alternate.active {
background-color: @alternate-active-background;
border-color: @blue;
text-color: @blue;
}
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: #1E90FF;
}
prompt {
spacing: 0;
text-color: #c678dd;
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: #c678dd;
padding: 4px 0px;
}

View File

@ -1,132 +0,0 @@
/**
* User: deadguy
* Copyright: deadguy
*/
configuration {
display-drun: "Activate";
display-run: "Execute";
display-window: "Window";
show-icons: true;
sidebar-mode: true;
}
* {
background-color: #282a36;
text-color: #d3d7cf;
selbg: #215d9c;
actbg: #262626;
urgbg: #e53935;
winbg: #26c6da;
selected-normal-foreground: @winbg;
normal-foreground: @text-color;
selected-normal-background: @actbg;
normal-background: @background-color;
selected-urgent-foreground: @background-color;
urgent-foreground: @text-color;
selected-urgent-background: @urgbg;
urgent-background: @background-color;
selected-active-foreground: @winbg;
active-foreground: @text-color;
selected-active-background: @actbg;
active-background: @selbg;
line-margin: 2;
line-padding: 2;
separator-style: "none";
hide-scrollbar: "true";
margin: 0;
padding: 0;
}
window {
location: west;
anchor: west;
height: 100%;
width: 24%; /* kobe */
orientation: horizontal;
children: [mainbox];
}
mainbox {
spacing: 0.8em;
children: [ entry,listview,mode-switcher ];
}
button { padding: 5px 2px; }
button selected {
background-color: @active-background;
text-color: @background-color;
}
inputbar {
padding: 5px;
spacing: 5px;
}
listview {
spacing: 0.5em;
dynamic: false;
cycle: true;
columns: 1;
}
element { padding: 10px; }
entry {
expand: false;
text-color: @normal-foreground;
vertical-align: 1;
padding: 5px;
}
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;
text-color: @active-foreground;
}
element selected.normal {
background-color: @selected-normal-background;
text-color: @selected-normal-foreground;
border: 0 5px solid 0 0;
border-color: @active-background;
}
element selected.urgent {
background-color: @selected-urgent-background;
text-color: @selected-urgent-foreground;
}
element selected.active {
background-color: @selected-active-background;
text-color: @selected-active-foreground;
}
element alternate.normal {
background-color: @normal-background;
text-color: @normal-foreground;
}
element alternate.urgent {
background-color: @urgent-background;
text-color: @urgent-foreground;
}
element alternate.active {
background-color: @active-background;
text-color: @active-foreground;
}