Compare commits

..

2 Commits

Author SHA1 Message Date
ksyasuda
c301fbf548 update 2022-02-13 15:15:35 -08:00
ksyasuda
4d2458564f update mpv config 2022-02-13 14:34:37 -08:00
12 changed files with 2534 additions and 2 deletions

View File

@ -197,3 +197,7 @@ CTRL+5 no-osd change-list glsl-shaders set "~~/shaders/Anime4K_Clamp_Highlights.
CTRL+6 no-osd change-list glsl-shaders set "~~/shaders/Anime4K_Clamp_Highlights.glsl:~~/shaders/Anime4K_Upscale_Denoise_CNN_x2_VL.glsl:~~/shaders/Anime4K_AutoDownscalePre_x2.glsl:~~/shaders/Anime4K_AutoDownscalePre_x4.glsl:~~/shaders/Anime4K_Restore_CNN_M.glsl:~~/shaders/Anime4K_Upscale_CNN_x2_M.glsl"; show-text "Anime4K: Mode C+A (HQ)" CTRL+6 no-osd change-list glsl-shaders set "~~/shaders/Anime4K_Clamp_Highlights.glsl:~~/shaders/Anime4K_Upscale_Denoise_CNN_x2_VL.glsl:~~/shaders/Anime4K_AutoDownscalePre_x2.glsl:~~/shaders/Anime4K_AutoDownscalePre_x4.glsl:~~/shaders/Anime4K_Restore_CNN_M.glsl:~~/shaders/Anime4K_Upscale_CNN_x2_M.glsl"; show-text "Anime4K: Mode C+A (HQ)"
CTRL+0 no-osd change-list glsl-shaders clr ""; show-text "GLSL shaders cleared" CTRL+0 no-osd change-list glsl-shaders clr ""; show-text "GLSL shaders cleared"
TAB script-binding skip-key
o write-watch-later-config; loadfile "${path}"

View File

@ -51,6 +51,7 @@
# Keep the player window on top of all other windows. # Keep the player window on top of all other windows.
#ontop=yes #ontop=yes
# window=scale=1.0
# Specify high quality video rendering preset (for --vo=gpu only) # Specify high quality video rendering preset (for --vo=gpu only)
# Can cause performance problems with some drivers and GPUs. # Can cause performance problems with some drivers and GPUs.
@ -94,7 +95,7 @@ profile=svp
# Pretend to be a web browser. Might fix playback with some streaming sites, # Pretend to be a web browser. Might fix playback with some streaming sites,
# but also will break with shoutcast streams. # but also will break with shoutcast streams.
#user-agent="Mozilla/5.0" user-agent="Mozilla/5.0"
# cache settings # cache settings
# #

106
mpv/scripts/discord.lua Normal file
View File

@ -0,0 +1,106 @@
msg = require("mp.msg")
opts = require("mp.options")
utils = require("mp.utils")
options = {
key = "D",
active = true,
client_id = "737663962677510245",
binary_path = "",
socket_path = "/tmp/mpvsocket",
use_static_socket_path = true,
autohide_threshold = 0
}
opts.read_options(options, "discord")
if options.binary_path == "" then
msg.fatal("Missing binary path in config file.")
os.exit(1)
end
function file_exists(path) -- fix(#23): use this instead of utils.file_info
local f = io.open(path, "r")
if f ~= nil then io.close(f) return true else return false end
end
if not file_exists(options.binary_path) then
msg.fatal("The specified binary path does not exist.")
os.exit(1)
end
version = "1.6.0"
msg.info(("mpv-discord v%s by tnychn"):format(version))
socket_path = options.socket_path
if not options.use_static_socket_path then
pid = utils.getpid()
filename = ("mpv-discord-%s"):format(pid)
if socket_path == "" then
socket_path = "/tmp/" -- default
end
socket_path = utils.join_path(socket_path, filename)
elseif socket_path == "" then
msg.fatal("Missing socket path in config file.")
os.exit(1)
end
msg.info(("(mpv-ipc): %s"):format(socket_path))
mp.set_property("input-ipc-server", socket_path)
cmd = nil
function start()
if cmd == nil then
cmd = mp.command_native_async({
name = "subprocess",
playback_only = false,
args = {
options.binary_path,
socket_path,
options.client_id
}
}, function() end)
msg.info("launched subprocess")
mp.osd_message("Discord Rich Presence: Started")
end
end
function stop()
mp.abort_async_command(cmd)
cmd = nil
msg.info("aborted subprocess")
mp.osd_message("Discord Rich Presence: Stopped")
end
if options.active then
mp.register_event("file-loaded", start)
end
mp.add_key_binding(options.key, "toggle-discord", function()
if cmd ~= nil then stop()
else start() end
end)
mp.register_event("shutdown", function()
if cmd ~= nil then stop() end
if not options.use_static_socket_path then
os.remove(socket_path)
end
end)
if options.autohide_threshold > 0 then
local timer = nil
local t = options.autohide_threshold
mp.observe_property("pause", "bool", function(_, value)
if value == true then
timer = mp.add_timeout(t, function()
if cmd ~= nil then stop() end
end)
else
if timer ~= nil then
timer:kill()
timer = nil
end
if options.active and cmd == nil then start() end
end
end)
end

File diff suppressed because it is too large Load Diff

418
mpv/scripts/reload.lua Normal file
View File

@ -0,0 +1,418 @@
-- reload.lua
--
-- When an online video is stuck buffering or got very slow CDN
-- source, restarting often helps. This script provides automatic
-- reloading of videos that doesn't have buffering progress for some
-- time while keeping the current time position. It also adds `Ctrl+r`
-- keybinding to reload video manually.
--
-- SETTINGS
--
-- To override default setting put the `lua-settings/reload.conf` file in
-- mpv user folder, on linux it is `~/.config/mpv`. NOTE: config file
-- name should match the name of the script.
--
-- Default `reload.conf` settings:
--
-- ```
-- # enable automatic reload on timeout
-- # when paused-for-cache event fired, we will wait
-- # paused_for_cache_timer_timeout sedonds and then reload the video
-- paused_for_cache_timer_enabled=yes
--
-- # checking paused_for_cache property interval in seconds,
-- # can not be less than 0.05 (50 ms)
-- paused_for_cache_timer_interval=1
--
-- # time in seconds to wait until reload
-- paused_for_cache_timer_timeout=10
--
-- # enable automatic reload based on demuxer cache
-- # if demuxer-cache-time property didn't change in demuxer_cache_timer_timeout
-- # time interval, the video will be reloaded as soon as demuxer cache depleated
-- demuxer_cache_timer_enabled=yes
--
-- # checking demuxer-cache-time property interval in seconds,
-- # can not be less than 0.05 (50 ms)
-- demuxer_cache_timer_interval=2
--
-- # if demuxer cache didn't receive any data during demuxer_cache_timer_timeout
-- # we decide that it has no progress and will reload the stream when
-- # paused_for_cache event happens
-- demuxer_cache_timer_timeout=20
--
-- # when the end-of-file is reached, reload the stream to check
-- # if there is more content available.
-- reload_eof_enabled=no
--
-- # keybinding to reload stream from current time position
-- # you can disable keybinding by setting it to empty value
-- # reload_key_binding=
-- reload_key_binding=Ctrl+r
-- ```
--
-- DEBUGGING
--
-- Debug messages will be printed to stdout with mpv command line option
-- `--msg-level='reload=debug'`. You may also need to add the `--no-msg-color`
-- option to make the debug logs visible if you are using a dark colorscheme
-- in terminal.
local msg = require 'mp.msg'
local options = require 'mp.options'
local utils = require 'mp.utils'
local settings = {
paused_for_cache_timer_enabled = true,
paused_for_cache_timer_interval = 1,
paused_for_cache_timer_timeout = 10,
demuxer_cache_timer_enabled = true,
demuxer_cache_timer_interval = 2,
demuxer_cache_timer_timeout = 20,
reload_eof_enabled = false,
reload_key_binding = "Ctrl+r",
}
-- global state stores properties between reloads
local property_path = nil
local property_time_pos = 0
local property_keep_open = nil
-- FSM managing the demuxer cache.
--
-- States:
--
-- * fetch - fetching new data
-- * stale - unable to fetch new data for time < 'demuxer_cache_timer_timeout'
-- * stuck - unable to fetch new data for time >= 'demuxer_cache_timer_timeout'
--
-- State transitions:
--
-- +---------------------------+
-- v |
-- +-------+ +-------+ +-------+
-- + fetch +<--->+ stale +---->+ stuck |
-- +-------+ +-------+ +-------+
-- | ^ | ^ | ^
-- +---+ +---+ +---+
local demuxer_cache = {
timer = nil,
state = {
name = 'uninitialized',
demuxer_cache_time = 0,
in_state_time = 0,
},
events = {
continue_fetch = { name = 'continue_fetch', from = 'fetch', to = 'fetch' },
continue_stale = { name = 'continue_stale', from = 'stale', to = 'stale' },
continue_stuck = { name = 'continue_stuck', from = 'stuck', to = 'stuck' },
fetch_to_stale = { name = 'fetch_to_stale', from = 'fetch', to = 'stale' },
stale_to_fetch = { name = 'stale_to_fetch', from = 'stale', to = 'fetch' },
stale_to_stuck = { name = 'stale_to_stuck', from = 'stale', to = 'stuck' },
stuck_to_fetch = { name = 'stuck_to_fetch', from = 'stuck', to = 'fetch' },
},
}
-- Always start with 'fetch' state
function demuxer_cache.reset_state()
demuxer_cache.state = {
name = demuxer_cache.events.continue_fetch.to,
demuxer_cache_time = 0,
in_state_time = 0,
}
end
-- Has 'demuxer_cache_time' changed
function demuxer_cache.has_progress_since(t)
return demuxer_cache.state.demuxer_cache_time ~= t
end
function demuxer_cache.is_state_fetch()
return demuxer_cache.state.name == demuxer_cache.events.continue_fetch.to
end
function demuxer_cache.is_state_stale()
return demuxer_cache.state.name == demuxer_cache.events.continue_stale.to
end
function demuxer_cache.is_state_stuck()
return demuxer_cache.state.name == demuxer_cache.events.continue_stuck.to
end
function demuxer_cache.transition(event)
if demuxer_cache.state.name == event.from then
-- state setup
demuxer_cache.state.demuxer_cache_time = event.demuxer_cache_time
if event.name == 'continue_fetch' then
demuxer_cache.state.in_state_time = demuxer_cache.state.in_state_time + event.interval
elseif event.name == 'continue_stale' then
demuxer_cache.state.in_state_time = demuxer_cache.state.in_state_time + event.interval
elseif event.name == 'continue_stuck' then
demuxer_cache.state.in_state_time = demuxer_cache.state.in_state_time + event.interval
elseif event.name == 'fetch_to_stale' then
demuxer_cache.state.in_state_time = 0
elseif event.name == 'stale_to_fetch' then
demuxer_cache.state.in_state_time = 0
elseif event.name == 'stale_to_stuck' then
demuxer_cache.state.in_state_time = 0
elseif event.name == 'stuck_to_fetch' then
demuxer_cache.state.in_state_time = 0
end
-- state transition
demuxer_cache.state.name = event.to
msg.debug('demuxer_cache.transition', event.name, utils.to_string(demuxer_cache.state))
else
msg.error(
'demuxer_cache.transition',
'illegal transition', event.name,
'from state', demuxer_cache.state.name)
end
end
function demuxer_cache.initialize(demuxer_cache_timer_interval)
demuxer_cache.reset_state()
demuxer_cache.timer = mp.add_periodic_timer(
demuxer_cache_timer_interval,
function()
demuxer_cache.demuxer_cache_timer_tick(
mp.get_property_native('demuxer-cache-time'),
demuxer_cache_timer_interval)
end
)
end
-- If there is no progress of demuxer_cache_time in
-- settings.demuxer_cache_timer_timeout time interval switch state to
-- 'stuck' and switch back to 'fetch' as soon as any progress is made
function demuxer_cache.demuxer_cache_timer_tick(demuxer_cache_time, demuxer_cache_timer_interval)
local event = nil
local cache_has_progress = demuxer_cache.has_progress_since(demuxer_cache_time)
-- I miss pattern matching so much
if demuxer_cache.is_state_fetch() then
if cache_has_progress then
event = demuxer_cache.events.continue_fetch
else
event = demuxer_cache.events.fetch_to_stale
end
elseif demuxer_cache.is_state_stale() then
if cache_has_progress then
event = demuxer_cache.events.stale_to_fetch
elseif demuxer_cache.state.in_state_time < settings.demuxer_cache_timer_timeout then
event = demuxer_cache.events.continue_stale
else
event = demuxer_cache.events.stale_to_stuck
end
elseif demuxer_cache.is_state_stuck() then
if cache_has_progress then
event = demuxer_cache.events.stuck_to_fetch
else
event = demuxer_cache.events.continue_stuck
end
end
event.demuxer_cache_time = demuxer_cache_time
event.interval = demuxer_cache_timer_interval
demuxer_cache.transition(event)
end
local paused_for_cache = {
timer = nil,
time = 0,
}
function paused_for_cache.reset_timer()
msg.debug('paused_for_cache.reset_timer', paused_for_cache.time)
if paused_for_cache.timer then
paused_for_cache.timer:kill()
paused_for_cache.timer = nil
paused_for_cache.time = 0
end
end
function paused_for_cache.start_timer(interval_seconds, timeout_seconds)
msg.debug('paused_for_cache.start_timer', paused_for_cache.time)
if not paused_for_cache.timer then
paused_for_cache.timer = mp.add_periodic_timer(
interval_seconds,
function()
paused_for_cache.time = paused_for_cache.time + interval_seconds
if paused_for_cache.time >= timeout_seconds then
paused_for_cache.reset_timer()
reload_resume()
end
msg.debug('paused_for_cache', 'tick', paused_for_cache.time)
end
)
end
end
function paused_for_cache.handler(property, is_paused)
if is_paused then
if demuxer_cache.is_state_stuck() then
msg.info("demuxer cache has no progress")
-- reset demuxer state to avoid immediate reload if
-- paused_for_cache event triggered right after reload
demuxer_cache.reset_state()
reload_resume()
end
paused_for_cache.start_timer(
settings.paused_for_cache_timer_interval,
settings.paused_for_cache_timer_timeout)
else
paused_for_cache.reset_timer()
end
end
function read_settings()
options.read_options(settings, mp.get_script_name())
msg.debug(utils.to_string(settings))
end
function reload(path, time_pos)
msg.debug("reload", path, time_pos)
if time_pos == nil then
mp.commandv("loadfile", path, "replace")
else
mp.commandv("loadfile", path, "replace", "start=+" .. time_pos)
end
end
function reload_resume()
local path = mp.get_property("path", property_path)
local time_pos = mp.get_property("time-pos")
local reload_duration = mp.get_property_native("duration")
local playlist_count = mp.get_property_number("playlist/count")
local playlist_pos = mp.get_property_number("playlist-pos")
local playlist = {}
for i = 0, playlist_count-1 do
playlist[i] = mp.get_property("playlist/" .. i .. "/filename")
end
-- Tries to determine live stream vs. pre-recordered VOD. VOD has non-zero
-- duration property. When reloading VOD, to keep the current time position
-- we should provide offset from the start. Stream doesn't have fixed start.
-- Decent choice would be to reload stream from it's current 'live' positon.
-- That's the reason we don't pass the offset when reloading streams.
if reload_duration and reload_duration > 0 then
msg.info("reloading video from", time_pos, "second")
reload(path, time_pos)
-- VODs get stuck when reload is called without a time_pos
-- this is most noticeable in youtube videos whenever download gets stuck in the first frames
-- video would stay paused without being actually paused
-- issue surfaced in mpv 0.33, afaik
elseif reload_duration and reload_duration == 0 then
msg.info("reloading video from", time_pos, "second")
reload(path, time_pos)
else
msg.info("reloading stream")
reload(path, nil)
end
msg.info("file ", playlist_pos+1, "of", playlist_count, "in playlist")
for i = 0, playlist_pos-1 do
mp.commandv("loadfile", playlist[i], "append")
end
mp.commandv("playlist-move", 0, playlist_pos+1)
for i = playlist_pos+1, playlist_count-1 do
mp.commandv("loadfile", playlist[i], "append")
end
end
function reload_eof(property, eof_reached)
msg.debug("reload_eof", property, eof_reached)
local time_pos = mp.get_property_number("time-pos")
local duration = mp.get_property_number("duration")
if eof_reached and math.floor(time_pos) == math.floor(duration) then
msg.debug("property_time_pos", property_time_pos, "time_pos", time_pos)
-- Check that playback time_pos made progress after the last reload. When
-- eof is reached we try to reload video, in case there is more content
-- available. If time_pos stayed the same after reload, it means that vidkk
-- to avoid infinite reload loop when playback ended
-- math.floor function rounds time_pos to a second, to avoid inane reloads
if math.floor(property_time_pos) == math.floor(time_pos) then
msg.info("eof reached, playback ended")
mp.set_property("keep-open", property_keep_open)
else
msg.info("eof reached, checking if more content available")
reload_resume()
mp.set_property_bool("pause", false)
property_time_pos = time_pos
end
end
end
function on_file_loaded(event)
local debug_info = {
event = event,
time_pos = mp.get_property("time-pos"),
stream_pos = mp.get_property("stream-pos"),
stream_end = mp.get_property("stream-end"),
duration = mp.get_property("duration"),
seekable = mp.get_property("seekable"),
pause = mp.get_property("pause"),
paused_for_cache = mp.get_property("paused-for-cache"),
cache_buffering_state = mp.get_property("cache-buffering-state"),
}
msg.debug("debug_info", utils.to_string(debug_info))
-- When the video is reloaded after being paused for cache, it won't start
-- playing again while all properties looks fine:
-- `pause=no`, `paused-for-cache=no` and `cache-buffering-state=100`.
-- As a workaround, we cycle through the paused state by sending two SPACE
-- keypresses.
-- What didn't work:
-- - Cycling through the `pause` property.
-- - Run the `playlist-play-index current` command.
mp.commandv("keypress", 'SPACE')
mp.commandv("keypress", 'SPACE')
end
-- main
read_settings()
if settings.reload_key_binding ~= "" then
mp.add_key_binding(settings.reload_key_binding, "reload_resume", reload_resume)
end
if settings.paused_for_cache_timer_enabled then
mp.observe_property("paused-for-cache", "bool", paused_for_cache.handler)
end
if settings.demuxer_cache_timer_enabled then
demuxer_cache.initialize(settings.demuxer_cache_timer_interval)
end
if settings.reload_eof_enabled then
-- vo-configured == video output created && its configuration went ok
mp.observe_property(
"vo-configured",
"bool",
function(name, vo_configured)
msg.debug(name, vo_configured)
if vo_configured then
property_path = mp.get_property("path")
property_keep_open = mp.get_property("keep-open")
mp.set_property("keep-open", "yes")
mp.set_property("keep-open-pause", "no")
end
end
)
mp.observe_property("eof-reached", "bool", reload_eof)
end
mp.register_event("file-loaded", on_file_loaded)

754
mpv/scripts/stats.lua Normal file
View File

@ -0,0 +1,754 @@
-- Display some stats.
--
-- Please consult the readme for information about usage and configuration:
-- https://github.com/Argon-/mpv-stats
--
-- Please note: not every property is always available and therefore not always
-- visible.
local mp = require 'mp'
local options = require 'mp.options'
local utils = require 'mp.utils'
-- Options
local o = {
-- Default key bindings
key_oneshot = "i",
key_toggle = "I",
key_page_1 = "1",
key_page_2 = "2",
key_page_3 = "3",
duration = 4,
redraw_delay = 1, -- acts as duration in the toggling case
ass_formatting = true,
persistent_overlay = false, -- whether the stats can be overwritten by other output
print_perfdata_passes = false, -- when true, print the full information about all passes
filter_params_max_length = 100, -- a filter list longer than this many characters will be shown one filter per line instead
debug = false,
-- Graph options and style
plot_perfdata = true,
plot_vsync_ratio = true,
plot_vsync_jitter = true,
skip_frames = 5,
global_max = true,
flush_graph_data = true, -- clear data buffers when toggling
plot_bg_border_color = "0000FF",
plot_bg_color = "262626",
plot_color = "FFFFFF",
-- Text style
font = "Source Sans Pro",
font_mono = "Source Sans Pro", -- monospaced digits are sufficient
font_size = 8,
font_color = "FFFFFF",
border_size = 0.8,
border_color = "262626",
shadow_x_offset = 0.0,
shadow_y_offset = 0.0,
shadow_color = "000000",
alpha = "11",
-- Custom header for ASS tags to style the text output.
-- Specifying this will ignore the text style values above and just
-- use this string instead.
custom_header = "",
-- Text formatting
-- With ASS
ass_nl = "\\N",
ass_indent = "\\h\\h\\h\\h\\h",
ass_prefix_sep = "\\h\\h",
ass_b1 = "{\\b1}",
ass_b0 = "{\\b0}",
ass_it1 = "{\\i1}",
ass_it0 = "{\\i0}",
-- Without ASS
no_ass_nl = "\n",
no_ass_indent = "\t",
no_ass_prefix_sep = " ",
no_ass_b1 = "\027[1m",
no_ass_b0 = "\027[0m",
no_ass_it1 = "\027[3m",
no_ass_it0 = "\027[0m",
}
options.read_options(o)
local format = string.format
local max = math.max
local min = math.min
-- Function used to record performance data
local recorder = nil
-- Timer used for redrawing (toggling) and clearing the screen (oneshot)
local display_timer = nil
-- Current page and <page key>:<page function> mappings
local curr_page = o.key_page_1
local pages = {}
-- Save these sequences locally as we'll need them a lot
local ass_start = mp.get_property_osd("osd-ass-cc/0")
local ass_stop = mp.get_property_osd("osd-ass-cc/1")
-- Ring buffers for the values used to construct a graph.
-- .pos denotes the current position, .len the buffer length
-- .max is the max value in the corresponding buffer
local vsratio_buf, vsjitter_buf
local function init_buffers()
vsratio_buf = {0, pos = 1, len = 50, max = 0}
vsjitter_buf = {0, pos = 1, len = 50, max = 0}
end
-- Save all properties known to this version of mpv
local property_list = {}
for p in string.gmatch(mp.get_property("property-list"), "([^,]+)") do property_list[p] = true end
-- Mapping of properties to their deprecated names
local property_aliases = {
["decoder-frame-drop-count"] = "drop-frame-count",
["frame-drop-count"] = "vo-drop-frame-count",
["container-fps"] = "fps",
}
-- Return deprecated name for the given property
local function compat(p)
while not property_list[p] and property_aliases[p] do
p = property_aliases[p]
end
return p
end
local function set_ASS(b)
if not o.use_ass or o.persistent_overlay then
return ""
end
return b and ass_start or ass_stop
end
local function no_ASS(t)
return set_ASS(false) .. t .. set_ASS(true)
end
local function b(t)
return o.b1 .. t .. o.b0
end
local function it(t)
return o.it1 .. t .. o.it0
end
local function text_style()
if not o.use_ass then
return ""
end
if o.custom_header and o.custom_header ~= "" then
return set_ASS(true) .. o.custom_header
else
return format("%s{\\r}{\\an7}{\\fs%d}{\\fn%s}{\\bord%f}{\\3c&H%s&}" ..
"{\\1c&H%s&}{\\alpha&H%s&}{\\xshad%f}{\\yshad%f}{\\4c&H%s&}",
set_ASS(true), o.font_size, o.font, o.border_size,
o.border_color, o.font_color, o.alpha, o.shadow_x_offset,
o.shadow_y_offset, o.shadow_color)
end
end
local function has_vo_window()
return mp.get_property("vo-configured") == "yes"
end
local function has_ansi()
local is_windows = type(package) == 'table'
and type(package.config) == 'string'
and package.config:sub(1, 1) == '\\'
if is_windows then
return os.getenv("ANSICON")
end
return true
end
-- Generate a graph from the given values.
-- Returns an ASS formatted vector drawing as string.
--
-- values: Array/table of numbers representing the data. Used like a ring buffer
-- it will get iterated backwards `len` times starting at position `i`.
-- i : Index of the latest data value in `values`.
-- len : The length/amount of numbers in `values`.
-- v_max : The maximum number in `values`. It is used to scale all data
-- values to a range of 0 to `v_max`.
-- v_avg : The average number in `values`. It is used to try and center graphs
-- if possible. May be left as nil
-- scale : A value that will be multiplied with all data values.
-- x_tics: Horizontal width multiplier for the steps
local function generate_graph(values, i, len, v_max, v_avg, scale, x_tics)
-- Check if at least one value exists
if not values[i] then
return ""
end
local x_max = (len - 1) * x_tics
local y_offset = o.border_size
local y_max = o.font_size * 0.66
local x = 0
-- try and center the graph if possible, but avoid going above `scale`
if v_avg then
scale = min(scale, v_max / (2 * v_avg))
end
local s = {format("m 0 0 n %f %f l ", x, y_max - (y_max * values[i] / v_max * scale))}
i = ((i - 2) % len) + 1
for p = 1, len - 1 do
if values[i] then
x = x - x_tics
s[#s+1] = format("%f %f ", x, y_max - (y_max * values[i] / v_max * scale))
end
i = ((i - 2) % len) + 1
end
s[#s+1] = format("%f %f %f %f", x, y_max, 0, y_max)
local bg_box = format("{\\bord0.5}{\\3c&H%s&}{\\1c&H%s&}m 0 %f l %f %f %f 0 0 0",
o.plot_bg_border_color, o.plot_bg_color, y_max, x_max, y_max, x_max)
return format("%s{\\r}{\\pbo%f}{\\shad0}{\\alpha&H00}{\\p1}%s{\\p0}{\\bord0}{\\1c&H%s}{\\p1}%s{\\p0}%s",
o.prefix_sep, y_offset, bg_box, o.plot_color, table.concat(s), text_style())
end
local function append(s, str, attr)
if not str then
return false
end
attr.prefix_sep = attr.prefix_sep or o.prefix_sep
attr.indent = attr.indent or o.indent
attr.nl = attr.nl or o.nl
attr.suffix = attr.suffix or ""
attr.prefix = attr.prefix or ""
attr.no_prefix_markup = attr.no_prefix_markup or false
attr.prefix = attr.no_prefix_markup and attr.prefix or b(attr.prefix)
s[#s+1] = format("%s%s%s%s%s%s", attr.nl, attr.indent,
attr.prefix, attr.prefix_sep, no_ASS(str), attr.suffix)
return true
end
-- Format and append a property.
-- A property whose value is either `nil` or empty (hereafter called "invalid")
-- is skipped and not appended.
-- Returns `false` in case nothing was appended, otherwise `true`.
--
-- s : Table containing strings.
-- prop : The property to query and format (based on its OSD representation).
-- attr : Optional table to overwrite certain (formatting) attributes for
-- this property.
-- exclude: Optional table containing keys which are considered invalid values
-- for this property. Specifying this will replace empty string as
-- default invalid value (nil is always invalid).
local function append_property(s, prop, attr, excluded)
excluded = excluded or {[""] = true}
local ret = mp.get_property_osd(prop)
if not ret or excluded[ret] then
if o.debug then
print("No value for property: " .. prop)
end
return false
end
return append(s, ret, attr)
end
local function append_perfdata(s, dedicated_page)
local vo_p = mp.get_property_native("vo-passes")
if not vo_p then
return
end
local ds = mp.get_property_bool("display-sync-active", false)
local target_fps = ds and mp.get_property_number("display-fps", 0)
or mp.get_property_number(compat("container-fps"), 0)
if target_fps > 0 then target_fps = 1 / target_fps * 1e9 end
-- Sums of all last/avg/peak values
local last_s, avg_s, peak_s = {}, {}, {}
for frame, data in pairs(vo_p) do
last_s[frame], avg_s[frame], peak_s[frame] = 0, 0, 0
for _, pass in ipairs(data) do
last_s[frame] = last_s[frame] + pass["last"]
avg_s[frame] = avg_s[frame] + pass["avg"]
peak_s[frame] = peak_s[frame] + pass["peak"]
end
end
-- Pretty print measured time
local function pp(i)
-- rescale to microseconds for a saner display
return format("%05d", i / 1000)
end
-- Format n/m with a font weight based on the ratio
local function p(n, m)
local i = 0
if m > 0 then
i = tonumber(n) / m
end
-- Calculate font weight. 100 is minimum, 400 is normal, 700 bold, 900 is max
local w = (700 * math.sqrt(i)) + 200
return format("{\\b%d}%02d%%{\\b0}", w, i * 100)
end
s[#s+1] = format("%s%s%s%s{\\fs%s}%s{\\fs%s}",
dedicated_page and "" or o.nl, dedicated_page and "" or o.indent,
b("Frame Timings:"), o.prefix_sep, o.font_size * 0.66,
"(last/average/peak μs)", o.font_size)
for frame, data in pairs(vo_p) do
local f = "%s%s%s{\\fn%s}%s / %s / %s %s%s{\\fn%s}%s%s%s"
if dedicated_page then
s[#s+1] = format("%s%s%s:", o.nl, o.indent,
b(frame:gsub("^%l", string.upper)))
for _, pass in ipairs(data) do
s[#s+1] = format(f, o.nl, o.indent, o.indent,
o.font_mono, pp(pass["last"]),
pp(pass["avg"]), pp(pass["peak"]),
o.prefix_sep .. o.prefix_sep, p(pass["last"], last_s[frame]),
o.font, o.prefix_sep, o.prefix_sep, pass["desc"])
if o.plot_perfdata and o.use_ass then
s[#s+1] = generate_graph(pass["samples"], pass["count"],
pass["count"], pass["peak"],
pass["avg"], 0.9, 0.25)
end
end
-- Print sum of timing values as "Total"
s[#s+1] = format(f, o.nl, o.indent, o.indent,
o.font_mono, pp(last_s[frame]),
pp(avg_s[frame]), pp(peak_s[frame]), "", "", o.font,
o.prefix_sep, o.prefix_sep, b("Total"))
else
-- for the simplified view, we just print the sum of each pass
s[#s+1] = format(f, o.nl, o.indent, o.indent, o.font_mono,
pp(last_s[frame]), pp(avg_s[frame]), pp(peak_s[frame]),
"", "", o.font, o.prefix_sep, o.prefix_sep,
frame:gsub("^%l", string.upper))
end
end
end
local function append_display_sync(s)
if not mp.get_property_bool("display-sync-active", false) then
return
end
local vspeed = append_property(s, "video-speed-correction", {prefix="DS:"})
if vspeed then
append_property(s, "audio-speed-correction",
{prefix="/", nl="", indent=" ", prefix_sep=" ", no_prefix_markup=true})
else
append_property(s, "audio-speed-correction",
{prefix="DS:" .. o.prefix_sep .. " - / ", prefix_sep=""})
end
append_property(s, "mistimed-frame-count", {prefix="Mistimed:", nl=""})
append_property(s, "vo-delayed-frame-count", {prefix="Delayed:", nl=""})
-- As we need to plot some graphs we print jitter and ratio on their own lines
if not display_timer.oneshot and (o.plot_vsync_ratio or o.plot_vsync_jitter) and o.use_ass then
local ratio_graph = ""
local jitter_graph = ""
if o.plot_vsync_ratio then
ratio_graph = generate_graph(vsratio_buf, vsratio_buf.pos, vsratio_buf.len, vsratio_buf.max, nil, 0.8, 1)
end
if o.plot_vsync_jitter then
jitter_graph = generate_graph(vsjitter_buf, vsjitter_buf.pos, vsjitter_buf.len, vsjitter_buf.max, nil, 0.8, 1)
end
append_property(s, "vsync-ratio", {prefix="VSync Ratio:", suffix=o.prefix_sep .. ratio_graph})
append_property(s, "vsync-jitter", {prefix="VSync Jitter:", suffix=o.prefix_sep .. jitter_graph})
else
-- Since no graph is needed we can print ratio/jitter on the same line and save some space
local vratio = append_property(s, "vsync-ratio", {prefix="VSync Ratio:"})
append_property(s, "vsync-jitter", {prefix="VSync Jitter:", nl="" or o.nl})
end
end
local function append_filters(s, prop, prefix)
local length = 0
local filters = {}
for _,f in ipairs(mp.get_property_native(prop, {})) do
local n = f.name
if f.enabled ~= nil and not f.enabled then
n = n .. " (disabled)"
end
local p = {}
for key,value in pairs(f.params) do
p[#p+1] = key .. "=" .. value
end
if #p > 0 then
p = " [" .. table.concat(p, " ") .. "]"
else
p = ""
end
length = length + n:len() + p:len()
filters[#filters+1] = no_ASS(n) .. it(no_ASS(p))
end
if #filters > 0 then
local ret
if length < o.filter_params_max_length then
ret = table.concat(filters, ", ")
else
local sep = o.nl .. o.indent .. o.indent
ret = sep .. table.concat(filters, sep)
end
s[#s+1] = o.nl .. o.indent .. b(prefix) .. o.prefix_sep .. ret
end
end
local function add_header(s)
s[#s+1] = text_style()
end
local function add_file(s)
append(s, "", {prefix="File:", nl="", indent=""})
append_property(s, "filename", {prefix_sep="", nl="", indent=""})
if not (mp.get_property_osd("filename") == mp.get_property_osd("media-title")) then
append_property(s, "media-title", {prefix="Title:"})
end
local ch_index = mp.get_property_number("chapter")
if ch_index and ch_index >= 0 then
append_property(s, "chapter-list/" .. tostring(ch_index) .. "/title", {prefix="Chapter:"})
append_property(s, "chapter-list/count",
{prefix="(" .. tostring(ch_index + 1) .. "/", suffix=")", nl="",
indent=" ", prefix_sep=" ", no_prefix_markup=true})
end
local demuxer_cache = mp.get_property_native("demuxer-cache-state", {})
if demuxer_cache["fw-bytes"] then
demuxer_cache = demuxer_cache["fw-bytes"] -- returns bytes
else
demuxer_cache = 0
end
local demuxer_secs = mp.get_property_number("demuxer-cache-duration", 0)
local stream_cache = mp.get_property_number("cache-used", 0) * 1024 -- returns KiB
if stream_cache + demuxer_cache + demuxer_secs > 0 then
append(s, utils.format_bytes_humanized(stream_cache + demuxer_cache), {prefix="Total Cache:"})
append(s, utils.format_bytes_humanized(demuxer_cache), {prefix="(Demuxer:",
suffix=",", nl="", no_prefix_markup=true, indent=o.prefix_sep})
append(s, format("%.1f", demuxer_secs), {suffix=" sec)", nl="", indent="",
no_prefix_markup=true})
local speed = mp.get_property_number("cache-speed", 0)
if speed > 0 then
append(s, utils.format_bytes_humanized(speed) .. "/s", {prefix="Speed:", nl="",
indent=o.prefix_sep, no_prefix_markup=true})
end
end
append_property(s, "file-size", {prefix="Size:"})
end
local function add_video(s)
local r = mp.get_property_native("video-params")
-- in case of e.g. lavi-complex there can be no input video, only output
if not r then
r = mp.get_property_native("video-out-params")
end
if not r then
return
end
append(s, "", {prefix=o.nl .. o.nl .. "Video:", nl="", indent=""})
if append_property(s, "video-codec", {prefix_sep="", nl="", indent=""}) then
append_property(s, "hwdec-current", {prefix="(hwdec:", nl="", indent=" ",
no_prefix_markup=true, suffix=")"}, {no=true, [""]=true})
end
append_property(s, "avsync", {prefix="A-V:"})
if append_property(s, compat("decoder-frame-drop-count"),
{prefix="Dropped Frames:", suffix=" (decoder)"}) then
append_property(s, compat("frame-drop-count"), {suffix=" (output)", nl="", indent=""})
end
if append_property(s, "display-fps", {prefix="Display FPS:", suffix=" (specified)"}) then
append_property(s, "estimated-display-fps",
{suffix=" (estimated)", nl="", indent=""})
else
append_property(s, "estimated-display-fps",
{prefix="Display FPS:", suffix=" (estimated)"})
end
if append_property(s, compat("container-fps"), {prefix="FPS:", suffix=" (specified)"}) then
append_property(s, "estimated-vf-fps",
{suffix=" (estimated)", nl="", indent=""})
else
append_property(s, "estimated-vf-fps",
{prefix="FPS:", suffix=" (estimated)"})
end
append_display_sync(s)
append_perfdata(s, o.print_perfdata_passes)
if append(s, r["w"], {prefix="Native Resolution:"}) then
append(s, r["h"], {prefix="x", nl="", indent=" ", prefix_sep=" ", no_prefix_markup=true})
end
append_property(s, "window-scale", {prefix="Window Scale:"})
append(s, format("%.2f", r["aspect"]), {prefix="Aspect Ratio:"})
append(s, r["pixelformat"], {prefix="Pixel Format:"})
-- Group these together to save vertical space
local prim = append(s, r["primaries"], {prefix="Primaries:"})
local cmat = append(s, r["colormatrix"], {prefix="Colormatrix:", nl=prim and "" or o.nl})
append(s, r["colorlevels"], {prefix="Levels:", nl=cmat and "" or o.nl})
-- Append HDR metadata conditionally (only when present and interesting)
local hdrpeak = r["sig-peak"] or 0
local hdrinfo = ""
if hdrpeak > 1 then
hdrinfo = " (HDR peak: " .. format("%.2f", hdrpeak) .. ")"
end
append(s, r["gamma"], {prefix="Gamma:", suffix=hdrinfo})
append_property(s, "packet-video-bitrate", {prefix="Bitrate:", suffix=" kbps"})
append_filters(s, "vf", "Filters:")
end
local function add_audio(s)
local r = mp.get_property_native("audio-params")
-- in case of e.g. lavi-complex there can be no input audio, only output
if not r then
r = mp.get_property_native("audio-out-params")
end
if not r then
return
end
append(s, "", {prefix=o.nl .. o.nl .. "Audio:", nl="", indent=""})
append_property(s, "audio-codec", {prefix_sep="", nl="", indent=""})
append(s, r["format"], {prefix="Format:"})
append(s, r["samplerate"], {prefix="Sample Rate:", suffix=" Hz"})
append(s, r["channel-count"], {prefix="Channels:"})
append_property(s, "packet-audio-bitrate", {prefix="Bitrate:", suffix=" kbps"})
append_filters(s, "af", "Filters:")
end
-- Determine whether ASS formatting shall/can be used and set formatting sequences
local function eval_ass_formatting()
o.use_ass = o.ass_formatting and has_vo_window()
if o.use_ass then
o.nl = o.ass_nl
o.indent = o.ass_indent
o.prefix_sep = o.ass_prefix_sep
o.b1 = o.ass_b1
o.b0 = o.ass_b0
o.it1 = o.ass_it1
o.it0 = o.ass_it0
else
o.nl = o.no_ass_nl
o.indent = o.no_ass_indent
o.prefix_sep = o.no_ass_prefix_sep
if not has_ansi() then
o.b1 = ""
o.b0 = ""
o.it1 = ""
o.it0 = ""
else
o.b1 = o.no_ass_b1
o.b0 = o.no_ass_b0
o.it1 = o.no_ass_it1
o.it0 = o.no_ass_it0
end
end
end
-- Returns an ASS string with "normal" stats
local function default_stats()
local stats = {}
eval_ass_formatting()
add_header(stats)
add_file(stats)
add_video(stats)
add_audio(stats)
return table.concat(stats)
end
-- Returns an ASS string with extended VO stats
local function vo_stats()
local stats = {}
eval_ass_formatting()
add_header(stats)
append_perfdata(stats, true)
return table.concat(stats)
end
-- Returns an ASS string with stats about filters/profiles/shaders
local function filter_stats()
return "coming soon"
end
-- Current page and <page key>:<page function> mapping
curr_page = o.key_page_1
pages = {
[o.key_page_1] = { f = default_stats, desc = "Default" },
[o.key_page_2] = { f = vo_stats, desc = "Extended Frame Timings" },
--[o.key_page_3] = { f = filter_stats, desc = "Dummy" },
}
-- Returns a function to record vsratio/jitter with the specified `skip` value
local function record_data(skip)
init_buffers()
skip = max(skip, 0)
local i = skip
return function()
if i < skip then
i = i + 1
return
else
i = 0
end
if o.plot_vsync_jitter then
local r = mp.get_property_number("vsync-jitter", nil)
if r then
vsjitter_buf.pos = (vsjitter_buf.pos % vsjitter_buf.len) + 1
vsjitter_buf[vsjitter_buf.pos] = r
vsjitter_buf.max = max(vsjitter_buf.max, r)
end
end
if o.plot_vsync_ratio then
local r = mp.get_property_number("vsync-ratio", nil)
if r then
vsratio_buf.pos = (vsratio_buf.pos % vsratio_buf.len) + 1
vsratio_buf[vsratio_buf.pos] = r
vsratio_buf.max = max(vsratio_buf.max, r)
end
end
end
end
-- Call the function for `page` and print it to OSD
local function print_page(page)
if o.persistent_overlay then
mp.set_osd_ass(0, 0, pages[page].f())
else
mp.osd_message(pages[page].f(), display_timer.oneshot and o.duration or o.redraw_delay + 1)
end
end
local function clear_screen()
if o.persistent_overlay then mp.set_osd_ass(0, 0, "") else mp.osd_message("", 0) end
end
-- Add keybindings for every page
local function add_page_bindings()
local function a(k)
return function()
curr_page = k
print_page(k)
if display_timer.oneshot then display_timer:kill() ; display_timer:resume() end
end
end
for k, _ in pairs(pages) do
mp.add_forced_key_binding(k, k, a(k), {repeatable=true})
end
end
-- Remove keybindings for every page
local function remove_page_bindings()
for k, _ in pairs(pages) do
mp.remove_key_binding(k)
end
end
local function process_key_binding(oneshot)
-- Stats are already being displayed
if display_timer:is_enabled() then
-- Previous and current keys were oneshot -> restart timer
if display_timer.oneshot and oneshot then
display_timer:kill()
print_page(curr_page)
display_timer:resume()
-- Previous and current keys were toggling -> end toggling
elseif not display_timer.oneshot and not oneshot then
display_timer:kill()
clear_screen()
remove_page_bindings()
if recorder then
mp.unregister_event(recorder)
recorder = nil
end
end
-- No stats are being displayed yet
else
if not oneshot and (o.plot_vsync_jitter or o.plot_vsync_ratio) then
recorder = record_data(o.skip_frames)
mp.register_event("tick", recorder)
end
display_timer:kill()
display_timer.oneshot = oneshot
display_timer.timeout = oneshot and o.duration or o.redraw_delay
add_page_bindings()
print_page(curr_page)
display_timer:resume()
end
end
-- Create the timer used for redrawing (toggling) or clearing the screen (oneshot)
-- The duration here is not important and always set in process_key_binding()
display_timer = mp.add_periodic_timer(o.duration,
function()
if display_timer.oneshot then
display_timer:kill() ; clear_screen() ; remove_page_bindings()
else
print_page(curr_page)
end
end)
display_timer:kill()
-- Single invocation key binding
mp.add_key_binding(o.key_oneshot, "display-stats", function() process_key_binding(true) end,
{repeatable=true})
-- Toggling key binding
mp.add_key_binding(o.key_toggle, "display-stats-toggle", function() process_key_binding(false) end,
{repeatable=false})
-- Single invocation bindings without key, can be used in input.conf to create
-- bindings for a specific page: "e script-binding stats/display-page-2"
for k, _ in pairs(pages) do
mp.add_key_binding(nil, "display-page-" .. k, function() process_key_binding(true) end,
{repeatable=true})
end
-- Reprint stats immediately when VO was reconfigured, only when toggled
mp.register_event("video-reconfig",
function()
if display_timer:is_enabled() then
print_page(curr_page)
end
end)

92
mpv/scripts/status-line.lua Executable file
View File

@ -0,0 +1,92 @@
-- Rebuild the terminal status line as a lua script
-- Be aware that this will require more cpu power!
-- Also, this is based on a rather old version of the
-- builtin mpv status line.
-- Add a string to the status line
function atsl(s)
newStatus = newStatus .. s
end
function update_status_line()
-- Reset the status line
newStatus = ""
if mp.get_property_bool("pause") then
atsl("(Paused) ")
elseif mp.get_property_bool("paused-for-cache") then
atsl("(Buffering) ")
end
if mp.get_property("aid") ~= "no" then
atsl("A")
end
if mp.get_property("vid") ~= "no" then
atsl("V")
end
atsl(": ")
atsl(mp.get_property_osd("time-pos"))
atsl(" / ");
atsl(mp.get_property_osd("duration"));
atsl(" (")
atsl(mp.get_property_osd("percent-pos", -1))
atsl("%)")
local r = mp.get_property_number("speed", -1)
if r ~= 1 then
atsl(string.format(" x%4.2f", r))
end
r = mp.get_property_number("avsync", nil)
if r ~= nil then
atsl(string.format(" A-V: %f", r))
end
r = mp.get_property("total-avsync-change", 0)
if math.abs(r) > 0.05 then
atsl(string.format(" ct:%7.3f", r))
end
r = mp.get_property_number("decoder-drop-frame-count", -1)
if r > 0 then
atsl(" Late: ")
atsl(r)
end
r = mp.get_property_osd("video-bitrate")
if r ~= nil and r ~= "" then
atsl(" Vb: ")
atsl(r)
end
r = mp.get_property_osd("audio-bitrate")
if r ~= nil and r ~= "" then
atsl(" Ab: ")
atsl(r)
end
r = mp.get_property_number("cache", 0)
if r > 0 then
atsl(string.format(" Cache: %d%% ", r))
end
-- Set the new status line
mp.set_property("options/term-status-msg", newStatus)
end
timer = mp.add_periodic_timer(1, update_status_line)
function on_pause_change(name, value)
if value == false then
timer:resume()
else
timer:stop()
end
mp.add_timeout(0.1, update_status_line)
end
mp.observe_property("pause", "bool", on_pause_change)
mp.register_event("seek", update_status_line)

83
mpv/scripts/tv.lua Normal file
View File

@ -0,0 +1,83 @@
-- Simple script for configurable TV out activation and/or deactivation on mpv playback
--
-- Intended to activate TV on mpv startup and deactivate TV on mpv close if TV is connected.
-- The script executes fully configurable shell sequences (e.g. xrandr on linux)
-- Can also be used for activating ambient lighting while watching etc ...
--
-- Note: There are implicit security issues due to a nature of direct execution
-- of command line tools without any sanitization ...
--
-- TV configurable options:
-- test ... check if TV is connected (result is non empty, exitcode 0)
-- on ... executed once on mpv player startup (TV ON)
-- off ... executed once on mpv player shutdown (TV OFF)
--
-- Note: xrandr seems to have problem turning off and on devices on single execution.
-- Therefore it is wise to split execution to multiple commands, for example:
-- problem : xrandr --output LVDS1 --off --output TV1 --auto
-- works ok: xrandr --output LVDS1 --off && xrandr --output TV1 --auto
--
-- To customize configuration place tv.conf into ~/.config/mpv/lua-settings/ and edit
--
-- Place script into ~/.config/mpv/scripts/ for autoload
--
-- GitHub: https://github.com/blue-sky-r/mpv/tree/master/scripts
local options = require("mp.options")
local utils = require("mp.utils")
-- defaults
local cfg = {
test = "xrandr | grep 'VGA1 connected'",
on = 'xrandr --output LVDS1 --off && xrandr --output VGA1 --mode 720x400 --output TV1 --auto',
off = 'xrandr --output LVDS1 --auto'
}
-- string v is empty
local function empty(v)
return not v or v == '' or string.find(v,"^%s*$")
end
-- evaluate shell condition by executing cmd
local function test(cmd)
-- return success if there is nothing to test
if empty(cmd) then return true end
-- get only exitcode
local exitcode = io.popen(cmd..' >/dev/null 2>&1; echo $?'):read('*n')
-- log
mp.msg.info("test '" .. cmd .. "' returned exitcode:"..exitcode)
-- success if exitcode is zero
return exitcode == 0
end
-- execute shell cmd
local function exec(cmd)
-- return if there is nothing to execute
if empty(cmd) then return end
-- get stdout and stderr combined
local stdcom = io.popen(cmd..' 2>&1'):read('*all')
-- log
mp.msg.info("exec '" .. cmd .. "'")
if stdcom then mp.msg.verbose(stdcom) end
end
-- read lua-settings/tv.conf
options.read_options(cfg, 'tv')
-- log active config
mp.msg.verbose('cfg = '..utils.to_string(cfg))
-- execute only if test condition
if test(cfg.test) then
-- optional TV.ON execute now
if not empty(cfg.on) then exec(cfg.on) end
-- optional TV.OFF execute on shutdown
if not empty(cfg.off) then
mp.register_event("shutdown",
function()
exec(cfg.off)
end
)
end
end

View File

@ -0,0 +1,24 @@
-- this script periodically deactivates xscreensaver
-- when video playback is active
local function heartbeat()
if mp.get_property_native("pause") or
mp.get_property_native("idle") or
not mp.get_property_native("vo-configured") then
return
end
mp.command_native_async(
{
name = "subprocess",
args = { "xscreensaver-command", "-deactivate" },
capture_stdout = true,
},
function () end)
end
mp.add_periodic_timer(60, heartbeat)
for _, prop in ipairs({"pause", "idle", "vo-configured"}) do
mp.observe_property(prop, nil, heartbeat)
end

View File

@ -82,6 +82,7 @@ if has('nvim')
" Plug 'TimUntersberger/neogit' " Plug 'TimUntersberger/neogit'
Plug 'akinsho/bufferline.nvim' Plug 'akinsho/bufferline.nvim'
Plug 'andweeb/presence.nvim'
Plug 'f-person/git-blame.nvim' Plug 'f-person/git-blame.nvim'
Plug 'folke/which-key.nvim' Plug 'folke/which-key.nvim'
Plug 'glepnir/dashboard-nvim' Plug 'glepnir/dashboard-nvim'
@ -137,6 +138,7 @@ if has('nvim')
source ~/.config/nvim/keybindings.vim source ~/.config/nvim/keybindings.vim
source ~/.config/nvim/plugin-confs/bufferline.lua source ~/.config/nvim/plugin-confs/bufferline.lua
source ~/.config/nvim/plugin-confs/presence.lua
source ~/.config/nvim/plugin-confs/dashboard-art.vim source ~/.config/nvim/plugin-confs/dashboard-art.vim
source ~/.config/nvim/plugin-confs/dashboard-nvim.lua source ~/.config/nvim/plugin-confs/dashboard-nvim.lua
source ~/.config/nvim/plugin-confs/git-blame.lua source ~/.config/nvim/plugin-confs/git-blame.lua

View File

@ -44,6 +44,7 @@ nmap <leader>bp :bprev<CR>
nmap <leader>ca :lua vim.lsp.buf.code_action()<CR> nmap <leader>ca :lua vim.lsp.buf.code_action()<CR>
nmap <leader>cd :LspDiagnostics <bufnr><CR> nmap <leader>cd :LspDiagnostics <bufnr><CR>
nmap <leader>cl :lua vim.lsp.diagnostic.show_line_diagnostics()<CR>
nnoremap <silent> <Leader>cn :DashboardNewFile<CR> nnoremap <silent> <Leader>cn :DashboardNewFile<CR>
nmap <leader>ff :CocCommand fzf-preview.ProjectFiles<CR> nmap <leader>ff :CocCommand fzf-preview.ProjectFiles<CR>

View File

@ -0,0 +1,22 @@
require("presence"):setup({
-- General options
auto_update = true, -- Update activity based on autocmd events (if `false`, map or manually execute `:lua package.loaded.presence:update()`)
neovim_image_text = "The One True Text Editor", -- Text displayed when hovered over the Neovim image
main_image = "neovim", -- Main image display (either "neovim" or "file")
-- client_id = "793271441293967371", -- Use your own Discord application client id (not recommended)
log_level = nil, -- Log messages at or above this level (one of the following: "debug", "info", "warn", "error")
debounce_timeout = 10, -- Number of seconds to debounce events (or calls to `:lua package.loaded.presence:update(<filename>, true)`)
enable_line_number = false, -- Displays the current line number instead of the current project
blacklist = {}, -- A list of strings or Lua patterns that disable Rich Presence if the current file name, path, or workspace matches
buttons = true, -- Configure Rich Presence button(s), either a boolean to enable/disable, a static table (`{{ label = "<label>", url = "<url>" }, ...}`, or a function(buffer: string, repo_url: string|nil): table)
file_assets = {}, -- Custom file asset definitions keyed by file names and extensions (see default config at `lua/presence/file_assets.lua` for reference)
-- Rich Presence text options
editing_text = "Editing %s", -- Format string rendered when an editable file is loaded in the buffer (either string or function(filename: string): string)
file_explorer_text = "Browsing %s", -- Format string rendered when browsing a file explorer (either string or function(file_explorer_name: string): string)
git_commit_text = "Committing changes", -- Format string rendered when committing changes in git (either string or function(filename: string): string)
plugin_manager_text = "Managing plugins", -- Format string rendered when managing plugins (either string or function(plugin_manager_name: string): string)
reading_text = "Reading %s", -- Format string rendered when a read-only or unmodifiable file is loaded in the buffer (either string or function(filename: string): string)
workspace_text = "Working on %s", -- Format string rendered when in a git repository (either string or function(project_name: string|nil, filename: string): string)
line_number_text = "Line %s out of %s", -- Format string rendered when `enable_line_number` is set to true (either string or function(line_number: number, line_count: number): string)
})