Skip to content

Commit

Permalink
feat: no-detach (#1264)
Browse files Browse the repository at this point in the history
  • Loading branch information
port19x authored Feb 3, 2024
1 parent 08aff13 commit fde5470
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
8 changes: 6 additions & 2 deletions ani-cli
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh

version_number="4.7.5"
version_number="4.7.6"

# UI

Expand Down Expand Up @@ -65,6 +65,8 @@ help_info() {
Use rofi instead of fzf for the interactive menu
--skip
Use ani-skip to skip the intro of the episode (mpv only)
--no-detach
Don't detach the player (useful for in-terminal playback, mpv only)
--skip-title <title>
Use given title as ani-skip query
-U, --update
Expand Down Expand Up @@ -238,7 +240,7 @@ play_episode() {
[ -z "$ANI_CLI_NON_INTERACTIVE" ] && printf "All links:\n%s\nSelected link:\n" "$links"
printf "%s\n" "$episode"
;;
mpv*) nohup "$player_function" $skip_flag --force-media-title="${allanime_title}Episode ${ep_no}" "$episode" >/dev/null 2>&1 & ;;
mpv*) $([ "$no_detach" = 0 ] && echo "nohup") "$player_function" $skip_flag --force-media-title="${allanime_title}Episode ${ep_no}" "$episode" >/dev/null 2>&1 & ;;
android_mpv) nohup am start --user 0 -a android.intent.action.VIEW -d "$episode" -n is.xyz.mpv/.MPVActivity >/dev/null 2>&1 & ;;
android_vlc) nohup am start --user 0 -a android.intent.action.VIEW -d "$episode" -n org.videolan.vlc/org.videolan.vlc.gui.video.VideoPlayerActivity -e "title" "${allanime_title}Episode ${ep_no}" >/dev/null 2>&1 & ;;
iina) nohup "$player_function" --no-stdin --keep-running --mpv-force-media-title="${allanime_title}Episode ${ep_no}" "$episode" >/dev/null 2>&1 & ;;
Expand Down Expand Up @@ -303,6 +305,7 @@ case "$(uname -a)" in
*) player_function="${ANI_CLI_PLAYER:-mpv}" ;; # Linux OS
esac

no_detach="${ANI_CLI_NO_DETACH:-0}"
use_external_menu="${ANI_CLI_EXTERNAL_MENU:-0}"
skip_intro="${ANI_CLI_SKIP_INTRO:-0}"
# shellcheck disable=SC2154
Expand Down Expand Up @@ -359,6 +362,7 @@ while [ $# -gt 0 ]; do
shift
;;
--dub) mode="dub" ;;
--no-detach) no_detach=1 ;;
--rofi) use_external_menu=1 ;;
--skip) skip_intro=1 ;;
--skip-title)
Expand Down
6 changes: 6 additions & 0 deletions ani-cli.1
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ Use rofi instead of fzf for the interactive menu
\fB\--skip\fR
Use ani-skip to skip the intro of the episode (mpv only)
.TP
\fB\--no-detach\fR
Don't detach the player (useful for in-terminal playback, mpv only)
.TP
\fB\--skip-title\fR \fI\,<title>\/\fR
Specify the title to use for ani-skip
.PP
Expand Down Expand Up @@ -99,6 +102,9 @@ Controls the default source. Valid is history (equivalent to -c), everything els
\fBANI_CLI_SKIP_INTRO\fR
Controls if ani-skip is used to skip intros (works with mpv only). Can be 0 (disabled) or 1 (enabled). Default is 0.
.TP
\fBANI_CLI_NO_DETACH\fR
Controls if mpv is detached from the main process for playback, which can be useful for use with terminal renderers such as kitty. (works with mpv only). Can be 0 (disabled) or 1 (enabled). Default is 0.
.TP
\fBANI_CLI_SKIP_TITLE\fR
Overrides the anime title to query for skip times. Can be any string value. Default is empty, resolving to the anime title as given by ani-cli.
.PP
Expand Down

0 comments on commit fde5470

Please sign in to comment.