# mpv auto fullscreen fix:
# windowrulev2 = suppressevent fullscreen,class:^(mpv.*)$
# needs this in mpv's input.conf:
# f run "/bin/sh" "-c" "hyprctl dispatch fullscreen toggle"; cycle fullscreen

# using mvtools frame interpolation vapoursynth filter - needs mvtools python package:
ü vf toggle format=yuv420p,vapoursynth="~/.config/mpv/filters/motioninterpolation-mvtools.vpy":4:4

### cool profiles function:
# _ set profile FrameInterpolation #menu: Profiles > profile FrameInterpolation


### SEEKING ###
# Relative Seeking
#Shift+RIGHT seek  1 exact
#Shift+LEFT  seek -1 exact
#RIGHT       seek  5 exact ; script-binding uosc/flash-timeline
#LEFT        seek -5 exact ; script-binding uosc/flash-timeline
#Shift+DOWN  seek  5       ; script-binding uosc/flash-timeline
#Shift+UP    seek -5       ; script-binding uosc/flash-timeline
#DOWN        seek  60      ; script-binding uosc/flash-timeline
#UP          seek -60      ; script-binding uosc/flash-timeline
#Shift+PGDWN seek  600     ; script-binding uosc/flash-timeline
#Shift+PGUP  seek -600     ; script-binding uosc/flash-timeline

# Absolute seeking
HOME osd-msg seek   0 absolute; set pause no
END  osd-msg seek 100 absolute-percent

Ctrl+1 osd-msg seek  10 absolute-percent;set pause no
Ctrl+2 osd-msg seek  20 absolute-percent;set pause no
Ctrl+3 osd-msg seek  30 absolute-percent;set pause no
Ctrl+4 osd-msg seek  40 absolute-percent;set pause no
Ctrl+5 osd-msg seek  50 absolute-percent;set pause no
Ctrl+6 osd-msg seek  60 absolute-percent;set pause no
Ctrl+7 osd-msg seek  70 absolute-percent;set pause no
Ctrl+8 osd-msg seek  80 absolute-percent;set pause no
Ctrl+9 osd-msg seek  90 absolute-percent;set pause no
Ctrl+0 osd-msg seek   0 absolute; set pause no


# generate thumbnails using the mpv_thumbnail_script
# https://github.com/TheAMM/mpv_thumbnail_script#configuration
alt+s script-binding generate-thumbnails

del script-message osc-visibility cycle

#DEL script-message cycle-cmd "script-message osc-visibility always" "set osd-level 1; script-message osc-visibility never"


# File and chapter seeking
#PGUP add chapter -1
#PGDWN add chapter 1
#Ctrl+PGUP playlist-prev
#Ctrl+PGDWN playlist-next
#Ctrl+z osd-msg-bar revert-seek

# Skip to previous/next subtitle (subject to some restrictions; see manpage)
#Alt+LEFT   no-osd sub-seek -1
#Alt+RIGHT  no-osd sub-seek  1

# Seek with ctrl+mouse wheel
#Ctrl+AXIS_UP   osd-msg-bar seek  2
#Ctrl+AXIS_DOWN osd-msg-bar seek -2


### UNSET BINDINGS TO BE REBOUND ###
#r ignore
#R ignore
s ignore
#e ignore
g ignore
#w ignore
#z ignore
#x ignore
#r ignore
#t ignore
#T ignore
#v ignore
#V ignore
#_ ignore
#SHARP ignore


### TOGGLE/CYCLE STUFF ###
#z-c cycle-values audio-channels auto-safe mono
#z-d cycle deband
#z-D cycle deinterlace
#z-y vf toggle yadif
#z-i cycle interpolation
#z-s cycle sub-visibility
#z-a cycle mute
#z-v cycle sub-ass-vsfilter-aspect-compat
#z-T cycle ontop
#z-r cycle-values video-aspect "16:9" "4:3" "2.35:1" "-1"
#z-t cycle-values tscale "box" "oversample" "linear" "catmull_rom" "mitchell" "gaussian" "bicubic"
#z-o cycle-values ass-style-override "yes" "force" "no"
#z-w cycle force-window
#z-f cycle osd-fractions
#z-b cycle-values blend-subtitles "yes" "no" "video"

# GLSL Shaders
#g-g change-list glsl-shaders clr ""
#g-r change-list glsl-shaders toggle "/usr/share/mpv-prescalers/vulkan/ravu-r3.hook"
#g-R change-list glsl-shaders toggle "/usr/share/mpv-prescalers/compute/ravu-r3.hook"
#g-l change-list glsl-shaders toggle "~~/shaders/noise_static_luma.hook"
#g-k change-list glsl-shaders toggle "~~/shaders/KrigBilateral.glsl"
#g-f change-list glsl-shaders toggle "~~/shaders/kyoani_fog.glsl"

# tracks/editions
# see uosc bindings at the end
#e cycle edition
#E cycle edition down


### MISC ###

# Volume control (with uosc calls)
#m           cycle mute    ; script-binding uosc/flash-volume
#WHEEL_UP    add volume  5 ; script-binding uosc/flash-volume
#WHEEL_DOWN  add volume -5 ; script-binding uosc/flash-volume
#9           add volume -5 ; script-binding uosc/flash-volume
#0           add volume  5 ; script-binding uosc/flash-volume

# Absolute window resizing
Alt+1 set window-scale 0.5
Alt+2 set window-scale 1.0
Alt+3 set window-scale 1.5
Alt+4 set window-scale 2.0
#Alt+5 autofit something

# Relative window resizing
#Alt+- multiply window-scale 1/1.25
#Alt++ multiply window-scale 1.25

# Playback speed (with uosc calls)
[ multiply speed 1/1.1 ; script-binding uosc/flash-speed
] multiply speed 1.1   ; script-binding uosc/flash-speed
{ multiply speed 0.5   ; script-binding uosc/flash-speed
} multiply speed 2.0   ; script-binding uosc/flash-speed
BS     set speed 1     ; script-binding uosc/flash-speed

s multiply speed 1/1.1 ; script-binding uosc/flash-speed
d multiply speed 1.1   ; script-binding uosc/flash-speed
g set speed 1.6   ; script-binding uosc/flash-speed
G set speed 1     ; script-binding uosc/flash-speed

# Subtitle adjustments
#h add sub-delay -0.041708333333 # shift subs (by 1 frame, assuming 24fps)
#l add sub-delay 0.041708333333
#j add sub-pos 1
#k add sub-pos -1

# Other
#Ctrl+l cycle-values loop "inf" "no"
#Ctrl+s screenshot subtitles
#S      screenshot video # rebind; s is used for subtitle selection
#P print-text "$filename $time-pos $estimated-frame-number"
#F10 show_text ${chapter-list}
#c show_text ${chapter-list}

#<key> script-message osc-chapterlist <optional-duration-in-seconds>
F10 script-message osc-chapterlist 2
c script-message osc-chapterlist 2


# Do stuff with ${path}
#F run firefox "${path}"; show-text "Opening in FireFox"
#C run zsh -c "echo -n '${path}' | xclip -sel c"; show-text "Copied path to clipboard"

# Copy stuff to clipboard
y-y run zsh -c "echo -n '${path}'| xclip -sel c"; show-text "Copied path to clipboard"
y-p run zsh -c "echo -n '${path}'| xclip -sel c"; show-text "Copied path to clipboard"
y-t run zsh -c "echo -n '${time-pos}' | xclip -sel c"; show-text "Copied timestamp to clipboard"
y-T run zsh -c "echo -n '${media-title} [${time-pos}/${duration}]' | xclip -sel c"; show-text "Copied title+timestamp to clipboard"
# time-code with fractions
#y-f run python -c "import pyperclip; timeform = r\"${time-pos}\"; timemill = r\"${=time-pos}\"; time = timeform+timemill[-7:-3]; pyperclip.copy(time)"; show-text "Copied timestamp to clipboard"

# Open help and config files
F1 run xdg-open https://mpv.io/manual/stable/
F2 run nvim ~/.config/mpv/mpv.conf
F3 run nvim ~/.config/mpv/input.conf
F4 run nvim ~/.config/mpv/default-input.conf

### SCRIPTS ###
#r       script-message-to reload reload_resume
#Alt+w   script-message-to webm display-webm-encoder
#Alt+r   script-message-to cycle_video_rotate Cycle_Video_Rotate 90
#z-p     script-message-to pitchcontrol toggle
#Alt+c   script-message-to crop start-crop
#Ctrl+v  script-message-to appendURL appendURL
#G       script-binding seek_to/toggle-seeker

#Alt+g   script-binding sponsorblock/set_segment
#Alt+G   script-binding sponsorblock/submit_segment
#Alt+h   script-binding sponsorblock/upvote
#Alt+H   script-binding sponsorblock/downvote

### uosc ###
#tab         script-binding uosc/peek-timeline
#MBTN_MID    script-binding uosc/menu
#menu        script-binding uosc/menu

#p           script-binding uosc/playlist           #! Navigate playlist
#c           script-binding uosc/chapters           #! Navigate chapters
#v           script-binding uosc/video              #! Tracks > Select video
#Ctrl+a           script-binding uosc/audio              #! Tracks > Select audio
#Ctl+s           script-binding uosc/subtitles          #! Tracks > Select subtitles
#           script-binding uosc/load-subtitles     #! Tracks > Load subtitles
#           script-binding uosc/navigate-directory #! Utils > Navigate directory
#           script-binding uosc/show-in-directory  #! Utils > Show in directory
#q           quit                                   #! Quit

## Cheat sheet for bindings bound by scripts directly ##
# Ctrl+f change ytdl quality
# Ctrl+r reload in-place / also bound to "r" above
#
## Playlist manager ##
# Shift+ enter open/close
# p save playlist to $XDG_CACHE_DIR/mpv
# Ctrl+p sort playlist
# Backspace remove current item
# RIGHT select item to move in the playlist (using up/down)
# ü vf toggle format=yuv420p,vapoursynth=~~/motioninterpolation.vpy:4:4
# ü cycle interpolation
# Ü cycle-values tscale "oversample" "linear" "catmull_rom" "mitchell"


# Alt+ü vf toggle format=yuv420p,vapoursynth="~/.config/mpv/filters/motioninterpolation.vpy":4:4
# Alt+ü vf toggle format=yuv420p,vapoursynth="~/.config/mpv/filters/mvtools.vpy":4:4
