我正在练习日语,作为练习工具,有时我想看没有字幕的动漫。我知道我可以使用热键关闭字幕mpv
,而且我也知道--sid=0
;然而,在这两种情况下,我只需一个热键就可以重新启用字幕。
这很糟糕,因为我经常发现自己很想频繁地重新启用潜艇,这严重阻碍了语言学习。所以我想知道是否有某种方法可以告诉mpv文件中的字幕不存在,这样,即使我真的想看到字幕,我也必须完全重新启动mpv
。
答案1
让我带来肯定涉及的众多解决方案之一mpv
视频播放器。
要解决您的问题,请编辑mpv.conf
以包含:
sub-visibility=no # Disable display of subtitles, but still load them if available.
这应从命令行运行,如下所示:
mpv --sub-visibility=no ...
第二次尝试:
编辑您的个人mpv
文件:
~/.config/mpv/input.conf
包含装有:
v disable
帮助脚本(示例)
#!/bin/sh
#-- Copyright: 2023 Vlastimil Burian --
#-- Script language: POSIX shell --
#-- Bugs: [email protected] --
#-- License: The Unlicense --
#-- Version 0.1 (beta) --
# Treat unset variables as errors.
set -o nounset
# Exit immediately when any command fails.
set -o errexit
# Function to show usage help.
# Requires one argument, the exit status.
usage ()
{
cat << EOF
MPV video player subtitles enable/disable toggling
--------------------------------------------------
on : Enable subtitles toggling in MPV.
off : Disable subtitles toggling in MPV.
-h : Show this help.
EOF
exit "$1"
}
# Process switches. Only help switch (-h) defined right now.
# If some other switch is given, show help with exit status 1.
while getopts ':h' opt; do
case "$opt" in
(h) usage 0 ;;
(*) usage 1 ;;
esac
done
# Check for the number of arguments.
# One argument is expected (on/off).
# If not given, show help with exit status 1.
if [ "$#" -ne 1 ]; then
usage 1
fi
# Here we know the user gave one argument.
# We accept (continue) only on/off values.
# If something else is given, show help with exit status 1.
case "$1" in
(on|off)
switch=$1 ;;
(*)
usage 1 ;;
esac
# Store MPV video player user config directory name.
# You must not quote the value for tilde to expand!
mpv_config_dir=~/.config/mpv
# Make sure the config directory exists,
# or create it with default permissions.
# shellcheck disable=SC2174
mkdir -p -m 0700 "$mpv_config_dir"
# Store MPV video player input config file name.
mpv_config_file=input.conf
# Store the whole path to config file.
mpv_config_file_path="$mpv_config_dir/$mpv_config_file"
# Check if the config file exists and if not, create it.
if [ ! -f "$mpv_config_file_path" ]; then
touch "$mpv_config_file_path"
chmod 664 "$mpv_config_file_path"
fi
# Linux tput color handling setup.
text_red=$(tput setaf 1)
text_green=$(tput setaf 2)
text_bold=$(tput bold)
text_reset=$(tput sgr0)
# Now we are ready to write to the MPV config file.
# We print success/error message according to what happens.
# Colors are optional of course. If you do not like them, remove their code.
case "$switch" in
(on)
if printf '\n' > "$mpv_config_file_path"; then
printf '%s\n' "${text_green}Success. MPV subtitles toggling is now ${text_bold}enabled.${text_reset}"
else
printf >&2 '%s\n' "${text_red}${text_bold}Error. Did not manage to write to the config file.${text_reset}"
exit 1
fi
;;
(off)
if printf '%s\n' 'v disable' > "$mpv_config_file_path"; then
printf '%s\n' "${text_green}Success. MPV subtitles toggling is now ${text_bold}disabled.${text_reset}"
else
printf >&2 '%s\n' "${text_red}${text_bold}Error. Did not manage to write to the config file.${text_reset}"
exit 1
fi
;;
esac