From 3b97bf86dd0a510bb196eac5230bc3e03240b91d Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sat, 24 Aug 2024 19:51:35 +0200 Subject: ... --- accounts/gkleen@sif/default.nix | 4 +- accounts/gkleen@sif/hyprland.nix | 2 +- user-profiles/mpv/default.nix | 161 +++++++++++++++++++++++---------------- 3 files changed, 100 insertions(+), 67 deletions(-) diff --git a/accounts/gkleen@sif/default.nix b/accounts/gkleen@sif/default.nix index 61769adb..87c7a437 100644 --- a/accounts/gkleen@sif/default.nix +++ b/accounts/gkleen@sif/default.nix @@ -201,7 +201,9 @@ in { gpu-api = "vulkan"; }; - zsh.initExtra = "source ${./zshrc}"; + zsh.initExtra = '' + source ${./zshrc} + ''; zsh.dirHashes = let flakeHashes = mapAttrs' (n: v: nameValuePair (inputNames.${n} or n) (toString v)) flakeInputs; inputNames = { diff --git a/accounts/gkleen@sif/hyprland.nix b/accounts/gkleen@sif/hyprland.nix index 50b019ca..052f35b0 100644 --- a/accounts/gkleen@sif/hyprland.nix +++ b/accounts/gkleen@sif/hyprland.nix @@ -88,7 +88,7 @@ in { kb_layout = "us,us"; kb_variant = "dvp,"; kb_model = ""; - kb_options = "compose:caps,grp:win_space_toggle,grp:alt_shift_toggle"; + kb_options = "compose:caps,grp:win_space_toggle"; kb_rules = ""; follow_mouse = 1; diff --git a/user-profiles/mpv/default.nix b/user-profiles/mpv/default.nix index 065b44ac..8fc38edd 100644 --- a/user-profiles/mpv/default.nix +++ b/user-profiles/mpv/default.nix @@ -3,6 +3,102 @@ home-manager.users.${userName} = { programs.mpv = { enable = true; + package = pkgs.symlinkJoin { + inherit (pkgs.mpv) name; + paths = [(pkgs.mpv.override { + scripts = [ + (pkgs.stdenv.mkDerivation (sources.mpv-reload // rec { + installPhase = '' + install -d $out/share/mpv/scripts + install -m 0644 reload.lua $out/share/mpv/scripts/${passthru.scriptName} + ''; + + passthru.scriptName = "reload.lua"; + })) + (pkgs.stdenv.mkDerivation (sources.mpv-createchapter // rec { + installPhase = '' + install -d $out/share/mpv/scripts + install -m 0644 createchapter.lua $out/share/mpv/scripts/${passthru.scriptName} + ''; + + passthru.scriptName = "createchapter.lua"; + })) + (pkgs.stdenv.mkDerivation (sources.mpv-autosave // rec { + installPhase = '' + install -d $out/share/mpv/scripts + install -m 0644 autosave.lua $out/share/mpv/scripts/${passthru.scriptName} + ''; + + passthru.scriptName = "autosave.lua"; + })) + (pkgs.stdenv.mkDerivation (sources.mpv-mpris // rec { + installPhase = '' + install -d $out/share/mpv/scripts + install -m 0644 mpris.so $out/share/mpv/scripts/${passthru.scriptName} + ''; + + nativeBuildInputs = with pkgs; [ pkg-config glib mpv ffmpeg.dev ]; + + passthru.scriptName = "mpris.so"; + })) + (pkgs.stdenv.mkDerivation (sources.mpv-chapterskip // rec { + installPhase = '' + install -d $out/share/mpv/scripts + install -m 0644 chapterskip.lua $out/share/mpv/scripts/${passthru.scriptName} + ''; + + passthru.scriptName = "chapterskip.lua"; + })) + (pkgs.stdenv.mkDerivation (sources.mpv-subselect // rec { + installPhase = '' + install -d $out/share/mpv/scripts + install -m 0644 sub-select.lua $out/share/mpv/scripts/${passthru.scriptName} + ''; + + passthru.scriptName = "sub-select.lua"; + })) + (pkgs.stdenv.mkDerivation (sources.mpv-youtube-quality // rec { + patches = [ + (pkgs.fetchpatch { url = "https://github.com/jgreco/mpv-youtube-quality/pull/31.patch"; hash = "sha256-2aTTkW48uRe8XC1ZQ8J5T9sUmZ5F3YAoYCMxqEs2AY8="; }) + (pkgs.fetchpatch { url = "https://github.com/jgreco/mpv-youtube-quality/pull/20.patch"; hash = "sha256-X5BwDsxziYbeiQvrBt8+IS+6oH1i0LvaaYtugL790gg="; }) + ]; + + installPhase = '' + install -d $out/share/mpv/scripts + install -m 0644 youtube-quality.lua $out/share/mpv/scripts/${passthru.scriptName} + ''; + + passthru.scriptName = "youtube-quality.lua"; + })) + ]; + })]; + buildInputs = [ pkgs.makeWrapper ]; + postBuild = '' + makeWrapper $out/bin/mpv $out/bin/mpvrm \ + --add-flags "--script=${pkgs.writeTextDir "share/mpv/scripts/delete.lua" '' + del_path = ''' + do_del = false + + mp.add_hook('on_load', 50, function() + del_path = ''' + end) + mp.add_hook('on_unload', 50, function() + del_path = mp.get_property('path') + end) + + mp.add_key_binding('Ctrl+q', function() + do_del = true + mp.commandv('quit', '4') + end) + mp.register_event('end-file', function(params) + if (params.reason == 'eof' or (do_del and params.reason == 'quit')) and del_path ~= ''' then + print('deleting: '..del_path) + os.remove(del_path) + end + end) + ''}/share/mpv/scripts/delete.lua" + ''; + }; bindings = { # "CTRL+n" = "af toggle \"lavfi=[dynaudnorm=f=100:g=31:s=20.0]\""; }; @@ -56,71 +152,6 @@ ]; watch-later-options = lib.concatStringsSep "," [ "start" ]; }; - scripts = [ - (pkgs.stdenv.mkDerivation (sources.mpv-reload // rec { - installPhase = '' - install -d $out/share/mpv/scripts - install -m 0644 reload.lua $out/share/mpv/scripts/${passthru.scriptName} - ''; - - passthru.scriptName = "reload.lua"; - })) - (pkgs.stdenv.mkDerivation (sources.mpv-createchapter // rec { - installPhase = '' - install -d $out/share/mpv/scripts - install -m 0644 createchapter.lua $out/share/mpv/scripts/${passthru.scriptName} - ''; - - passthru.scriptName = "createchapter.lua"; - })) - (pkgs.stdenv.mkDerivation (sources.mpv-autosave // rec { - installPhase = '' - install -d $out/share/mpv/scripts - install -m 0644 autosave.lua $out/share/mpv/scripts/${passthru.scriptName} - ''; - - passthru.scriptName = "autosave.lua"; - })) - (pkgs.stdenv.mkDerivation (sources.mpv-mpris // rec { - installPhase = '' - install -d $out/share/mpv/scripts - install -m 0644 mpris.so $out/share/mpv/scripts/${passthru.scriptName} - ''; - - nativeBuildInputs = with pkgs; [ pkg-config glib mpv ffmpeg.dev ]; - - passthru.scriptName = "mpris.so"; - })) - (pkgs.stdenv.mkDerivation (sources.mpv-chapterskip // rec { - installPhase = '' - install -d $out/share/mpv/scripts - install -m 0644 chapterskip.lua $out/share/mpv/scripts/${passthru.scriptName} - ''; - - passthru.scriptName = "chapterskip.lua"; - })) - (pkgs.stdenv.mkDerivation (sources.mpv-subselect // rec { - installPhase = '' - install -d $out/share/mpv/scripts - install -m 0644 sub-select.lua $out/share/mpv/scripts/${passthru.scriptName} - ''; - - passthru.scriptName = "sub-select.lua"; - })) - (pkgs.stdenv.mkDerivation (sources.mpv-youtube-quality // rec { - patches = [ - (pkgs.fetchpatch { url = "https://github.com/jgreco/mpv-youtube-quality/pull/31.patch"; hash = "sha256-2aTTkW48uRe8XC1ZQ8J5T9sUmZ5F3YAoYCMxqEs2AY8="; }) - (pkgs.fetchpatch { url = "https://github.com/jgreco/mpv-youtube-quality/pull/20.patch"; hash = "sha256-X5BwDsxziYbeiQvrBt8+IS+6oH1i0LvaaYtugL790gg="; }) - ]; - - installPhase = '' - install -d $out/share/mpv/scripts - install -m 0644 youtube-quality.lua $out/share/mpv/scripts/${passthru.scriptName} - ''; - - passthru.scriptName = "youtube-quality.lua"; - })) - ]; }; xdg.configFile."mpv/youtube-dl".source = "${pkgs.yt-dlp}/bin/yt-dlp"; -- cgit v1.2.3