diff --git a/README.md b/README.md index 14668e2..405a7af 100644 --- a/README.md +++ b/README.md @@ -193,13 +193,13 @@ aniwrapper -C aniwrapper -Q # Choose rofi theme from presets -aniwrapper -t [aniwrapper (default)|dracula|fancy|flamingo|material|onedark] +aniwrapper -t # Specify custom rofi config aniwrapper -T # Specify starting directory for play_from_file mode, bypassing main menu -aniwrapper -f (no trailing slash in path) +aniwrapper -f # Use ani-cli command-line mode (rofi disabled) aniwrapper -c @@ -258,13 +258,13 @@ ani-cli -H ani-cli -s # choose quality -ani-cli -q [high|normal (default)|low] +ani-cli -q # choose rofi theme from presets -ani-cli -t [aniwrapper (default)|dracula|fancy|flamingo|material|onedark] +ani-cli -t # Specify starting directory for play_from_file mode (does not work with -c) -ani-cli -f (no trailing slash in path) +ani-cli -f # run ani-cli in command-line mode (rofi disabled) ani-cli -c diff --git a/ani-cli b/ani-cli index 3199f54..6aeb563 100755 --- a/ani-cli +++ b/ani-cli @@ -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|fancy|flamingo|material|onedark" +THEMES="aniwrapper (default)|dracula|fancy|flamingo|material|nord|onedark" # dependencies: grep, sed, curl, video_player, rofi, sqlite3 # video_player ( needs to be able to play urls ) @@ -318,21 +318,16 @@ sync_watch_history() { play_file() { logger "Checking if file is playable" if [[ "$1" =~ ($playable)$ ]]; then - logger "File is playable..." filename=$(grep -oE '[^/]*$' <<< "$1") directory=$(sed -E "s/\/$filename//" <<< "$1") - logger "FILENAME: $filename" - logger "DIRECTORY: $directory" insert_history "file" "$directory" "$filename" & if [[ "$1" =~ .mp3 ]]; then logger ".mp3 file found... playing without video" - logger "MPV COMMAND: $PLAYER_CMD --no-video $1" notification "Playing $1" $PLAYER_CMD --no-video "$1" else notification "Playing $1" - logger "MPV COMMAND: $PLAYER_CMD $1" - $PLAYER_CMD "$1" + $PLAYER_CMD "$1" > /dev/null 2>&1 & fi return $? else @@ -340,41 +335,15 @@ play_file() { fi } -# attempt to generate list of valid files and directories -generate_inputlist() { - # start at 2nd line, because first line out output from find is $1 - outstr="" - while read -r directory; do - if [[ "${directory// /}" == "" ]]; then - continue - fi - [ "$outstr" = "" ] && outstr="$directory" || outstr="$outstr|$directory" - done <<< "$(find "$1" -maxdepth 1 -type d | sed "s|$1/||" | tail -n +2 | sort -V)" - # logger "DIRS: $outstr" 1> /dev/stderr - while read -r filename; do - if [[ "${filename// /}" == "" ]]; then - continue - fi - [ "$outstr" = "" ] && outstr="$filename" || outstr="$outstr|$filename" - done <<< "$(find "$1" -maxdepth 1 -type f | sed "s|$1/||" | grep -E "$playable$" | sort -V)" - # logger "DIRS + FILES: $outstr" 1> /dev/stderr - outstr="$outstr|Back|Quit" - printf "%s\n" "$outstr" -} - -get_file_history_as_string() { - while read -r directory; do - continue - done <<< "$(run_stmt 'SELECT DISTINCT DIRECTORY FROM FILE_HISTORY;')" -} - -generate_file_watchedlist() { +get_directory_data() { search_dir="$1" + inputlist="" watched="" - cnt=0 + cnt=1 while read -r directory; do # sometimes direetory is empty string due to find parsing - [ -z "$directory" ] && continue + [ -z "${directory// /}" ] && continue + [ "$inputlist" = "" ] && inputlist="$directory" || inputlist="$inputlist|$directory" if ! check_db "directory" "$search_dir/$directory"; then logger "$search_dir/$directory opened before... adding $cnt to list" 1> /dev/stderr [ "$watched" = "" ] && watched="$cnt" || watched="$watched, $cnt" @@ -382,14 +351,17 @@ generate_file_watchedlist() { ((++cnt)) done <<< "$(find "$search_dir" -maxdepth 1 -type d | sed -E "s|$search_dir/||" | tail -n +2 | sort -V)" while read -r filename; do + [ -z "${filename// /}" ] && continue if ! check_db "file" "$search_dir" "$filename"; then logger "$filename watched before... adding $cnt to list" 1> /dev/stderr [ "$watched" = "" ] && watched="$cnt" || watched="$watched, $cnt" fi + [ "$inputlist" = "" ] && inputlist="$filename" || inputlist="$inputlist|$filename" ((++cnt)) done <<< "$(find "$search_dir" -maxdepth 1 -type f | sed "s|$search_dir/||" | grep -E "$playable$" | sort -V)" + [ "$search_dir" != "/" ] && inputlist="../|$inputlist|Back|Quit" || inputlist="$inputlist|Back|Quit" + logger "INPUT LIST: $inputlist" 1> /dev/stderr logger "WATCHED LIST: $watched" 1> /dev/stderr - printf "%s\n" "$watched" } # recursive function for finding path to video file given a starting directory @@ -405,17 +377,16 @@ find_media() { return 0 fi + get_directory_data "$inp" + [ -z "$inputlist" ] && return 1 + span=$(generate_span "Current directory: $inp") - # run in parallel in background? - inputlist=$(generate_inputlist "$inp" &) - watched_files=$(generate_file_watchedlist "$inp" &) - wait selection=$(rofi -dmenu -only-match -async-pre-read 33 -config "$ROFI_CFG" \ - -l 12 -i -sep '|' -mesg "$span" -a "$watched_files" \ - -p "Enter selection" <<< "${inputlist[@]}") + -l 15 -i -sep '|' -mesg "$span" -a "$watched" \ + -p "Enter selection" <<< "$inputlist") case "$selection" in - Back) + Back | ../) # go up one directory # dotdotslash=$(sed -E "s/(\/[^\/]*$)//" <<< "$inp") if [ -z "$(sed -E "s/(\/[^\/]*$)//" <<< "$inp")" ]; then @@ -798,6 +769,7 @@ while getopts 'hd:Hsvq:c-:f:t:T:CQ:' OPT; do f) scrape="file" play_dir="$OPTARG" + [ "$play_dir" != "/" ] && play_dir="$(sed -E 's/\/$//' <<< "$play_dir")" # remove trailing slash... unless searching / for some reason ;; t) theme="$OPTARG" @@ -820,6 +792,9 @@ while getopts 'hd:Hsvq:c-:f:t:T:CQ:' OPT; do material) ROFI_THEME=aniwrapper-material.rasi ;; + nord) + ROFI_THEME=aniwrapper-nord.rasi + ;; onedark) ROFI_THEME=aniwrapper-onedark.rasi ;; @@ -919,7 +894,6 @@ case $scrape in [ ! -d "$play_dir" ] && die "$play_dir does not exist" video_path=$(find_media "$play_dir") retcode="$?" - echo "RETURN FROM find_media() -> $retcode" if [ "$retcode" -ne 0 ]; then die "QUITTING" elif [ -z "$video_path" ]; then diff --git a/aniwrapper b/aniwrapper index 29e137f..a338496 100755 --- a/aniwrapper +++ b/aniwrapper @@ -12,7 +12,7 @@ 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|fancy|flamingo|material|onedark" +THEMES="aniwrapper (default)|dracula|fancy|flamingo|material|nord|onedark" GET_QUALITY=0 VERBOSE=0 IS_ROFI=1 @@ -151,6 +151,9 @@ parse_args() { material) ROFI_THEME=aniwrapper-material.rasi ;; + nord) + ROFI_THEME=aniwrapper-nord.rasi + ;; onedark) ROFI_THEME=aniwrapper-onedark.rasi ;; diff --git a/themes/aniwrapper-nord.rasi b/themes/aniwrapper-nord.rasi new file mode 100644 index 0000000..8a4a9e7 --- /dev/null +++ b/themes/aniwrapper-nord.rasi @@ -0,0 +1,156 @@ +* { + font: "Open Sans 15"; + nord0: #2e3440; + nord1: #3b4252; + nord2: #434c5e; + nord3: #4c566a; + nord4: #d8dee9; + nord5: #e5e9f0; + nord6: #eceff4; + nord7: #8fbcbb; + nord8: #88c0d0; + nord9: #81a1c1; + nord10: #5e81ac; + nord11: #bf616a; + nord12: #d08770; + nord13: #ebcb8b; + nord14: #a3be8c; + nord15: #b48ead; + + spacing: 2; + background-color: var(nord1); + + background: var(nord1); + foreground: var(nord4); + + normal-background: var(background); + normal-foreground: var(foreground); + alternate-normal-background: var(background); + alternate-normal-foreground: var(foreground); + selected-normal-background: var(nord8); + selected-normal-foreground: var(background); + + active-background: var(background); + active-foreground: var(nord10); + alternate-active-background: var(background); + alternate-active-foreground: var(nord10); + selected-active-background: var(nord10); + selected-active-foreground: var(background); + + urgent-background: var(background); + urgent-foreground: var(nord11); + alternate-urgent-background: var(background); + alternate-urgent-foreground: var(nord11); + selected-urgent-background: var(nord11); + selected-urgent-foreground: var(background); +} +element { + padding: 4px 0px 4px 7px; + spacing: 5px; + border: 0; + cursor: pointer; + margin: 1px 0px; + border-radius: 12px; +} +element normal.normal { + background-color: var(normal-background); + text-color: var(normal-foreground); +} +element normal.urgent { + background-color: var(urgent-background); + text-color: var(urgent-foreground); +} +element normal.active { + background-color: var(active-background); + text-color: var(active-foreground); +} +element selected.normal { + background-color: var(selected-normal-background); + text-color: var(selected-normal-foreground); +} +element selected.urgent { + background-color: var(selected-urgent-background); + text-color: var(selected-urgent-foreground); +} +element selected.active { + background-color: var(selected-active-background); + text-color: var(selected-active-foreground); +} +element alternate.normal { + background-color: var(alternate-normal-background); + text-color: var(alternate-normal-foreground); +} +element alternate.urgent { + background-color: var(alternate-urgent-background); + text-color: var(alternate-urgent-foreground); +} +element alternate.active { + background-color: var(alternate-active-background); + text-color: var(alternate-active-foreground); +} +element-text { + background-color: rgba(0, 0, 0, 0%); + text-color: inherit; + highlight: inherit; + cursor: inherit; +} +element-icon { + background-color: rgba(0, 0, 0, 0%); + size: 1.0000em; + text-color: inherit; + cursor: inherit; +} +window { + padding: 0; + border: 0; + background-color: var(background); + width: 60%; + border-radius: 12px; +} +mainbox { + padding: 0; + border: 0; +} +message { + margin: 0px 7px; +} +textbox { + text-color: var(foreground); +} +listview { + margin: 0px 0px 5px; + scrollbar: true; + spacing: 2px; + fixed-height: 0; + columns: 2; +} +scrollbar { + padding: 0; + handle-width: 14px; + border: 0; + handle-color: var(nord3); +} +button { + spacing: 0; + text-color: var(normal-foreground); + cursor: pointer; +} +button selected { + background-color: var(selected-normal-background); + text-color: var(selected-normal-foreground); +} +inputbar { + padding: 7px; + margin: 7px; + spacing: 0; + text-color: var(normal-foreground); + background-color: var(nord3); + children: [ entry ]; + border-radius: 12px; +} +entry { + spacing: 0; + cursor: text; + text-color: var(normal-foreground); + background-color: var(nord3); +}