mpv config

This commit is contained in:
chayleaf 2023-02-20 06:59:00 +07:00
parent 159542369d
commit e11b6598df
3 changed files with 172 additions and 9 deletions

View file

@ -28,14 +28,165 @@
# TODO sort out this mess with colors
programs.mpv = {
enable = true;
defaultProfiles = [ "main" ];
profiles.main = {
vo = "vdpau";
defaultProfiles = [ "gpu-hq" ];
bindings = rec {
MBTN_LEFT_DBL = "cycle fullscreen";
MBTN_RIGHT = "cycle pause";
MBTN_BACK = "playlist-prev";
MBTN_FORWARD = "playlist-next";
WHEEL_DOWN = "seek -5";
WHEEL_UP = "seek 5";
WHEEL_LEFT = "seek -60";
WHEEL_RIGHT = "seek 60";
h = "no-osd seek -5 exact";
LEFT = h;
l = "no-osd seek 5 exact";
RIGHT = l;
j = "seek -30";
DOWN = j;
k = "seek 30";
UP = k;
H = "no-osd seek -1 exact";
"Shift+LEFT" = "no-osd seek -1 exact";
L = "no-osd seek 1 exact";
"Shift+RIGHT" = "no-osd seek 1 exact";
J = "seek -300";
"Shift+DOWN" = "seek -300";
K = "seek 300";
"Shift+UP" = "seek 300";
"Ctrl+LEFT" = "no-osd sub-seek -1";
"Ctrl+h" = "no-osd sub-seek -1";
"Ctrl+RIGHT" = "no-osd sub-seek 1";
"Ctrl+l" = "no-osd sub-seek 1";
"Ctrl+DOWN" = "add chapter -1";
"Ctrl+j" = "add chapter -1";
"Ctrl+UP" = "add chapter 1";
"Ctrl+k" = "add chapter 1";
"Alt+LEFT" = "frame-back-step";
"Alt+h" = "frame-back-step";
"Alt+RIGHT" = "frame-step";
"Alt+l" = "frame-step";
PGUP = "add chapter 1";
PGDWN = "add chapter -1";
u = "revert-seek";
"Ctrl++" = "add sub-scale 0.1";
"Ctrl+-" = "add sub-scale -0.1";
"Ctrl+0" = "set sub-scale 0";
q = "quit";
Q = "quit-watch-later";
"q {encode}" = "quit 4";
p = "cycle pause";
SPACE = p;
f = "cycle fullscreen";
n = "playlist-next";
N = "playlist-prev";
o = "show-progress";
O = "script-binding stats/display-stats-toggle";
"`" = "script-binding console/enable";
":" = "script-binding console/enable";
z = "add sub-delay -0.1";
x = "add sub-delay 0.1";
Z = "add audio-delay -0.1";
X = "add audio-delay 0.1";
"1" = "add volume -1";
"2" = "add volume 1";
s = "cycle sub";
v = "cycle video";
a = "cycle audio";
S = ''cycle-values sub-ass-override "force" "no"'';
PRINT = "screenshot";
c = "add panscan 0.1";
C = "add panscan -0.1";
PLAY = "cycle pause";
PAUSE = "cycle pause";
PLAYPAUSE = "cycle pause";
PLAYONLY = "set pause no";
PAUSEONLY = "set pause yes";
STOP = "stop";
CLOSE_WIN = "quit";
"CLOSE_WIN {encode}" = "quit 4";
"Ctrl+w" = ''set hwdec "no"'';
# T = "script-binding generate-thumbnails";
};
config = {
osc = "no";
hwdec = "vaapi";
vo = "gpu-next,gpu,dmabuf-wayland,wlshm,vdpau,xv,x11,sdl,drm,";
alang = "jpn,en,ru";
slang = "jpn,en,ru";
vlang = "jpn,en,ru";
watch-later-directory = "${config.xdg.stateHome}/mpv/watch_later";
resume-playback-check-mtime = true;
# vaapi-device / vulkan-device
# screen / vulkan-display-display
audio-device = "pipewire";
ao = "pipewire,pulse,alsa,jack,";
audio-file-auto = "fuzzy";
sub-auto = "fuzzy";
gpu-context = "waylandvk";
wayland-edge-pixels-pointer = 0;
wayland-edge-pixels-touch = 0;
screenshot-format = "webp";
screenshot-webp-lossless = true;
screenshot-directory = "${config.home.homeDirectory}/Pictures/Screenshots/mpv";
screenshot-sw = true;
cache-dir = "${config.xdg.cacheHome}/mpv";
input-default-bindings = false;
};
# profiles = {};
package = pkgs.wrapMpv (pkgs.mpv-unwrapped.override {
ffmpeg_5 = pkgs.ffmpeg_5-full;
}) {
scripts =
let subserv = (port: secondary:
(pkgs.stdenv.mkDerivation {
pname = "subserv-mpv-plugin";
version = "0.1";
src = pkgs.fetchFromGitHub {
owner = "kaervin";
repo = "subserv-mpv-plugin";
rev = "08e312f02f3d3608d61944247d39148c34215f75";
sha256 = "sha256-CXyp+AAgyocAEbhuMMPVDlAiocozPe8tm/dIUofCRL8=";
};
buildInputs = with pkgs; [ mpv-unwrapped ];
installFlags = [ "SCRIPTS_DIR=$(out)/share/mpv/scripts" ];
stripDebugList = [ "share/mpv/scripts" ];
passthru.scriptName = "subserv.so";
patchPhase = ''
sed -i 's%<client.h>%<mpv/client.h>%' subserv.c
sed -i 's%printf("Hello%// printf("Hello%' subserv.c
sed -i 's%printf("Got event%// printf("Got event%' subserv.c
sed -i 's/PORT 8080/PORT ${builtins.toString port}/' subserv.c
'' + (if secondary then ''
sed -i 's/sub-text/secondary-sub-text/g' subserv.c
'' else "");
buildPhase = ''
gcc -o subserv.so subserv.c -shared -fPIC
'';
installPhase = ''
mkdir -p $out/share/mpv/scripts
cp subserv.so $out/share/mpv/scripts
'';
}));
in with pkgs.mpvScripts; [
thumbnail
mpris
(subserv 1337 false)
(subserv 1338 true)
];
};
scripts = [ ];
};
i18n.inputMethod = let fcitx5-qt = pkgs.libsForQt5.fcitx5-qt; in {
enabled = "fcitx5";
@ -131,7 +282,7 @@
keepassxc nheko qbittorrent mumble
nextcloud-client gnome.zenity kdeconnect
# cli tools
imagemagick ffmpeg
imagemagick ffmpeg_5-full
# fonts
noto-fonts noto-fonts-cjk noto-fonts-emoji
(nerdfonts.override { fonts = [ "NerdFontsSymbolsOnly" ]; })

View file

@ -1,6 +1,8 @@
{ options, config, pkgs, lib, ... }:
let
modifier = "Mod4";
rofiSway = config.programs.rofi.finalPackage;
rofiI3 = pkgs.rofi.override { plugins = config.programs.rofi.plugins; };
barConfig = {
mode = "dock";
hiddenState = "hide";
@ -169,8 +171,9 @@ in
statusCommand = "${pkgs.i3status}/bin/i3status";
})
];
menu = "${pkgs.rofi}/bin/rofi -show drun";
menu = "${rofiI3}/bin/rofi -show drun";
keybindings = genKeybindings options.xsession.windowManager.i3 {
"${modifier}+c" = "exec ${rofiI3}/bin/rofi -show calc -no-show-match -no-sort -no-persist-history";
XF86AudioRaiseVolume = "exec ${pkgs.pamixer}/bin/pamixer --increase 5";
XF86AudioLowerVolume = "exec ${pkgs.pamixer}/bin/pamixer --decrease 5";
XF86AudioMute = "exec ${pkgs.pamixer}/bin/pamixer --toggle-mute";
@ -262,6 +265,7 @@ in
"Scroll_Lock"
"exec ${pkgs.mumble}/bin/mumble rpc stoptalking")
// {
"${modifier}+c" = "exec ${rofiSway}/bin/rofi -show calc -no-show-match -no-sort -no-persist-history";
"${modifier}+Print" = "exec ${grimshot}/bin/grimshot copy area";
"${modifier}+Mod1+Print" = "exec ${grimshot}/bin/grimshot copy window";
"--locked XF86AudioRaiseVolume" = "exec ${pkgs.pamixer}/bin/pamixer --increase 5";
@ -293,7 +297,7 @@ in
xkb_options = "compose:ralt,grp:win_space_toggle";
};
};
menu = "${pkgs.rofi-wayland}/bin/rofi -show drun";
menu = "${rofiSway}/bin/rofi -show drun";
}; in commonConfig // swayConfig;
extraSessionCommands = ''
export SDL_VIDEODRIVER=wayland
@ -322,9 +326,14 @@ in
{ timeout = 300;
command = "${pkgs.sway}/bin/swaymsg \"output * dpms off\"";
resumeCommand = "${pkgs.sway}/bin/swaymsg \"output * dpms on\""; }
{ timeout = 598;
command = "${pkgs.sway}/bin/swaymsg \"output * dpms on\""; }
{ timeout = 600;
command = swaylock-start;
resumeCommand = "${pkgs.sway}/bin/swaymsg \"output * dpms on\""; }
{ timeout = 602;
command = "${pkgs.sway}/bin/swaymsg \"output * dpms off\"";
resumeCommand = "${pkgs.sway}/bin/swaymsg \"output * dpms on\""; }
];
};
programs.swaylock.settings = rec {
@ -375,7 +384,7 @@ in
] else [];
programs.rofi = {
enable = true;
font = "Noto Sans Mono 12";
font = "Noto Sans Mono 16";
package = lib.mkIf config.wayland.windowManager.sway.enable pkgs.rofi-wayland;
plugins = with pkgs; [
rofi-calc
@ -417,9 +426,11 @@ in
};
terminal = config.terminalBin;
extraConfig = {
modi = [ "calc" "drun" "run" "ssh" ];
icon-theme = "hicolor";
drun-match-fields = "name,generic,exec,keywords";
drun-match-fields = [ "name" "generic" "exec" "keywords" ];
show-icons = true;
matching = "fuzzy";
sort = true;
sorting-method = "fzf";
steal-focus = true;

View file

@ -5,3 +5,4 @@ fetch.url = "https://github.com/GloriousEggroll/proton-ge-custom/releases/downlo
[yomichan]
src.github = "FooSoft/yomichan"
fetch.url = "https://github.com/FooSoft/yomichan/releases/download/$ver/yomichan-firefox-dev.xpi"