├── rules ├── eslint │ ├── .gitignore │ ├── eslint.config.js │ ├── index.js │ ├── plugins │ │ ├── markdown.js │ │ ├── javascript.js │ │ ├── typescript.js │ │ ├── react.js │ │ ├── yaml.js │ │ ├── toml.js │ │ └── json.js │ └── package.json ├── stylua.toml ├── .prettierrc.json ├── .luacheckrc ├── stylelint │ ├── package.json │ └── stylelint.config.js ├── rustfmt.toml └── revive.toml ├── yazi ├── .gitignore ├── cspell.json ├── theme.toml ├── plugins │ └── folder-rules.yazi │ │ └── main.lua ├── init.lua ├── yazi.toml ├── package.toml └── keymap.toml ├── kitty ├── kitty.app.icns ├── keymap.py ├── themes │ ├── dracula.conf │ └── catppuccin │ │ ├── latte.conf │ │ ├── mocha.conf │ │ ├── frappe.conf │ │ └── macchiato.conf ├── testing.py ├── window.py └── kitty.conf ├── nix ├── nix.conf ├── flake.nix ├── users │ └── ika.nix └── darwin │ ├── software.nix │ └── default.nix ├── zsh ├── cspell.json ├── tabtab │ └── pnpm.zsh ├── .zshenv ├── .zshrc ├── function.zsh └── keymap.zsh ├── nvim ├── cspell.json ├── .luacheckrc ├── lua │ ├── plugins │ │ ├── debugging.lua │ │ ├── theme.lua │ │ └── parser.lua │ ├── utils.lua │ ├── editconfig.lua │ ├── terminal.lua │ ├── core.lua │ ├── keymap.lua │ └── window.lua ├── init.lua └── lazy-lock.json ├── mpv ├── fonts │ └── Material-Design-Iconic-Font.ttf ├── script-opts │ ├── thumbfast.conf │ ├── osc.conf │ └── playlistmanager.conf ├── scripts │ ├── reveal-file.lua │ ├── copy-subtitle.lua │ ├── ontop-playback.lua │ └── seek-to.lua ├── README.md ├── mpv.conf ├── shaders │ ├── Anime4K_AutoDownscalePre_x2.glsl │ ├── Anime4K_AutoDownscalePre_x4.glsl │ ├── Anime4K_Denoise_Bilateral_Mean.glsl │ ├── Anime4K_Clamp_Highlights.glsl │ ├── Anime4K_Denoise_Bilateral_Mode.glsl │ ├── Anime4K_Upscale_DoG_x2.glsl │ ├── Anime4K_Denoise_Bilateral_Median.glsl │ ├── Anime4K_Deblur_DoG.glsl │ ├── Anime4K_Upscale_Deblur_DoG_x2.glsl │ ├── Anime4K_Darken_HQ.glsl │ ├── Anime4K_Thin_HQ.glsl │ ├── Anime4K_Thin_Fast.glsl │ ├── Anime4K_Darken_Fast.glsl │ ├── Anime4K_Darken_VeryFast.glsl │ ├── Anime4K_Thin_VeryFast.glsl │ └── Anime4K_Upscale_Original_x2.glsl └── input.conf ├── .gitmodules ├── README.md ├── .gitignore ├── less └── .lesskey ├── os └── darwin │ └── power.sh ├── lazygit └── config.yml └── tmux └── tmux.conf /rules/eslint/.gitignore: -------------------------------------------------------------------------------- 1 | eslint.config.cjs 2 | -------------------------------------------------------------------------------- /yazi/.gitignore: -------------------------------------------------------------------------------- 1 | flavors/* 2 | plugins/* 3 | 4 | !plugins/folder-rules.yazi 5 | -------------------------------------------------------------------------------- /kitty/kitty.app.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sxyazi/dotfiles/HEAD/kitty/kitty.app.icns -------------------------------------------------------------------------------- /nix/nix.conf: -------------------------------------------------------------------------------- 1 | auto-optimise-store = true 2 | experimental-features = nix-command flakes 3 | -------------------------------------------------------------------------------- /zsh/cspell.json: -------------------------------------------------------------------------------- 1 | {"flagWords":[],"language":"en","version":"0.2","words":["yazi","mktemp"]} 2 | -------------------------------------------------------------------------------- /nvim/cspell.json: -------------------------------------------------------------------------------- 1 | {"flagWords":[],"words":["rustfmt","autocmd","augroup","yazi"],"version":"0.2","language":"en"} -------------------------------------------------------------------------------- /mpv/fonts/Material-Design-Iconic-Font.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sxyazi/dotfiles/HEAD/mpv/fonts/Material-Design-Iconic-Font.ttf -------------------------------------------------------------------------------- /mpv/script-opts/thumbfast.conf: -------------------------------------------------------------------------------- 1 | spawn_first=yes 2 | 3 | max_height=100 4 | max_width=100 5 | 6 | hwdec=yes 7 | network=yes 8 | 9 | -------------------------------------------------------------------------------- /yazi/cspell.json: -------------------------------------------------------------------------------- 1 | {"version":"0.2","words":["nvim","iina","mediainfo","keymap","zoxide","linemode"],"language":"en","flagWords":[]} -------------------------------------------------------------------------------- /mpv/script-opts/osc.conf: -------------------------------------------------------------------------------- 1 | hidetimeout=500 2 | fadeduration=400 3 | 4 | showtitle=no 5 | showonpause=no 6 | 7 | greenandgrumpy=yes 8 | -------------------------------------------------------------------------------- /yazi/theme.toml: -------------------------------------------------------------------------------- 1 | "$schema" = "https://yazi-rs.github.io/schemas/theme.json" 2 | 3 | [flavor] 4 | dark = "catppuccin-macchiato" 5 | light = "catppuccin-latte" 6 | -------------------------------------------------------------------------------- /rules/stylua.toml: -------------------------------------------------------------------------------- 1 | indent_width = 2 2 | call_parentheses = "NoSingleTable" 3 | collapse_simple_statement = "FunctionOnly" 4 | 5 | [sort_requires] 6 | enabled = true 7 | -------------------------------------------------------------------------------- /rules/.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "printWidth" : 120, 3 | "useTabs" : true, 4 | "semi" : false, 5 | "quoteProps" : "consistent", 6 | "arrowParens": "avoid" 7 | } 8 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "ranger/plugins/ranger_devicons"] 2 | path = ranger/plugins/ranger_devicons 3 | url = https://github.com/alexanderjeurissen/ranger_devicons.git 4 | [submodule "ranger/plugins/zoxide"] 5 | path = ranger/plugins/zoxide 6 | url = https://github.com/jchook/ranger-zoxide.git 7 | -------------------------------------------------------------------------------- /rules/eslint/eslint.config.js: -------------------------------------------------------------------------------- 1 | import { extended, formatting, javascript, json, markdown, toml, typescript, yaml } from "./index.js" 2 | 3 | /** @type { import('eslint').Linter.FlatConfig[] } */ 4 | export default [...javascript, ...typescript, ...json, ...markdown, ...toml, ...yaml, ...extended, ...formatting] 5 | -------------------------------------------------------------------------------- /rules/.luacheckrc: -------------------------------------------------------------------------------- 1 | -- Rerun tests only if their modification time changed. 2 | cache = true 3 | 4 | ignore = { 5 | "631", -- max_line_length 6 | "212/_.*", -- unused argument, for vars with "_" prefix 7 | "214", -- used variable with unused hint ("_" prefix) 8 | "121", -- setting read-only global variable 'vim' 9 | "122", -- setting read-only field of global variable 'vim' 10 | } 11 | -------------------------------------------------------------------------------- /rules/eslint/index.js: -------------------------------------------------------------------------------- 1 | export * from "./plugins/extended.js" 2 | export * from "./plugins/formatting.js" 3 | export * from "./plugins/json.js" 4 | export * from "./plugins/javascript.js" 5 | export * from "./plugins/markdown.js" 6 | export * from "./plugins/react.js" 7 | export * from "./plugins/toml.js" 8 | export * from "./plugins/typescript.js" 9 | export * from "./plugins/yaml.js" 10 | 11 | -------------------------------------------------------------------------------- /rules/stylelint/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@sxyazi/stylelint-config", 3 | "version": "1.0.0", 4 | "scripts": {}, 5 | "main": "index.js", 6 | "author": "sxyazi ", 7 | "license": "MIT", 8 | "description": "", 9 | "keywords": [], 10 | "dependencies": { 11 | "stylelint-config-standard": "^33.0.0" 12 | }, 13 | "devDependencies": { 14 | "stylelint": "^15.6.1" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /yazi/plugins/folder-rules.yazi/main.lua: -------------------------------------------------------------------------------- 1 | local function setup() 2 | ps.sub("cd", function() 3 | local cwd = cx.active.current.cwd 4 | if cwd:ends_with("Downloads") then 5 | ya.mgr_emit("sort", { "mtime", reverse = true, dir_first = false }) 6 | else 7 | ya.mgr_emit("sort", { "natural", reverse = false, dir_first = true }) 8 | end 9 | end) 10 | end 11 | 12 | return { setup = setup } 13 | -------------------------------------------------------------------------------- /mpv/scripts/reveal-file.lua: -------------------------------------------------------------------------------- 1 | local msg = require('mp.msg') 2 | 3 | function reveal_file() 4 | local path = mp.get_property("path") 5 | if not path then 6 | return msg.debug("no media has been loaded.") 7 | end 8 | 9 | if path:sub(1, 4) == "http" then 10 | mp.commandv("run", "open", path) 11 | else 12 | mp.commandv("run", "open", "-a", "Finder", "-R", path) 13 | end 14 | end 15 | 16 | mp.add_key_binding("o", "reveal-file", reveal_file) 17 | -------------------------------------------------------------------------------- /mpv/README.md: -------------------------------------------------------------------------------- 1 | ```bash 2 | curl -L https://github.com/cyl0/ModernX/raw/main/modernx.lua > scripts/modernx.lua 3 | curl -L https://github.com/po5/thumbfast/raw/master/thumbfast.lua > scripts/thumbfast.lua 4 | curl -L https://github.com/jonniek/mpv-playlistmanager/raw/master/playlistmanager.lua > scripts/playlistmanager.lua 5 | curl -L https://github.com/mpv-player/mpv/raw/master/TOOLS/lua/ontop-playback.lua > scripts/ontop-playback.lua 6 | curl -L https://github.com/occivink/mpv-scripts/raw/master/scripts/seek-to.lua > scripts/seek-to.lua 7 | ``` 8 | -------------------------------------------------------------------------------- /zsh/tabtab/pnpm.zsh: -------------------------------------------------------------------------------- 1 | ###-begin-pnpm-completion-### 2 | if type compdef &>/dev/null; then 3 | _pnpm_completion () { 4 | local reply 5 | local si=$IFS 6 | 7 | IFS=$'\n' reply=($(COMP_CWORD="$((CURRENT-1))" COMP_LINE="$BUFFER" COMP_POINT="$CURSOR" pnpm completion -- "${words[@]}")) 8 | IFS=$si 9 | 10 | if [ "$reply" = "__tabtab_complete_files__" ]; then 11 | _files 12 | else 13 | _describe 'values' reply 14 | fi 15 | } 16 | compdef _pnpm_completion pnpm 17 | fi 18 | ###-end-pnpm-completion-### 19 | -------------------------------------------------------------------------------- /mpv/scripts/copy-subtitle.lua: -------------------------------------------------------------------------------- 1 | function copy_subtitle() 2 | local subtitle = mp.get_property("sub-text") 3 | if not subtitle then 4 | return 5 | end 6 | 7 | local last = "" 8 | for w in string.gmatch(subtitle .. "\n", "(.-)[\r\n]+") do 9 | if w:find("%S") then 10 | last = w:gsub("^%s+", ""):gsub("%s+$", "") 11 | end 12 | end 13 | 14 | mp.commandv("run", "sh", "-c", 'printf "%s" "$1" | LANG=en_US.UTF-8 pbcopy', "", last) 15 | mp.osd_message("Subtitle line copied!") 16 | end 17 | 18 | mp.add_key_binding("Meta+c", "copy-subtitle", copy_subtitle) 19 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # README 2 | 3 | Initialize for Darwin system: 4 | 5 | ```bash 6 | /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" 7 | 8 | sh <(curl -L https://nixos.org/nix/install) 9 | 10 | git clone https://github.com/sxyazi/dotfiles.git ~/.config 11 | ln -s ~/.config/zsh/.zshenv ~/.zshenv 12 | 13 | cd ~/.config/nix 14 | nix build .#darwinConfigurations.ikas-Virtual-Machine.system 15 | ./result/sw/bin/darwin-rebuild switch --flake . 16 | ``` 17 | 18 | gc 19 | 20 | ``` 21 | sudo nix-collect-garbage -d 22 | nix-store --gc 23 | ``` 24 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !README.md 3 | 4 | !os/ 5 | !os/** 6 | 7 | !nix/ 8 | !nix/** 9 | nix/result 10 | 11 | !kitty/ 12 | !kitty/** 13 | 14 | !zsh/ 15 | !zsh/** 16 | zsh/.zsh_history 17 | zsh/.zsh_sessions 18 | zsh/.zcompdump 19 | zsh/.zcompcache 20 | 21 | !less/ 22 | !less/** 23 | less/.lesshst 24 | 25 | !yazi 26 | !yazi/** 27 | 28 | !nvim/ 29 | !nvim/** 30 | 31 | !mpv 32 | !mpv/** 33 | mpv/watch_later 34 | 35 | !lazygit 36 | !lazygit/** 37 | 38 | !bat/ 39 | !bat/** 40 | 41 | !tmux/ 42 | !tmux/** 43 | tmux/plugins/ 44 | 45 | !rules/ 46 | !rules/** 47 | rules/**/node_modules 48 | 49 | -------------------------------------------------------------------------------- /yazi/init.lua: -------------------------------------------------------------------------------- 1 | require("git"):setup { order = 0 } 2 | 3 | require("full-border"):setup() 4 | 5 | require("starship"):setup() 6 | 7 | require("session"):setup { 8 | sync_yanked = true, 9 | } 10 | 11 | require("folder-rules"):setup() 12 | 13 | require("mactag"):setup { 14 | keys = { 15 | r = "Red", 16 | o = "Orange", 17 | y = "Yellow", 18 | g = "Green", 19 | b = "Blue", 20 | p = "Purple", 21 | }, 22 | colors = { 23 | Red = "#ee7b70", 24 | Orange = "#f5bd5c", 25 | Yellow = "#fbe764", 26 | Green = "#91fc87", 27 | Blue = "#5fa3f8", 28 | Purple = "#cb88f8", 29 | }, 30 | } 31 | -------------------------------------------------------------------------------- /nvim/.luacheckrc: -------------------------------------------------------------------------------- 1 | -- Rerun tests only if their modification time changed. 2 | cache = true 3 | 4 | ignore = { 5 | "631", -- max_line_length 6 | "212/_.*", -- unused argument, for vars with "_" prefix 7 | "214", -- used variable with unused hint ("_" prefix) 8 | "121", -- setting read-only global variable 'vim' 9 | "122", -- setting read-only field of global variable 'vim' 10 | } 11 | 12 | -- Global objects defined by the C code 13 | read_globals = { 14 | "vim", 15 | } 16 | 17 | globals = { 18 | "vim.g", 19 | "vim.b", 20 | "vim.w", 21 | "vim.o", 22 | "vim.bo", 23 | "vim.wo", 24 | "vim.go", 25 | "vim.env", 26 | } 27 | -------------------------------------------------------------------------------- /mpv/scripts/ontop-playback.lua: -------------------------------------------------------------------------------- 1 | --makes mpv disable ontop when pausing and re-enable it again when resuming playback 2 | --please note that this won't do anything if ontop was not enabled before pausing 3 | 4 | local was_ontop = false 5 | 6 | mp.observe_property("pause", "bool", function(_, value) 7 | local ontop = mp.get_property_native("ontop") 8 | if value then 9 | if ontop then 10 | mp.set_property_native("ontop", false) 11 | was_ontop = true 12 | end 13 | else 14 | if was_ontop and not ontop then 15 | mp.set_property_native("ontop", true) 16 | end 17 | was_ontop = false 18 | end 19 | end) 20 | -------------------------------------------------------------------------------- /nvim/lua/plugins/debugging.lua: -------------------------------------------------------------------------------- 1 | return { 2 | -- An extensible framework for interacting with tests within NeoVim 3 | { 4 | "nvim-neotest/neotest", 5 | dependencies = { 6 | "nvim-neotest/nvim-nio", 7 | "nvim-lua/plenary.nvim", 8 | "antoinemadec/FixCursorHold.nvim", 9 | "nvim-treesitter/nvim-treesitter", 10 | "nvim-neotest/neotest-plenary", 11 | "rouge8/neotest-rust", 12 | }, 13 | keys = { 14 | { "s", function() require("neotest").run.run() end }, 15 | { "S", function() require("neotest").output.open { enter = true } end }, 16 | }, 17 | config = function() 18 | require("neotest").setup { 19 | adapters = { 20 | require("neotest-plenary"), 21 | require("neotest-rust") { 22 | args = { "--no-capture" }, 23 | }, 24 | }, 25 | } 26 | end, 27 | }, 28 | } 29 | -------------------------------------------------------------------------------- /rules/eslint/plugins/markdown.js: -------------------------------------------------------------------------------- 1 | import tsPlugin from "@typescript-eslint/eslint-plugin" 2 | import mdPlugin from "eslint-plugin-markdown" 3 | 4 | /** @type { import('eslint').Linter.FlatConfig[] } */ 5 | export const markdown = [ 6 | { 7 | files : ["**/*.md"], 8 | processor : "markdown/markdown", 9 | linterOptions: { 10 | reportUnusedDisableDirectives: true, 11 | }, 12 | plugins: { 13 | markdown: mdPlugin, 14 | }, 15 | rules: { 16 | ...mdPlugin.configs.recommended.overrides[1].rules, 17 | }, 18 | }, 19 | { 20 | files : ["**/*.md/*.{js,jsx}"], 21 | languageOptions: { 22 | parserOptions: { 23 | ecmaFeatures: { impliedStrict: true }, 24 | }, 25 | }, 26 | }, 27 | { 28 | files : ["**/*.md/*.{ts,tsx}"], 29 | plugins: { 30 | "@typescript-eslint": tsPlugin, 31 | }, 32 | }, 33 | ] 34 | 35 | -------------------------------------------------------------------------------- /less/.lesskey: -------------------------------------------------------------------------------- 1 | #command 2 | \r forw-line 3 | \n forw-line 4 | 5 | e forw-line 6 | E forw-scroll 7 | u back-line 8 | U back-scroll 9 | 10 | n left-scroll 11 | i right-scroll 12 | 13 | g goto-line 14 | G goto-end 15 | 16 | / forw-search 17 | ? back-search 18 | - repeat-search 19 | = reverse-search 20 | f filter 21 | 22 | o examine 23 | [ prev-file 24 | ] next-file 25 | x remove-file 26 | 27 | p status 28 | r repaint-flush 29 | F forw-forever 30 | v visual 31 | ; shell 32 | q quit 33 | 34 | 0 digit 35 | 1 digit 36 | 2 digit 37 | 3 digit 38 | 4 digit 39 | 5 digit 40 | 6 digit 41 | 7 digit 42 | 8 digit 43 | 9 digit 44 | #stop 45 | 46 | #line-edit 47 | \ku up 48 | \kd down 49 | ^N left 50 | ^I right 51 | 52 | ^B word-left 53 | ^H word-right 54 | ^W word-backspace 55 | 56 | \e0 home 57 | \e$ end 58 | #stop 59 | 60 | #env 61 | LESS = -i 62 | LESSCHARSET = utf-8 63 | -------------------------------------------------------------------------------- /mpv/mpv.conf: -------------------------------------------------------------------------------- 1 | osc=no 2 | # border=no 3 | 4 | input-builtin-bindings=no 5 | 6 | save-position-on-quit=yes 7 | watch-later-options=start,speed,volume,audio-delay,sub-delay,sub-speed,sub-pos,sub-visibility,sub-scale 8 | 9 | user-agent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36" 10 | 11 | 12 | # Display 13 | target-prim=apple 14 | icc-profile-auto=yes 15 | 16 | # Video 17 | geometry=50%:50% 18 | autofit-larger=85%x85% 19 | 20 | vo=gpu-next 21 | hwdec=auto 22 | macos-force-dedicated-gpu=yes 23 | 24 | # Audio 25 | alang=chs,sc,zh,chi,zho,en 26 | audio-file-auto=fuzzy 27 | 28 | # Subtitle 29 | slang=chs,sc,zh,chi,zho,en 30 | sub-auto=fuzzy 31 | 32 | # Cache 33 | cache=yes 34 | cache-pause=no 35 | 36 | demuxer-max-bytes=500M 37 | demuxer-max-back-bytes=100M 38 | 39 | # IPC 40 | input-ipc-server=/tmp/mpv.sock 41 | -------------------------------------------------------------------------------- /rules/eslint/plugins/javascript.js: -------------------------------------------------------------------------------- 1 | import eslint from "@eslint/js" 2 | import globals from "globals" 3 | 4 | export const jsRules = { 5 | "no-case-declarations": "off", 6 | } 7 | 8 | /** @type { import('eslint').Linter.FlatConfig[] } */ 9 | export const javascript = [ 10 | { 11 | files : ["**/*.{js,jsx,cjs,mjs}"], 12 | languageOptions: { 13 | globals: { 14 | ...globals.browser, 15 | ...globals.es2021, 16 | ...globals.node, 17 | }, 18 | }, 19 | linterOptions: { 20 | reportUnusedDisableDirectives: true, 21 | }, 22 | rules: { 23 | ...eslint.configs.recommended.rules, 24 | ...jsRules, 25 | }, 26 | }, 27 | { 28 | files : ["**/*.jsx"], 29 | languageOptions: { 30 | globals: { 31 | ...globals.browser, 32 | ...globals.es2021, 33 | }, 34 | parserOptions: { 35 | ecmaFeatures: { jsx: true }, 36 | }, 37 | }, 38 | }, 39 | ] 40 | 41 | -------------------------------------------------------------------------------- /rules/eslint/plugins/typescript.js: -------------------------------------------------------------------------------- 1 | import eslint from "@eslint/js" 2 | import tsPlugin from "@typescript-eslint/eslint-plugin" 3 | import tsParser from "@typescript-eslint/parser" 4 | 5 | import { jsRules } from "./javascript.js" 6 | 7 | /** @type { import('eslint').Linter.FlatConfig[] } */ 8 | export const typescript = [ 9 | { 10 | files : ["**/*.{ts,tsx,cts,mts}"], 11 | languageOptions: { 12 | parser : tsParser, 13 | parserOptions: { project: true }, 14 | }, 15 | linterOptions: { 16 | reportUnusedDisableDirectives: true, 17 | }, 18 | plugins: { 19 | "@typescript-eslint": tsPlugin, 20 | }, 21 | rules: { 22 | ...eslint.configs.recommended.rules, 23 | ...tsPlugin.configs["eslint-recommended"].overrides[0].rules, 24 | ...tsPlugin.configs.recommended.rules, 25 | ...tsPlugin.configs["recommended-requiring-type-checking"].rules, 26 | 27 | ...jsRules, 28 | "@typescript-eslint/ban-ts-comment" : "off", 29 | "@typescript-eslint/no-non-null-assertion": "off", 30 | }, 31 | }, 32 | ] 33 | 34 | -------------------------------------------------------------------------------- /mpv/script-opts/playlistmanager.conf: -------------------------------------------------------------------------------- 1 | # navigation keys 2 | key_moveup=u 3 | key_movedown=e 4 | key_movepageup=n 5 | key_movepagedown=i 6 | key_movebegin=U 7 | key_moveend=E 8 | key_selectfile=TAB 9 | key_playfile=ENTER 10 | key_removefile=BS 11 | key_closeplaylist=ESC SHIFT+ENTER 12 | 13 | # extra functionality keys 14 | key_shuffleplaylist=Ctrl+s 15 | key_loadfiles=Ctrl-r 16 | 17 | # files 18 | loadfiles_on_start=yes 19 | loadfiles_on_idle_start=yes 20 | sortplaylist_on_file_add=yes 21 | 22 | loadfiles_filetypes=["mp3","wav","ogm","flac","m4a","wma","ogg","opus","mkv","avi","mp4","ogv","webm","rmvb","flv","wmv","mpeg","mpg","m4v","3gp"] 23 | filename_replace=[{"ext":{"all":true},"rules":[{"_":" "}]},{"ext":{"mp4":true,"mkv":true},"rules":[{"^(.+)%..+$":"%1"},{"%s*[%[%(].-[%]%)]%s*":""},{"(%w)%.(%w)":"%1 %2"}]},{"protocol":{"http":true,"https":true},"rules":[{"^%a+://w*%.?":""}]}] 24 | 25 | # visual 26 | showamount=10 27 | 28 | playlist_header=[ %cursor / %plen ]%N 29 | style_ass_tags={\fnSF Mono\fs8\b0\bord1} 30 | 31 | resolve_url_titles=yes 32 | youtube_dl_executable=yt-dlp 33 | 34 | -------------------------------------------------------------------------------- /nvim/lua/utils.lua: -------------------------------------------------------------------------------- 1 | local M = {} 2 | 3 | function M.search(forward) 4 | vim.cmd('noau normal! "vy"') 5 | local s = vim.fn.getreg("v") 6 | 7 | s = s:gsub("/", "\\/"):gsub([[\]], [[\\]]):gsub("\n", "\\n"):gsub("\r", "\\r") 8 | s = string.format("%s\\V%s\ngn", forward and "?" or "/", s) 9 | 10 | vim.api.nvim_feedkeys(s, "n", false) 11 | end 12 | 13 | function M.list_equal(a, b) 14 | if #a ~= #b then 15 | return false 16 | end 17 | for k, v in ipairs(a) do 18 | if v ~= b[k] then 19 | return false 20 | end 21 | end 22 | return true 23 | end 24 | 25 | function M.line_ending(bufnr) 26 | local format = vim.api.nvim_get_option_value("fileformat", { buf = bufnr }) 27 | if format == "dos" then 28 | return "\r\n" 29 | elseif format == "mac" then 30 | return "\r" 31 | else 32 | return "\n" 33 | end 34 | end 35 | 36 | function M.full_lines(bufnr) 37 | local lines = vim.api.nvim_buf_get_lines(bufnr, 0, -1, true) 38 | if vim.api.nvim_get_option_value("eol", { buf = bufnr }) then 39 | lines[#lines + 1] = "" 40 | end 41 | return lines 42 | end 43 | 44 | return M 45 | -------------------------------------------------------------------------------- /rules/eslint/plugins/react.js: -------------------------------------------------------------------------------- 1 | import reactPlugin from "eslint-plugin-react" 2 | import reactHooksPlugin from "eslint-plugin-react-hooks" 3 | 4 | /** @type { import('eslint').Linter.FlatConfig[] } */ 5 | export const react = [ 6 | { 7 | files : ["**/*.{ts,tsx,js,jsx,cjs,mjs,cts,mts}"], 8 | plugins: { 9 | "react" : reactPlugin, 10 | "react-hooks": reactHooksPlugin, 11 | }, 12 | settings: { 13 | react: { 14 | version: "detect", 15 | }, 16 | }, 17 | rules: { 18 | ...reactPlugin.configs.recommended.rules, 19 | ...reactHooksPlugin.configs.recommended.rules, 20 | }, 21 | }, 22 | ] 23 | 24 | /** @type { import('eslint').Linter.FlatConfig[] } */ 25 | export const preact = [ 26 | { 27 | files : ["**/*.{ts,tsx,js,jsx,cjs,mjs,cts,mts}"], 28 | plugins: { 29 | "react" : reactPlugin, 30 | "react-hooks": reactHooksPlugin, 31 | }, 32 | settings: { 33 | react: { 34 | version: "16.0", 35 | }, 36 | }, 37 | rules: { 38 | ...reactPlugin.configs.recommended.rules, 39 | ...reactHooksPlugin.configs.recommended.rules, 40 | 41 | "react/react-in-jsx-scope": "off", 42 | }, 43 | }, 44 | ] 45 | 46 | -------------------------------------------------------------------------------- /kitty/keymap.py: -------------------------------------------------------------------------------- 1 | from kittens.tui.handler import result_handler 2 | from kitty.keys import keyboard_mode_name 3 | 4 | 5 | def main(args): 6 | pass 7 | 8 | 9 | @result_handler(no_ui=True) 10 | def handle_result(args, answer, target_window_id, boss): 11 | window = boss.active_window 12 | if window is None: 13 | return 14 | 15 | cmd = window.child.foreground_cmdline[0] 16 | if args[1] == "C-i": 17 | # Move cursor to the end of line, specific to zsh 18 | if cmd[-3:] == "zsh": 19 | window.write_to_child("\x1b[105;5u") 20 | 21 | # A workaround for tmux to fix its bug of Ctrl+i recognition, sending a Ctrl-; instead 22 | elif cmd[-4:] == "tmux": 23 | window.write_to_child("\x1b[59;5u") 24 | return 25 | 26 | # Other programs that support CSI u 27 | elif keyboard_mode_name(window.screen) == "kitty": 28 | window.write_to_child("\x1b[105;5u") 29 | 30 | # Otherwise send a ^I 31 | else: 32 | window.write_to_child("\x09") 33 | 34 | elif args[1] == "S-s": 35 | if cmd[-4:] == "nvim": 36 | window.write_to_child("\x1b[115;8u") 37 | -------------------------------------------------------------------------------- /nvim/init.lua: -------------------------------------------------------------------------------- 1 | require("core") 2 | require("keymap") 3 | require("window") 4 | require("terminal") 5 | 6 | local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" 7 | if not vim.loop.fs_stat(lazypath) then 8 | vim.fn.system { 9 | "git", 10 | "clone", 11 | "--filter=blob:none", 12 | "https://github.com/folke/lazy.nvim.git", 13 | "--branch=stable", -- latest stable release 14 | lazypath, 15 | } 16 | end 17 | vim.opt.rtp:prepend(lazypath) 18 | 19 | require("lazy").setup("plugins", { 20 | change_detection = { 21 | notify = false, 22 | }, 23 | performance = { 24 | rtp = { 25 | disabled_plugins = { 26 | "gzip", 27 | "health", 28 | "man", 29 | "matchit", 30 | "matchparen", 31 | "netrwPlugin", 32 | "nvim", 33 | "rplugin", 34 | "shada", 35 | "spellfile", 36 | "tarPlugin", 37 | "tohtml", 38 | "tutor", 39 | "zipPlugin", 40 | }, 41 | }, 42 | }, 43 | }) 44 | 45 | local commands = require("lazy.view.config").commands 46 | commands.install = nil 47 | commands.update = nil 48 | commands.clean = nil 49 | commands.check = nil 50 | commands.restore.button = false 51 | commands.help = nil 52 | 53 | require("editconfig") 54 | -------------------------------------------------------------------------------- /zsh/.zshenv: -------------------------------------------------------------------------------- 1 | # Zsh root 2 | ZDOTDIR=$HOME/.config/zsh 3 | ZSHAREDIR=$HOME/.local/share/zsh 4 | 5 | # Zsh related 6 | HISTFILE=$ZDOTDIR/.history 7 | HISTSIZE=10000 8 | SAVEHIST=10000 9 | KEYTIMEOUT=1 # makes the switch between modes quicker 10 | HISTORY_SUBSTRING_SEARCH_PREFIXED=1 # enables prefixed search for zsh-history-substring-search 11 | 12 | # Temporary variables 13 | __TREE_IGNORE="-I '.git' -I '*.py[co]' -I '__pycache__' $__TREE_IGNORE" 14 | __FD_COMMAND="-L -H --no-ignore-vcs ${__TREE_IGNORE//-I/-E} $__FD_COMMAND" 15 | 16 | # Software specific 17 | export EDITOR="nvim" 18 | export VISUAL="nvim" 19 | 20 | export BAT_THEME="Catppuccin Mocha" 21 | export HOMEBREW_NO_ANALYTICS=1 22 | export HOMEBREW_DOWNLOAD_CONCURRENCY=8 23 | export PNPM_HOME=$HOME/Library/pnpm 24 | 25 | export LESSKEYIN=$HOME/.config/less/.lesskey 26 | export LESSHISTFILE=$HOME/.config/less/.lesshst 27 | 28 | export FZF_DEFAULT_COMMAND="fd $__FD_COMMAND" 29 | export FZF_DEFAULT_OPTS=" 30 | --reverse --ansi 31 | --bind=ctrl-u:up,ctrl-e:down,ctrl-n:backward-char,ctrl-i:forward-char,ctrl-b:backward-word,ctrl-h:forward-word,tab:toggle+down,shift-tab:toggle+up,ctrl-a:select-all,ctrl-r:toggle-all 32 | --border --scrollbar=▌" 33 | 34 | # Clean up 35 | unset __TREE_IGNORE 36 | unset __FD_COMMAND 37 | -------------------------------------------------------------------------------- /os/darwin/power.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | sudo pmset -a displaysleep 15 4 | sudo pmset -a sleep 20 5 | sudo pmset -a disksleep 30 6 | 7 | # Disable wake by network 8 | sudo pmset -a womp 0 9 | # Disable wake when power source (AC/battery) change 10 | sudo pmset -a acwake 0 11 | # Disable wake by other devices using the same iCloud id 12 | sudo pmset -a proximitywake 0 13 | 14 | # Disable TCP keepalive on sleeping, this will cause "Find My Mac" to be unavailable 15 | sudo pmset -a tcpkeepalive 0 16 | # Disable auto update, auto backup when sleeping 17 | sudo pmset -a powernap 0 18 | 19 | # Enable "full light - half light - off" screen transition, when going to sleep 20 | sudo pmset -a halfdim 1 21 | # Auto switch GPU for apps on battery, use separate GPU on charger 22 | sudo pmset -b gpuswitch 2 23 | sudo pmset -c gpuswitch 1 24 | 25 | # Auto hibernate after a period of time of sleeping 26 | sudo pmset -a standby 1 27 | # High power (> `highstandbythreshold`), 2 hours hibernate 28 | sudo pmset -a standbydelayhigh 7200 29 | # Low power (< `highstandbythreshold`), 1 hour hibernate 30 | sudo pmset -a standbydelaylow 3600 31 | # Sync memory data to disk, and stop powering the memory when hibernating 32 | sudo pmset -a hibernatemode 3 33 | # `highstandbythreshold` defaults to 50% 34 | 35 | -------------------------------------------------------------------------------- /rules/rustfmt.toml: -------------------------------------------------------------------------------- 1 | color = "Never" 2 | condense_wildcard_suffixes = true 3 | edition = "2021" 4 | enum_discrim_align_threshold = 99 5 | fn_single_line = true 6 | format_code_in_doc_comments = false 7 | format_generated_files = false 8 | format_macro_matchers = true 9 | format_macro_bodies = true 10 | format_strings = false 11 | hard_tabs = true 12 | hex_literal_case = "Lower" 13 | hide_parse_errors = true 14 | imports_indent = "Visual" 15 | imports_layout = "Horizontal" 16 | imports_granularity = "Crate" 17 | newline_style = "Unix" 18 | normalize_comments = true 19 | normalize_doc_attributes = false 20 | overflow_delimited_expr = true 21 | reorder_impl_items = true 22 | group_imports = "StdExternalCrate" 23 | reorder_modules = true 24 | struct_field_align_threshold = 99 25 | tab_spaces = 2 26 | unstable_features = true 27 | use_field_init_shorthand = true 28 | use_small_heuristics = "Max" 29 | use_try_shorthand = true 30 | version = "Two" 31 | wrap_comments = true 32 | -------------------------------------------------------------------------------- /rules/eslint/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@sxyazi/eslint-config", 3 | "type": "module", 4 | "version": "1.0.6", 5 | "scripts": { 6 | "build": "esbuild eslint.config.js --bundle --minify --platform=node --packages=external --footer:js='module.exports=module.exports.default' --outfile=eslint.config.cjs", 7 | "release": "pnpm build && pnpm publish" 8 | }, 9 | "module": "index.js", 10 | "author": "sxyazi ", 11 | "license": "MIT", 12 | "description": "", 13 | "publishConfig": { 14 | "access": "public" 15 | }, 16 | "dependencies": { 17 | "@eslint/js": "^8.57.1", 18 | "@typescript-eslint/eslint-plugin": "^5.62.0", 19 | "@typescript-eslint/parser": "^5.62.0", 20 | "eslint-plugin-import": "^2.31.0", 21 | "eslint-plugin-json-schema-validator": "^4.9.0", 22 | "eslint-plugin-jsonc": "^2.18.2", 23 | "eslint-plugin-markdown": "^3.0.1", 24 | "eslint-plugin-react": "^7.37.2", 25 | "eslint-plugin-react-hooks": "^4.6.2", 26 | "eslint-plugin-toml": "^0.5.0", 27 | "eslint-plugin-unicorn": "^47.0.0", 28 | "eslint-plugin-yml": "^1.16.0", 29 | "espree": "^9.6.1", 30 | "globals": "^13.24.0", 31 | "jsonc-eslint-parser": "^2.4.0", 32 | "toml-eslint-parser": "^0.6.1", 33 | "yaml-eslint-parser": "^1.2.3" 34 | }, 35 | "devDependencies": { 36 | "esbuild": "^0.17.19", 37 | "eslint": "^8.57.1" 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /nvim/lua/editconfig.lua: -------------------------------------------------------------------------------- 1 | local function apply(bufnr, config) 2 | local path = vim.fs.normalize(vim.api.nvim_buf_get_name(bufnr)) 3 | if vim.bo[bufnr].buftype ~= "" or not vim.bo[bufnr].modifiable or path == "" then 4 | return 5 | end 6 | 7 | local default = { 8 | charset = "utf-8", 9 | end_of_line = "lf", 10 | indent_style = "tab", 11 | indent_size = 2, 12 | insert_final_newline = "true", 13 | max_line_length = 120, 14 | tab_width = 2, 15 | trim_trailing_whitespace = "true", 16 | } 17 | 18 | -- YAML 19 | if path:find("%.ya?ml$") then 20 | default.indent_style = "space" 21 | end 22 | 23 | local override = {} 24 | for k, v in pairs(default) do 25 | if not config[k] then 26 | config[k] = v 27 | override[#override + 1] = k 28 | end 29 | end 30 | 31 | local editorconfig = require("editorconfig") 32 | for _, k in ipairs(override) do 33 | editorconfig.properties[k](bufnr, config[k], override) 34 | end 35 | 36 | config.root = "true" 37 | end 38 | 39 | local group = vim.api.nvim_create_augroup("AutoEditorConfig", { clear = true }) 40 | vim.api.nvim_create_autocmd({ "BufNewFile", "BufReadPost", "BufFilePost", "FileChangedShellPost" }, { 41 | group = group, 42 | callback = function(args) 43 | local opts = vim.b[args.buf] 44 | opts.editorconfig = opts.editorconfig or {} 45 | 46 | apply(args.buf, opts.editorconfig) 47 | end, 48 | }) 49 | -------------------------------------------------------------------------------- /kitty/themes/dracula.conf: -------------------------------------------------------------------------------- 1 | # https://draculatheme.com/kitty 2 | # 3 | # Installation instructions: 4 | # 5 | # cp dracula.conf ~/.config/kitty/ 6 | # echo "include dracula.conf" >> ~/.config/kitty/kitty.conf 7 | # 8 | # Then reload kitty for the config to take affect. 9 | # Alternatively copy paste below directly into kitty.conf 10 | 11 | foreground #f8f8f2 12 | background #282a36 13 | selection_foreground #ffffff 14 | selection_background #44475a 15 | 16 | url_color #8be9fd 17 | 18 | # black 19 | color0 #21222c 20 | color8 #6272a4 21 | 22 | # red 23 | color1 #ff5555 24 | color9 #ff6e6e 25 | 26 | # green 27 | color2 #50fa7b 28 | color10 #69ff94 29 | 30 | # yellow 31 | color3 #f1fa8c 32 | color11 #ffffa5 33 | 34 | # blue 35 | color4 #bd93f9 36 | color12 #d6acff 37 | 38 | # magenta 39 | color5 #ff79c6 40 | color13 #ff92df 41 | 42 | # cyan 43 | color6 #8be9fd 44 | color14 #a4ffff 45 | 46 | # white 47 | color7 #f8f8f2 48 | color15 #ffffff 49 | 50 | # Cursor colors 51 | cursor #f8f8f2 52 | cursor_text_color background 53 | 54 | # Tab bar colors 55 | active_tab_foreground #282a36 56 | active_tab_background #f8f8f2 57 | inactive_tab_foreground #282a36 58 | inactive_tab_background #6272a4 59 | 60 | # Marks 61 | mark1_foreground #282a36 62 | mark1_background #ff5555 63 | 64 | # Splits/Windows 65 | active_border_color #f8f8f2 66 | inactive_border_color #6272a4 67 | -------------------------------------------------------------------------------- /yazi/yazi.toml: -------------------------------------------------------------------------------- 1 | "$schema" = "https://yazi-rs.github.io/schemas/yazi.json" 2 | 3 | [mgr] 4 | linemode = "size" 5 | show_hidden = true 6 | sort_by = "natural" 7 | # mouse_events = [] 8 | 9 | [preview] 10 | wrap = "yes" 11 | max_width = 1500 12 | max_height = 1500 13 | 14 | [opener] 15 | edit = [ 16 | { run = '${EDITOR:=vi} "$@"', desc = "$EDITOR", block = true }, 17 | { run = 'code "$@"', orphan = true }, 18 | ] 19 | play = [ 20 | { run = 'mpv --force-window "$@"' }, 21 | { run = 'iina --no-stdin "$@"' }, 22 | { run = '''mediainfo "$1"; echo "Press enter to exit"; read''', block = true, desc = "Show media info" } 23 | ] 24 | extract = [ 25 | { run = 'ya pub extract --list "$@"', desc = "Extract here" }, 26 | { run = 'open -a MacZip "$1"', orphan = true, desc = "MacZip" } 27 | ] 28 | subtitle = [ 29 | { run = ''' echo sub-add "'$0'" | socat - /tmp/mpv.sock ''', desc = "Add sub to MPV" }, 30 | { run = ''' opencc -c tw2sp -i "$1" -o "$1" ''', desc = "TW to SC" }, 31 | ] 32 | 33 | [open] 34 | prepend_rules = [ 35 | { url = "*.{ass,srt,ssa,sty,sup,vtt}", use = [ "subtitle", "edit" ] }, 36 | ] 37 | 38 | [tasks] 39 | image_alloc = 0 40 | image_bound = [ 0, 0 ] 41 | 42 | [plugin] 43 | prepend_fetchers = [ 44 | { id = "git", url = "*", run = "git" }, 45 | { id = "git", url = "*/", run = "git" }, 46 | 47 | { id = "mactag", url = "*", run = "mactag" }, 48 | { id = "mactag", url = "*/", run = "mactag" }, 49 | ] 50 | -------------------------------------------------------------------------------- /nix/flake.nix: -------------------------------------------------------------------------------- 1 | { 2 | inputs = { 3 | nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; 4 | 5 | darwin.url = "github:LnL7/nix-darwin"; 6 | darwin.inputs.nixpkgs.follows = "nixpkgs"; 7 | 8 | home-manager.url = "github:nix-community/home-manager"; 9 | home-manager.inputs.nixpkgs.follows = "nixpkgs"; 10 | 11 | neovim-overlay.url = "github:nix-community/neovim-nightly-overlay"; 12 | rust-overlay.url = "github:oxalica/rust-overlay"; 13 | }; 14 | 15 | outputs = { self, darwin, home-manager, neovim-overlay, rust-overlay, ... }: { 16 | darwinConfigurations = { 17 | ikas-Virtual-Machine = darwin.lib.darwinSystem { 18 | system = "aarch64-darwin"; 19 | modules = [ 20 | ./darwin 21 | home-manager.darwinModules.home-manager 22 | ({ pkgs, ... } @ args: { 23 | home-manager.useGlobalPkgs = true; 24 | home-manager.useUserPackages = true; 25 | home-manager.users.ika = import ./users/ika.nix args; 26 | users.users.ika.home = /Users/ika; 27 | }) 28 | ({ pkgs, ... }: { 29 | nix.settings.trusted-users = [ "ika" ]; 30 | services.nix-daemon.enable = true; 31 | 32 | nixpkgs.config.allowUnfree = true; 33 | nixpkgs.overlays = [ 34 | # neovim-overlay.overlay 35 | rust-overlay.overlays.default 36 | ]; 37 | }) 38 | ]; 39 | }; 40 | }; 41 | }; 42 | } 43 | 44 | -------------------------------------------------------------------------------- /mpv/shaders/Anime4K_AutoDownscalePre_x2.glsl: -------------------------------------------------------------------------------- 1 | // This is free and unencumbered software released into the public domain. 2 | 3 | // Anyone is free to copy, modify, publish, use, compile, sell, or 4 | // distribute this software, either in source code form or as a compiled 5 | // binary, for any purpose, commercial or non-commercial, and by any 6 | // means. 7 | 8 | // In jurisdictions that recognize copyright laws, the author or authors 9 | // of this software dedicate any and all copyright interest in the 10 | // software to the public domain. We make this dedication for the benefit 11 | // of the public at large and to the detriment of our heirs and 12 | // successors. We intend this dedication to be an overt act of 13 | // relinquishment in perpetuity of all present and future rights to this 14 | // software under copyright law. 15 | 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | // IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | // OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | // OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | // For more information, please refer to 25 | 26 | //!DESC Anime4K-v4.0-AutoDownscalePre-x2 27 | //!HOOK MAIN 28 | //!BIND HOOKED 29 | //!BIND NATIVE 30 | //!WHEN OUTPUT.w NATIVE.w / 2.0 < OUTPUT.h NATIVE.h / 2.0 < * OUTPUT.w NATIVE.w / 1.2 > OUTPUT.h NATIVE.h / 1.2 > * * 31 | //!WIDTH OUTPUT.w 32 | //!HEIGHT OUTPUT.h 33 | 34 | vec4 hook() { 35 | return HOOKED_tex(HOOKED_pos); 36 | } 37 | -------------------------------------------------------------------------------- /mpv/shaders/Anime4K_AutoDownscalePre_x4.glsl: -------------------------------------------------------------------------------- 1 | // This is free and unencumbered software released into the public domain. 2 | 3 | // Anyone is free to copy, modify, publish, use, compile, sell, or 4 | // distribute this software, either in source code form or as a compiled 5 | // binary, for any purpose, commercial or non-commercial, and by any 6 | // means. 7 | 8 | // In jurisdictions that recognize copyright laws, the author or authors 9 | // of this software dedicate any and all copyright interest in the 10 | // software to the public domain. We make this dedication for the benefit 11 | // of the public at large and to the detriment of our heirs and 12 | // successors. We intend this dedication to be an overt act of 13 | // relinquishment in perpetuity of all present and future rights to this 14 | // software under copyright law. 15 | 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | // IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | // OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | // OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | // For more information, please refer to 25 | 26 | //!DESC Anime4K-v3.2-AutoDownscalePre-x4 27 | //!HOOK MAIN 28 | //!BIND HOOKED 29 | //!BIND NATIVE 30 | //!WHEN OUTPUT.w NATIVE.w / 4.0 < OUTPUT.h NATIVE.h / 4.0 < * OUTPUT.w NATIVE.w / 2.4 > OUTPUT.h NATIVE.h / 2.4 > * * 31 | //!WIDTH OUTPUT.w 2 / 32 | //!HEIGHT OUTPUT.h 2 / 33 | 34 | vec4 hook() { 35 | return HOOKED_tex(HOOKED_pos); 36 | } 37 | -------------------------------------------------------------------------------- /zsh/.zshrc: -------------------------------------------------------------------------------- 1 | setopt AUTO_CD 2 | setopt INTERACTIVE_COMMENTS 3 | setopt HIST_FCNTL_LOCK 4 | setopt HIST_IGNORE_ALL_DUPS 5 | setopt SHARE_HISTORY 6 | unsetopt AUTO_REMOVE_SLASH 7 | unsetopt HIST_EXPIRE_DUPS_FIRST 8 | unsetopt EXTENDED_HISTORY 9 | 10 | # PATH 11 | if [[ "$(uname -sm)" = "Darwin arm64" ]] then export PATH=/opt/homebrew/bin:$PATH; fi 12 | export PATH=$HOME/.local/bin:$PATH 13 | export PATH=$PNPM_HOME:$PATH 14 | export PATH=$HOME/go/bin:$PATH 15 | export PATH=$HOME/.cargo/bin:$PATH 16 | export PATH=$HOME/Documents/nvim/bin:$PATH 17 | export PATH=/opt/homebrew/opt/llvm/bin:$PATH 18 | export PATH=$HOME/Desktop/yazi/target/release:$PATH 19 | 20 | # Autoload 21 | autoload -U compinit; compinit 22 | zmodload zsh/complist 23 | autoload -Uz edit-command-line; zle -N edit-command-line 24 | 25 | # Plugins 26 | source $ZSHAREDIR/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh 27 | source $ZSHAREDIR/zsh-autosuggestions/zsh-autosuggestions.zsh 28 | source $ZSHAREDIR/zsh-history-substring-search/zsh-history-substring-search.zsh 29 | fpath=($ZSHAREDIR/zsh-completions/src $fpath) 30 | 31 | [[ $- == *i* ]] && source $ZSHAREDIR/fzf/completion.zsh 2> /dev/null 32 | source $ZSHAREDIR/fzf/key-bindings.zsh 33 | 34 | # Auto completion 35 | zstyle ":completion:*:*:*:*:*" menu select 36 | zstyle ":completion:*" use-cache yes 37 | zstyle ":completion:*" special-dirs true 38 | zstyle ":completion:*" squeeze-slashes true 39 | zstyle ":completion:*" file-sort change 40 | zstyle ":completion:*" matcher-list "m:{[:lower:][:upper:]}={[:upper:][:lower:]}" "r:|=*" "l:|=* r:|=*" 41 | source $ZDOTDIR/keymap.zsh 42 | 43 | # Tabtab for node cli programs, e.g. `pnpm` 44 | source $ZDOTDIR/tabtab/pnpm.zsh 45 | 46 | # Initialize tools 47 | source $ZDOTDIR/function.zsh 48 | eval "$(starship init zsh)" 49 | eval "$(zoxide init zsh)" 50 | -------------------------------------------------------------------------------- /rules/revive.toml: -------------------------------------------------------------------------------- 1 | ignoreGeneratedHeader = false 2 | severity = "warning" 3 | confidence = 0.8 4 | errorCode = 0 5 | warningCode = 0 6 | 7 | # [rule.add-constant] 8 | [rule.argument-limit] 9 | arguments = [4] 10 | [rule.atomic] 11 | # [rule.bare-return] 12 | [rule.blank-imports] 13 | [rule.bool-literal-in-expr] 14 | [rule.call-to-gc] 15 | # [rule.confusing-naming] 16 | [rule.confusing-results] 17 | [rule.constant-logical-expr] 18 | [rule.context-as-argument] 19 | [rule.context-keys-type] 20 | [rule.deep-exit] 21 | [rule.defer] 22 | # [rule.dot-imports] 23 | [rule.duplicated-imports] 24 | [rule.early-return] 25 | [rule.error-naming] 26 | [rule.error-return] 27 | [rule.error-strings] 28 | [rule.errorf] 29 | # [rule.exported] 30 | [rule.flag-parameter] 31 | [rule.function-result-limit] 32 | arguments = [3] 33 | [rule.get-return] 34 | [rule.identical-branches] 35 | [rule.if-return] 36 | [rule.increment-decrement] 37 | # [rule.indent-error-flow] 38 | [rule.import-shadowing] 39 | # [rule.line-length-limit] 40 | # arguments = [120] 41 | [rule.max-public-structs] 42 | arguments = [3] 43 | [rule.modifies-parameter] 44 | [rule.modifies-value-receiver] 45 | # [rule.nested-structs] 46 | # [rule.package-comments] 47 | [rule.range] 48 | [rule.range-val-in-closure] 49 | [rule.range-val-address] 50 | [rule.receiver-naming] 51 | [rule.redefines-builtin-id] 52 | [rule.string-of-int] 53 | [rule.struct-tag] 54 | # [rule.string-format] 55 | [rule.superfluous-else] 56 | [rule.time-naming] 57 | [rule.var-naming] 58 | [rule.var-declaration] 59 | [rule.unconditional-recursion] 60 | [rule.unexported-naming] 61 | [rule.unexported-return] 62 | # [rule.unhandled-error] 63 | # arguments = ["fmt.Fprint", "fmt.Fprintf"] 64 | [rule.unnecessary-stmt] 65 | [rule.unreachable-code] 66 | [rule.unused-parameter] 67 | [rule.unused-receiver] 68 | [rule.waitgroup-by-value] 69 | -------------------------------------------------------------------------------- /kitty/themes/catppuccin/latte.conf: -------------------------------------------------------------------------------- 1 | # vim:ft=kitty 2 | 3 | ## name: Catppuccin Kitty Latte 4 | ## author: Catppuccin Org 5 | ## license: MIT 6 | ## upstream: https://github.com/catppuccin/kitty/blob/main/themes/latte.conf 7 | ## blurb: Soothing pastel theme for the high-spirited! 8 | 9 | 10 | 11 | # The basic colors 12 | foreground #4c4f69 13 | background #eff1f5 14 | selection_foreground #eff1f5 15 | selection_background #dc8a78 16 | 17 | # Cursor colors 18 | cursor #dc8a78 19 | cursor_text_color #eff1f5 20 | 21 | # URL underline color when hovering with mouse 22 | url_color #dc8a78 23 | 24 | # Kitty window border colors 25 | active_border_color #7287fd 26 | inactive_border_color #9ca0b0 27 | bell_border_color #df8e1d 28 | 29 | # OS Window titlebar colors 30 | wayland_titlebar_color system 31 | macos_titlebar_color system 32 | 33 | # Tab bar colors 34 | active_tab_foreground #eff1f5 35 | active_tab_background #8839ef 36 | inactive_tab_foreground #4c4f69 37 | inactive_tab_background #9ca0b0 38 | tab_bar_background #bcc0cc 39 | 40 | # Colors for marks (marked text in the terminal) 41 | mark1_foreground #eff1f5 42 | mark1_background #7287fd 43 | mark2_foreground #eff1f5 44 | mark2_background #8839ef 45 | mark3_foreground #eff1f5 46 | mark3_background #209fb5 47 | 48 | # The 16 terminal colors 49 | 50 | # black 51 | color0 #5c5f77 52 | color8 #6c6f85 53 | 54 | # red 55 | color1 #d20f39 56 | color9 #d20f39 57 | 58 | # green 59 | color2 #40a02b 60 | color10 #40a02b 61 | 62 | # yellow 63 | color3 #df8e1d 64 | color11 #df8e1d 65 | 66 | # blue 67 | color4 #1e66f5 68 | color12 #1e66f5 69 | 70 | # magenta 71 | color5 #ea76cb 72 | color13 #ea76cb 73 | 74 | # cyan 75 | color6 #179299 76 | color14 #179299 77 | 78 | # white 79 | color7 #acb0be 80 | color15 #bcc0cc 81 | -------------------------------------------------------------------------------- /kitty/themes/catppuccin/mocha.conf: -------------------------------------------------------------------------------- 1 | # vim:ft=kitty 2 | 3 | ## name: Catppuccin Kitty Mocha 4 | ## author: Catppuccin Org 5 | ## license: MIT 6 | ## upstream: https://github.com/catppuccin/kitty/blob/main/themes/mocha.conf 7 | ## blurb: Soothing pastel theme for the high-spirited! 8 | 9 | 10 | 11 | # The basic colors 12 | foreground #cdd6f4 13 | background #1e1e2e 14 | selection_foreground #1e1e2e 15 | selection_background #f5e0dc 16 | 17 | # Cursor colors 18 | cursor #f5e0dc 19 | cursor_text_color #1e1e2e 20 | 21 | # URL underline color when hovering with mouse 22 | url_color #f5e0dc 23 | 24 | # Kitty window border colors 25 | active_border_color #b4befe 26 | inactive_border_color #6c7086 27 | bell_border_color #f9e2af 28 | 29 | # OS Window titlebar colors 30 | wayland_titlebar_color system 31 | macos_titlebar_color system 32 | 33 | # Tab bar colors 34 | active_tab_foreground #11111b 35 | active_tab_background #cba6f7 36 | inactive_tab_foreground #cdd6f4 37 | inactive_tab_background #181825 38 | tab_bar_background #11111b 39 | 40 | # Colors for marks (marked text in the terminal) 41 | mark1_foreground #1e1e2e 42 | mark1_background #b4befe 43 | mark2_foreground #1e1e2e 44 | mark2_background #cba6f7 45 | mark3_foreground #1e1e2e 46 | mark3_background #74c7ec 47 | 48 | # The 16 terminal colors 49 | 50 | # black 51 | color0 #45475a 52 | color8 #585b70 53 | 54 | # red 55 | color1 #f38ba8 56 | color9 #f38ba8 57 | 58 | # green 59 | color2 #a6e3a1 60 | color10 #a6e3a1 61 | 62 | # yellow 63 | color3 #f9e2af 64 | color11 #f9e2af 65 | 66 | # blue 67 | color4 #89b4fa 68 | color12 #89b4fa 69 | 70 | # magenta 71 | color5 #f5c2e7 72 | color13 #f5c2e7 73 | 74 | # cyan 75 | color6 #94e2d5 76 | color14 #94e2d5 77 | 78 | # white 79 | color7 #bac2de 80 | color15 #a6adc8 81 | -------------------------------------------------------------------------------- /kitty/themes/catppuccin/frappe.conf: -------------------------------------------------------------------------------- 1 | # vim:ft=kitty 2 | 3 | ## name: Catppuccin Kitty Frappé 4 | ## author: Catppuccin Org 5 | ## license: MIT 6 | ## upstream: https://github.com/catppuccin/kitty/blob/main/themes/frappe.conf 7 | ## blurb: Soothing pastel theme for the high-spirited! 8 | 9 | 10 | 11 | # The basic colors 12 | foreground #c6d0f5 13 | background #303446 14 | selection_foreground #303446 15 | selection_background #f2d5cf 16 | 17 | # Cursor colors 18 | cursor #f2d5cf 19 | cursor_text_color #303446 20 | 21 | # URL underline color when hovering with mouse 22 | url_color #f2d5cf 23 | 24 | # Kitty window border colors 25 | active_border_color #babbf1 26 | inactive_border_color #737994 27 | bell_border_color #e5c890 28 | 29 | # OS Window titlebar colors 30 | wayland_titlebar_color system 31 | macos_titlebar_color system 32 | 33 | # Tab bar colors 34 | active_tab_foreground #232634 35 | active_tab_background #ca9ee6 36 | inactive_tab_foreground #c6d0f5 37 | inactive_tab_background #292c3c 38 | tab_bar_background #232634 39 | 40 | # Colors for marks (marked text in the terminal) 41 | mark1_foreground #303446 42 | mark1_background #babbf1 43 | mark2_foreground #303446 44 | mark2_background #ca9ee6 45 | mark3_foreground #303446 46 | mark3_background #85c1dc 47 | 48 | # The 16 terminal colors 49 | 50 | # black 51 | color0 #51576d 52 | color8 #626880 53 | 54 | # red 55 | color1 #e78284 56 | color9 #e78284 57 | 58 | # green 59 | color2 #a6d189 60 | color10 #a6d189 61 | 62 | # yellow 63 | color3 #e5c890 64 | color11 #e5c890 65 | 66 | # blue 67 | color4 #8caaee 68 | color12 #8caaee 69 | 70 | # magenta 71 | color5 #f4b8e4 72 | color13 #f4b8e4 73 | 74 | # cyan 75 | color6 #81c8be 76 | color14 #81c8be 77 | 78 | # white 79 | color7 #b5bfe2 80 | color15 #a5adce 81 | -------------------------------------------------------------------------------- /nix/users/ika.nix: -------------------------------------------------------------------------------- 1 | { config, lib, pkgs, ... }: 2 | 3 | { 4 | home.stateVersion = "23.05"; 5 | 6 | home.file.".zshenv".text = '' 7 | source ${config.system.build.setEnvironment} 8 | source $HOME/.config/zsh/.zshenv 9 | ''; 10 | 11 | xdg.dataFile = with pkgs; { 12 | # Zsh plugins 13 | "zsh/zsh-autosuggestions".source = "${zsh-autosuggestions}/share/zsh-autosuggestions"; 14 | "zsh/zsh-completions".source = "${zsh-autosuggestions}/share/zsh-completions"; 15 | "zsh/zsh-history-substring-search".source = "${zsh-history-substring-search}/share/zsh-history-substring-search"; 16 | "zsh/zsh-syntax-highlighting".source = "${zsh-syntax-highlighting}/share/zsh-syntax-highlighting"; 17 | "zsh/fzf".source = "${fzf}/share/fzf"; 18 | }; 19 | 20 | programs.ssh = { 21 | enable = true; 22 | compression = true; 23 | serverAliveCountMax = 5; 24 | serverAliveInterval = 30; 25 | extraConfig = '' 26 | Host * 27 | IdentityAgent "~/Library/Group Containers/2BUA8C4S2C.com.1password/t/agent.sock" 28 | 29 | Host github.com 30 | Hostname ssh.github.com 31 | Port 443 32 | User git 33 | ''; 34 | }; 35 | 36 | programs.git = { 37 | enable = true; 38 | userName = "sxyazi"; 39 | userEmail = "sxyazi@gmail.com"; 40 | ignores = [ 41 | ".DS_Store" 42 | ]; 43 | signing = { 44 | key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIB7IT5qOcGD6ov8Z2OfgI2wHnfbYjYVZhi08OHTSyDoV"; 45 | signByDefault = true; 46 | }; 47 | extraConfig = { 48 | core = { 49 | editor = "nvim"; 50 | }; 51 | 52 | gpg.format = "ssh"; 53 | gpg.ssh.program = "/Applications/1Password.app/Contents/MacOS/op-ssh-sign"; 54 | 55 | push.default = "current"; 56 | push.autoSetupRemote = true; 57 | }; 58 | delta.enable = true; 59 | }; 60 | } 61 | 62 | -------------------------------------------------------------------------------- /kitty/themes/catppuccin/macchiato.conf: -------------------------------------------------------------------------------- 1 | # vim:ft=kitty 2 | 3 | ## name: Catppuccin Kitty Macchiato 4 | ## author: Catppuccin Org 5 | ## license: MIT 6 | ## upstream: https://github.com/catppuccin/kitty/blob/main/themes/macchiato.conf 7 | ## blurb: Soothing pastel theme for the high-spirited! 8 | 9 | 10 | 11 | # The basic colors 12 | foreground #cad3f5 13 | background #24273a 14 | selection_foreground #24273a 15 | selection_background #f4dbd6 16 | 17 | # Cursor colors 18 | cursor #f4dbd6 19 | cursor_text_color #24273a 20 | 21 | # URL underline color when hovering with mouse 22 | url_color #f4dbd6 23 | 24 | # Kitty window border colors 25 | active_border_color #b7bdf8 26 | inactive_border_color #6e738d 27 | bell_border_color #eed49f 28 | 29 | # OS Window titlebar colors 30 | wayland_titlebar_color system 31 | macos_titlebar_color system 32 | 33 | # Tab bar colors 34 | active_tab_foreground #181926 35 | active_tab_background #c6a0f6 36 | inactive_tab_foreground #cad3f5 37 | inactive_tab_background #1e2030 38 | tab_bar_background #181926 39 | 40 | # Colors for marks (marked text in the terminal) 41 | mark1_foreground #24273a 42 | mark1_background #b7bdf8 43 | mark2_foreground #24273a 44 | mark2_background #c6a0f6 45 | mark3_foreground #24273a 46 | mark3_background #7dc4e4 47 | 48 | # The 16 terminal colors 49 | 50 | # black 51 | color0 #494d64 52 | color8 #5b6078 53 | 54 | # red 55 | color1 #ed8796 56 | color9 #ed8796 57 | 58 | # green 59 | color2 #a6da95 60 | color10 #a6da95 61 | 62 | # yellow 63 | color3 #eed49f 64 | color11 #eed49f 65 | 66 | # blue 67 | color4 #8aadf4 68 | color12 #8aadf4 69 | 70 | # magenta 71 | color5 #f5bde6 72 | color13 #f5bde6 73 | 74 | # cyan 75 | color6 #8bd5ca 76 | color14 #8bd5ca 77 | 78 | # white 79 | color7 #b8c0e0 80 | color15 #a5adcb 81 | -------------------------------------------------------------------------------- /rules/stylelint/stylelint.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | extends: ["stylelint-config-standard"], 3 | rules : { 4 | // https://stylelint.io/user-guide/rules/#avoid-errors 5 | "at-rule-no-unknown": [true, { 6 | ignoreAtRules: ["tailwind", "apply"], 7 | }], 8 | "declaration-property-value-no-unknown": [true, { 9 | ignoreProperties: ["theme"], 10 | }], 11 | "function-no-unknown": [true, { 12 | ignoreFunctions: ["theme"], 13 | }], 14 | "no-unknown-animations" : true, 15 | "no-unknown-custom-properties": true, 16 | 17 | // https://stylelint.io/user-guide/rules/#enforce-conventions 18 | "at-rule-property-required-list": { 19 | "font-face": ["src", "font-display", "font-family", "font-style"], 20 | }, 21 | "color-hex-alpha" : "never", 22 | "color-named" : "always-where-possible", 23 | "media-feature-name-value-allowed-list": { 24 | "/resolution/" : "/dpcm$/", 25 | "/^(min|max)-width$/": ["320px", "480px", "768px", "1024px", "1280px", "1366px", "1440px", "1600px", "1920px", "2560px", "3840px"], 26 | }, 27 | "selector-no-qualifying-type" : [true, { ignore: ["attribute", "class"] }], 28 | "value-keyword-case" : ["lower", { camelCaseSvgKeywords: true }], 29 | "custom-property-empty-line-before": null, 30 | "selector-max-attribute" : 2, 31 | "selector-max-class" : 3, 32 | "selector-max-combinators" : 2, 33 | "selector-max-compound-selectors" : 3, 34 | "selector-max-id" : 1, 35 | "selector-max-pseudo-class" : 2, 36 | "selector-max-type" : 2, 37 | "selector-max-universal" : 1, 38 | "font-weight-notation" : "named-where-possible", 39 | "import-notation" : "string", 40 | "font-family-name-quotes" : "always-unless-keyword", 41 | }, 42 | } 43 | -------------------------------------------------------------------------------- /kitty/testing.py: -------------------------------------------------------------------------------- 1 | from kittens.tui.handler import result_handler 2 | from kitty.launch import launch, parse_launch_args 3 | import os 4 | import time 5 | import signal 6 | import shlex 7 | 8 | 9 | def process_exists(pid): 10 | try: 11 | os.kill(pid, 0) 12 | except OSError: 13 | return False 14 | else: 15 | return True 16 | 17 | 18 | def main(args): 19 | pass 20 | 21 | 22 | @result_handler(no_ui=True) 23 | def handle_result(args, answer, target_window_id, boss): 24 | window = None 25 | for w in boss.active_tab.windows: 26 | if w.title == "TEST_RUNNER": 27 | window = w 28 | break 29 | 30 | if window: 31 | if window.has_running_program: 32 | pid = window.child.pid_for_cwd 33 | 34 | os.kill(pid, signal.SIGTERM) 35 | time.sleep(0.2) 36 | 37 | i = 0 38 | while i < 5 and process_exists(pid): 39 | i += 1 40 | os.kill(pid, signal.SIGKILL) 41 | time.sleep(0.1) 42 | if process_exists(pid): 43 | raise Exception("Failed to terminate the process") 44 | 45 | window.send_text("normal", "\x03cd " + shlex.quote(args[1]) + "\n\x03") 46 | time.sleep(0.1) 47 | window.clear_screen(reset=True, scrollback=True) 48 | else: 49 | window = launch( 50 | boss, 51 | *parse_launch_args( 52 | [ 53 | "--cwd=" + args[1], 54 | "--title=TEST_RUNNER", 55 | "--location=hsplit", 56 | "--dont-take-focus", 57 | ] 58 | ) 59 | ) 60 | 61 | boss.active_tab.resize_window_by(window.id, -999, False) 62 | boss.active_tab.resize_window_by(window.id, +8, False) 63 | 64 | window.send_text("normal", args[2] + "\n") 65 | -------------------------------------------------------------------------------- /rules/eslint/plugins/yaml.js: -------------------------------------------------------------------------------- 1 | import jsonSchemaPlugin, { configs as jsonSchemaConfigs } from "eslint-plugin-json-schema-validator" 2 | import ymlPlugin, { configs as ymlConfigs } from "eslint-plugin-yml" 3 | import ymlParser from "yaml-eslint-parser" 4 | 5 | import { fmRules } from "./formatting.js" 6 | 7 | export const ymlRules = { 8 | // https://ota-meshi.github.io/eslint-plugin-yml/rules/#yaml-rules 9 | "yml/block-mapping-colon-indicator-newline": "warn", 10 | "yml/block-mapping-question-indicator-newline": "warn", 11 | "yml/block-mapping": ["warn", { singleline: "never", multiline: "always" }], 12 | "yml/block-sequence-hyphen-indicator-newline": "warn", 13 | "yml/block-sequence": ["warn", { singleline: "never", multiline: "always" }], 14 | "yml/indent": "warn", 15 | "yml/no-trailing-zeros": "warn", 16 | "yml/plain-scalar": "warn", 17 | "yml/quotes": "warn", 18 | 19 | // https://ota-meshi.github.io/eslint-plugin-yml/rules/#extension-rules 20 | "yml/flow-mapping-curly-newline": fmRules["object-curly-newline"], 21 | "yml/flow-mapping-curly-spacing": fmRules["object-curly-spacing"], 22 | "yml/flow-sequence-bracket-newline": fmRules["array-bracket-newline"], 23 | "yml/flow-sequence-bracket-spacing": fmRules["array-bracket-spacing"], 24 | "yml/key-spacing": fmRules["key-spacing"], 25 | "yml/no-multiple-empty-lines": fmRules["no-multiple-empty-lines"], 26 | "yml/spaced-comment": fmRules["spaced-comment"], 27 | } 28 | 29 | /** @type { import('eslint').Linter.FlatConfig[] } */ 30 | export const yaml = [ 31 | { 32 | files: ["**/*.{yaml,yml}"], 33 | languageOptions: { parser: ymlParser }, 34 | plugins: { 35 | "yml": ymlPlugin, 36 | "json-schema-validator": jsonSchemaPlugin, 37 | }, 38 | rules: { 39 | // eslint-plugin-yml 40 | ...ymlConfigs.recommended.rules, 41 | ...ymlRules, 42 | 43 | // eslint-plugin-json-schema-validator 44 | ...jsonSchemaConfigs.recommended.rules, 45 | }, 46 | }, 47 | ] 48 | -------------------------------------------------------------------------------- /rules/eslint/plugins/toml.js: -------------------------------------------------------------------------------- 1 | import jsonSchemaPlugin, { configs as jsonSchemaConfigs } from "eslint-plugin-json-schema-validator" 2 | import tomlPlugin, { configs as tomlConfigs } from "eslint-plugin-toml" 3 | import tomlParser from "toml-eslint-parser" 4 | 5 | import { fmRules } from "./formatting.js" 6 | 7 | export const tomlRules = { 8 | // https://ota-meshi.github.io/eslint-plugin-toml/rules/#toml-rules 9 | "toml/indent" : ["warn", "tab", { subTables: 1 }], 10 | "toml/keys-order" : "warn", 11 | "toml/no-non-decimal-integer" : "warn", 12 | "toml/no-space-dots" : "warn", 13 | "toml/padding-line-between-pairs" : "warn", 14 | "toml/padding-line-between-tables": "warn", 15 | "toml/quoted-keys" : "warn", 16 | "toml/tables-order" : "warn", 17 | 18 | // https://ota-meshi.github.io/eslint-plugin-toml/rules/#extension-rules 19 | "toml/array-bracket-newline" : fmRules["array-bracket-newline"], 20 | "toml/array-bracket-spacing" : fmRules["array-bracket-spacing"], 21 | "toml/array-element-newline" : fmRules["array-element-newline"], 22 | "toml/comma-style" : fmRules["comma-style"], 23 | "toml/inline-table-curly-spacing": fmRules["object-curly-spacing"], 24 | "toml/key-spacing" : ["warn", { align: "equal" }], 25 | "toml/spaced-comment" : ["warn", "always", { markers: ["#"] }], 26 | "toml/table-bracket-spacing" : fmRules["array-bracket-spacing"], 27 | } 28 | 29 | /** @type { import('eslint').Linter.FlatConfig[] } */ 30 | export const toml = [ 31 | { 32 | files : ["**/*.toml"], 33 | languageOptions: { parser: tomlParser }, 34 | plugins : { 35 | "toml" : tomlPlugin, 36 | "json-schema-validator": jsonSchemaPlugin, 37 | }, 38 | rules: { 39 | // eslint-plugin-toml 40 | ...tomlConfigs.recommended.rules, 41 | ...tomlRules, 42 | 43 | // eslint-plugin-json-schema-validator 44 | ...jsonSchemaConfigs.recommended.rules, 45 | }, 46 | }, 47 | ] 48 | -------------------------------------------------------------------------------- /yazi/package.toml: -------------------------------------------------------------------------------- 1 | [[plugin.deps]] 2 | use = "Rolv-Apneseth/starship" 3 | rev = "6a0f3f7" 4 | hash = "d5a74d95c2e8194ac352c5e10e81e64f" 5 | 6 | [[plugin.deps]] 7 | use = "yazi-rs/plugins:chmod" 8 | rev = "cbc4450" 9 | hash = "1adc12c2b2b025411ab61eb8f0879574" 10 | 11 | [[plugin.deps]] 12 | use = "yazi-rs/plugins:diff" 13 | rev = "cbc4450" 14 | hash = "47865a70cade14a0b9b6bc6a54f16bdb" 15 | 16 | [[plugin.deps]] 17 | use = "yazi-rs/plugins:full-border" 18 | rev = "cbc4450" 19 | hash = "3996fc74044bc44144b323686f887e1" 20 | 21 | [[plugin.deps]] 22 | use = "yazi-rs/plugins:git" 23 | rev = "cbc4450" 24 | hash = "a57f09c9e61ffc850d8ea8c6fc1efb2c" 25 | 26 | [[plugin.deps]] 27 | use = "yazi-rs/plugins:mactag" 28 | rev = "cbc4450" 29 | hash = "72dfb25e9d0c015365827431e28df322" 30 | 31 | [[plugin.deps]] 32 | use = "yazi-rs/plugins:mount" 33 | rev = "cbc4450" 34 | hash = "f10a14e823382d90fab5b3ee54cb38fe" 35 | 36 | [[plugin.deps]] 37 | use = "yazi-rs/plugins:smart-enter" 38 | rev = "cbc4450" 39 | hash = "56fdabc96fc1f4d53c96eb884b02a5be" 40 | 41 | [[plugin.deps]] 42 | use = "yazi-rs/plugins:vcs-files" 43 | rev = "cbc4450" 44 | hash = "cc8da55f1deda45ee3787cc97b58ffc9" 45 | 46 | [[plugin.deps]] 47 | use = "yazi-rs/plugins:toggle-pane" 48 | rev = "cbc4450" 49 | hash = "d6f60c24d8c0cf57a855bf46115b2502" 50 | 51 | [[plugin.deps]] 52 | use = "yazi-rs/plugins:piper" 53 | rev = "cbc4450" 54 | hash = "2143a53182dbbe935a1abd1623424aa5" 55 | 56 | [[plugin.deps]] 57 | use = "yazi-rs/plugins:types" 58 | rev = "cbc4450" 59 | hash = "1e047e1b13b5e3fc6ab1f5d0d04a14e2" 60 | 61 | [[plugin.deps]] 62 | use = "TKperson/yazip" 63 | rev = "de4098e" 64 | hash = "2650b3b34087f3bfaa95846149a17f2e" 65 | 66 | [[plugin.deps]] 67 | use = "yazi-rs/plugins:zoom" 68 | rev = "b886025" 69 | hash = "23d704e18d864036fc65c188bc6b2e47" 70 | 71 | [[flavor.deps]] 72 | use = "yazi-rs/flavors:catppuccin-latte" 73 | rev = "d04a298" 74 | hash = "a4d508772dc7b20d739a2f9a1d2d396f" 75 | 76 | [[flavor.deps]] 77 | use = "yazi-rs/flavors:catppuccin-macchiato" 78 | rev = "d04a298" 79 | hash = "e6c5beeb1da3199355734273ee452a7f" 80 | -------------------------------------------------------------------------------- /nvim/lua/plugins/theme.lua: -------------------------------------------------------------------------------- 1 | return { 2 | { 3 | "folke/tokyonight.nvim", 4 | lazy = false, 5 | priority = 1000, 6 | enabled = false, 7 | opts = { 8 | transparent = true, 9 | styles = { 10 | sidebars = "transparent", 11 | floats = "transparent", 12 | }, 13 | }, 14 | config = function(_, opts) 15 | require("tokyonight").setup(opts) 16 | vim.cmd.colorscheme("tokyonight") 17 | end, 18 | }, 19 | 20 | { 21 | "catppuccin/nvim", 22 | name = "catppuccin", 23 | lazy = false, 24 | priority = 1000, 25 | build = ":CatppuccinCompile", 26 | enabled = true, 27 | opts = { 28 | flavour = "macchiato", 29 | background = { light = "latte", dark = "macchiato" }, 30 | transparent_background = true, 31 | float = { transparent = true, solid = true }, 32 | term_colors = true, 33 | custom_highlights = function(C) 34 | local O = require("catppuccin").options 35 | return { 36 | ["@module"] = { fg = C.lavender, style = O.styles.miscs or { "italic" } }, 37 | ["@type.builtin"] = { fg = C.yellow, style = O.styles.properties or { "italic" } }, 38 | ["@property"] = { fg = C.lavender, style = O.styles.properties or {} }, 39 | } 40 | end, 41 | integrations = { 42 | bufferline = false, 43 | cmp = true, 44 | fidget = true, 45 | gitsigns = true, 46 | illuminate = true, 47 | indent_blankline = { enabled = true }, 48 | lsp_trouble = true, 49 | markdown = true, 50 | mason = true, 51 | native_lsp = { 52 | enabled = true, 53 | underlines = { 54 | errors = { "undercurl" }, 55 | hints = { "undercurl" }, 56 | warnings = { "undercurl" }, 57 | information = { "undercurl" }, 58 | }, 59 | }, 60 | neotree = true, 61 | noice = true, 62 | notify = true, 63 | rainbow_delimiters = true, 64 | telescope = true, 65 | treesitter = true, 66 | treesitter_context = true, 67 | }, 68 | }, 69 | config = function(_, opts) 70 | require("catppuccin").setup(opts) 71 | vim.cmd.colorscheme("catppuccin") 72 | end, 73 | }, 74 | } 75 | -------------------------------------------------------------------------------- /lazygit/config.yml: -------------------------------------------------------------------------------- 1 | gui: 2 | sidePanelWidth: 0.2 3 | expandFocusedSidePanel: true 4 | language: en 5 | mouseEvents: false 6 | nerdFontsVersion: "3" 7 | git: 8 | paging: 9 | colorArg: always 10 | # pager: delta --dark --paging=never --syntax-theme="Catppuccin Mocha" 11 | externalDiffCommand: difft --color=always --display=inline --syntax-highlight=off 12 | update: 13 | method: never 14 | notARepository: quit 15 | promptToReturnFromSubprocess: false 16 | keybinding: 17 | universal: 18 | prevItem-alt: u 19 | nextItem-alt: e 20 | prevBlock-alt: n 21 | nextBlock-alt: i 22 | nextBlock-alt2: 23 | prevBlock-alt2: 24 | scrollUpMain-alt1: U 25 | scrollDownMain-alt1: E 26 | scrollLeft: N 27 | scrollRight: I 28 | nextMatch: "-" 29 | prevMatch: = 30 | new: k 31 | edit: o 32 | openFile: O 33 | nextTab: 34 | prevTab: 35 | undo: l 36 | redo: L 37 | status: 38 | checkForUpdate: 39 | files: 40 | ignoreFile: . 41 | branches: 42 | viewGitFlowOptions: I 43 | setUpstream: s 44 | commits: 45 | moveUpCommit: 46 | moveDownCommit: 47 | startInteractiveRebase: I 48 | main: 49 | editSelectHunk: 50 | submodules: 51 | init: c 52 | customCommands: 53 | - key: v 54 | context: localBranches 55 | loadingText: Checking out GitHub Pull Request... 56 | command: gh pr checkout {{.Form.PullRequestNumber}} 57 | prompts: 58 | - type: menuFromCommand 59 | title: Which PR do you want to check out? 60 | key: PullRequestNumber 61 | command: >- 62 | gh pr list --json number,title,headRefName,updatedAt 63 | --template '{{`{{range .}}{{printf "#%v: %s - %s (%s)" .number .title .headRefName (timeago .updatedAt)}}{{end}}`}}' 64 | filter: "#(?P[0-9]+): (?P.+) - (?P<ref_name>[^ ]+).*" 65 | valueFormat: "{{.number}}" 66 | labelFormat: '{{"#" | black | bold}}{{.number | white | bold}} {{.title | yellow | bold}}{{" [" | black | bold}}{{.ref_name | green}}{{"]" | black | bold}}' 67 | -------------------------------------------------------------------------------- /nvim/lua/terminal.lua: -------------------------------------------------------------------------------- 1 | local M = { 2 | height = 15, 3 | window = nil, 4 | buffer = nil, 5 | job_id = nil, 6 | } 7 | 8 | function M.open(cwd) 9 | if vim.fn.win_gotoid(M.window) == 0 then 10 | vim.cmd("new") 11 | vim.cmd("setlocal nonumber") 12 | vim.cmd("setlocal signcolumn=no") 13 | vim.cmd("setlocal nobuflisted") 14 | M.window = vim.fn.win_getid() 15 | end 16 | vim.api.nvim_win_set_height(M.window, M.height) 17 | 18 | if vim.fn.bufexists(M.buffer) == 0 then 19 | local job_id = nil 20 | M.buffer = vim.fn.bufnr("%") 21 | M.job_id = vim.fn.termopen(vim.o.shell, { 22 | cwd = cwd or vim.fn.getcwd(), 23 | detach = true, 24 | on_exit = function() 25 | if M.job_id == job_id then 26 | M.destroy() 27 | end 28 | end, 29 | }) 30 | job_id = M.job_id 31 | else 32 | vim.cmd("buffer " .. M.buffer) 33 | end 34 | end 35 | 36 | function M.hide() 37 | M.height = vim.api.nvim_win_get_height(M.window) 38 | vim.api.nvim_win_hide(M.window) 39 | end 40 | 41 | function M.destroy() 42 | if vim.fn.win_gotoid(M.window) ~= 0 then 43 | M.height = vim.api.nvim_win_get_height(M.window) 44 | end 45 | if vim.fn.bufexists(M.buffer) == 1 then 46 | vim.api.nvim_buf_delete(M.buffer, { force = true }) 47 | end 48 | 49 | M.window = nil 50 | M.buffer = nil 51 | M.job_id = nil 52 | end 53 | 54 | function M.exec(cwd, cmd) 55 | M.destroy() 56 | M.open(cwd) 57 | vim.fn.chansend(M.job_id, cmd .. "\n") 58 | vim.cmd("wincmd p") 59 | end 60 | 61 | vim.api.nvim_create_user_command("TerminalOpen", function() M.open(nil) end, {}) 62 | vim.api.nvim_create_user_command("TerminalHide", M.hide, {}) 63 | vim.api.nvim_create_user_command("TerminalDestroy", M.destroy, {}) 64 | 65 | -- Toggle 66 | vim.keymap.set("", "<C-\\>", ":TerminalOpen<CR>:startinsert<CR>", { silent = true }) 67 | vim.keymap.set("i", "<C-\\>", "<Esc>:TerminalOpen<CR>:startinsert<CR>", { silent = true }) 68 | vim.keymap.set("t", "<C-\\>", "<C-\\><C-n>:TerminalHide<CR>", { silent = true }) 69 | 70 | -- Close 71 | vim.keymap.set("t", "<C-S-M-w>c", "<C-\\><C-n>:TerminalDestroy<CR>", { silent = true }) 72 | 73 | -- Move cursor to the end of line, specific to zsh 74 | vim.keymap.set("t", "<Tab>", "<Tab>") 75 | vim.keymap.set("t", "<C-i>", "\x1b[105;5u") 76 | 77 | return M 78 | -------------------------------------------------------------------------------- /zsh/function.zsh: -------------------------------------------------------------------------------- 1 | # Alias 2 | alias ..="cd .." 3 | alias ...="cd ../.." 4 | alias ~="cd ~" 5 | alias -- -="cd -" 6 | 7 | alias p="pwd" 8 | alias v="nvim" 9 | alias l="eza -al --icons --group-directories-first" 10 | alias ll="eza -a --icons --group-directories-first" 11 | alias ssh="kitty +kitten ssh" 12 | alias du="dust -r -n 999999999" 13 | alias tree="tree -aC" 14 | alias icpng="mkdir converted-images; sips -s format png * --out converted-images" 15 | alias icjpg="mkdir converted-images; sips -s format jpeg * --out converted-images" 16 | 17 | alias g='XDG_CONFIG_HOME="$HOME/.config" lazygit' 18 | alias gs="git status" 19 | alias ga="git add -A" 20 | alias gc="git commit -v" 21 | alias gc!="git commit -v --amend --no-edit" 22 | alias gl="git pull" 23 | alias gp="git push" 24 | alias gp!="git push --force" 25 | alias gcl="git clone --depth 1 --single-branch" 26 | alias gf="git fetch --all" 27 | alias gb="git branch" 28 | alias gr="git rebase" 29 | alias gt='cd "$(git rev-parse --show-toplevel)"' 30 | 31 | alias rl="echo '' > ~/.local/state/yazi/yazi.log; tail -F ~/.local/state/yazi/yazi.log" 32 | alias rr="~/Desktop/yazi/target/debug/yazi --clear-cache" 33 | 34 | function y() { 35 | local tmp="$(mktemp -t "yazi-cwd.XXXXXX")" cwd 36 | YAZI_LOG=debug yazi "$@" --cwd-file="$tmp" 37 | IFS= read -r -d '' cwd < "$tmp" 38 | [ -n "$cwd" ] && [ "$cwd" != "$PWD" ] && builtin cd -- "$cwd" 39 | rm -f -- "$tmp" 40 | } 41 | 42 | function r() { 43 | local old="$PWD" 44 | cd ~/Desktop/yazi && cargo build -p yazi-fm 45 | cd "$old" 46 | RUST_BACKTRACE=1 YAZI_LOG=debug ~/Desktop/yazi/target/debug/yazi "$@" 47 | } 48 | 49 | function gpr() { 50 | local username=$(git config user.name) 51 | if [ -z "$username" ]; then 52 | echo "Please set your git username" 53 | return 1 54 | fi 55 | 56 | local origin=$(git config remote.origin.url) 57 | if [ -z "$origin" ]; then 58 | echo "No remote origin found" 59 | return 1 60 | fi 61 | 62 | local remote_username=$(basename $(dirname $origin)) 63 | if [ "$remote_username" != "$username" ]; then 64 | local new_origin=${origin/\/$remote_username\//\/$username\/} 65 | new_origin=${new_origin/https:\/\/github.com\//git@github.com:/} 66 | 67 | git config remote.origin.url $new_origin 68 | git remote remove upstream > /dev/null 2>&1 69 | git remote add upstream $origin 70 | fi 71 | 72 | git checkout -b "pr-$(openssl rand -hex 4)" 73 | } 74 | 75 | # Change Yazi's CWD to PWD on subshell exit 76 | if [[ -n "$YAZI_ID" ]]; then 77 | function _yazi_cd() { 78 | ya emit cd "$PWD" 79 | } 80 | add-zsh-hook zshexit _yazi_cd 81 | fi 82 | -------------------------------------------------------------------------------- /mpv/shaders/Anime4K_Denoise_Bilateral_Mean.glsl: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019-2021 bloc97 4 | // All rights reserved. 5 | 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | 24 | //!DESC Anime4K-v3.2-Denoise-Bilateral-Mean 25 | //!HOOK MAIN 26 | //!BIND HOOKED 27 | 28 | #define INTENSITY_SIGMA 0.1 //Intensity window size, higher is stronger denoise, must be a positive real number 29 | #define SPATIAL_SIGMA 1.0 //Spatial window size, higher is stronger denoise, must be a positive real number. 30 | 31 | #define INTENSITY_POWER_CURVE 1.0 //Intensity window power curve. Setting it to 0 will make the intensity window treat all intensities equally, while increasing it will make the window narrower in darker intensities and wider in brighter intensities. 32 | 33 | #define KERNELSIZE (max(int(ceil(SPATIAL_SIGMA * 2.0)), 1) * 2 + 1) //Kernel size, must be an positive odd integer. 34 | #define KERNELHALFSIZE (int(KERNELSIZE/2)) //Half of the kernel size without remainder. Must be equal to trunc(KERNELSIZE/2). 35 | #define KERNELLEN (KERNELSIZE * KERNELSIZE) //Total area of kernel. Must be equal to KERNELSIZE * KERNELSIZE. 36 | 37 | #define GETOFFSET(i) vec2((i % KERNELSIZE) - KERNELHALFSIZE, (i / KERNELSIZE) - KERNELHALFSIZE) 38 | 39 | vec4 gaussian_vec(vec4 x, vec4 s, vec4 m) { 40 | vec4 scaled = (x - m) / s; 41 | return exp(-0.5 * scaled * scaled); 42 | } 43 | 44 | float gaussian(float x, float s, float m) { 45 | float scaled = (x - m) / s; 46 | return exp(-0.5 * scaled * scaled); 47 | } 48 | 49 | vec4 hook() { 50 | vec4 sum = vec4(0.0); 51 | vec4 n = vec4(0.0); 52 | 53 | vec4 vc = HOOKED_tex(HOOKED_pos); 54 | 55 | vec4 is = pow(vc + 0.0001, vec4(INTENSITY_POWER_CURVE)) * INTENSITY_SIGMA; 56 | float ss = SPATIAL_SIGMA; 57 | 58 | for (int i=0; i<KERNELLEN; i++) { 59 | vec2 ipos = GETOFFSET(i); 60 | vec4 v = HOOKED_texOff(ipos); 61 | vec4 d = gaussian_vec(v, is, vc) * gaussian(length(ipos), ss, 0.0); 62 | sum += d * v; 63 | n += d; 64 | } 65 | 66 | return sum / n; 67 | } -------------------------------------------------------------------------------- /mpv/shaders/Anime4K_Clamp_Highlights.glsl: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019-2021 bloc97 4 | // All rights reserved. 5 | 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | 24 | //!DESC Anime4K-v4.0-De-Ring-Compute-Statistics 25 | //!HOOK MAIN 26 | //!BIND HOOKED 27 | //!SAVE STATSMAX 28 | //!COMPONENTS 1 29 | 30 | #define KERNELSIZE 5 //Kernel size, must be an positive odd integer. 31 | #define KERNELHALFSIZE 2 //Half of the kernel size without remainder. Must be equal to trunc(KERNELSIZE/2). 32 | 33 | float get_luma(vec4 rgba) { 34 | return dot(vec4(0.299, 0.587, 0.114, 0.0), rgba); 35 | } 36 | 37 | vec4 hook() { 38 | 39 | float gmax = 0.0; 40 | 41 | for (int i=0; i<KERNELSIZE; i++) { 42 | float g = get_luma(MAIN_texOff(vec2(i - KERNELHALFSIZE, 0))); 43 | 44 | gmax = max(g, gmax); 45 | } 46 | 47 | return vec4(gmax, 0.0, 0.0, 0.0); 48 | } 49 | 50 | //!DESC Anime4K-v4.0-De-Ring-Compute-Statistics 51 | //!HOOK MAIN 52 | //!BIND HOOKED 53 | //!BIND STATSMAX 54 | //!SAVE STATSMAX 55 | //!COMPONENTS 1 56 | 57 | #define KERNELSIZE 5 //Kernel size, must be an positive odd integer. 58 | #define KERNELHALFSIZE 2 //Half of the kernel size without remainder. Must be equal to trunc(KERNELSIZE/2). 59 | 60 | vec4 hook() { 61 | 62 | float gmax = 0.0; 63 | 64 | for (int i=0; i<KERNELSIZE; i++) { 65 | float g = STATSMAX_texOff(vec2(0, i - KERNELHALFSIZE)).x; 66 | 67 | gmax = max(g, gmax); 68 | } 69 | 70 | return vec4(gmax, 0.0, 0.0, 0.0); 71 | } 72 | 73 | //!DESC Anime4K-v4.0-De-Ring-Clamp 74 | //!HOOK PREKERNEL 75 | //!BIND HOOKED 76 | //!BIND STATSMAX 77 | 78 | float get_luma(vec4 rgba) { 79 | return dot(vec4(0.299, 0.587, 0.114, 0.0), rgba); 80 | } 81 | 82 | vec4 hook() { 83 | 84 | float current_luma = get_luma(HOOKED_tex(HOOKED_pos)); 85 | float new_luma = min(current_luma, STATSMAX_tex(HOOKED_pos).x); 86 | 87 | //This trick is only possible if the inverse Y->RGB matrix has 1 for every row... (which is the case for BT.709) 88 | //Otherwise we would need to convert RGB to YUV, modify Y then convert back to RGB. 89 | return HOOKED_tex(HOOKED_pos) - (current_luma - new_luma); 90 | } -------------------------------------------------------------------------------- /yazi/keymap.toml: -------------------------------------------------------------------------------- 1 | "$schema" = "https://yazi-rs.github.io/schemas/keymap.json" 2 | 3 | [mgr] 4 | 5 | prepend_keymap = [ 6 | # Hopping 7 | { on = "u", run = "arrow prev" }, 8 | { on = "e", run = "arrow next" }, 9 | 10 | { on = "U", run = "arrow -5" }, 11 | { on = "E", run = "arrow 5" }, 12 | 13 | # Navigation 14 | { on = "n", run = "leave" }, 15 | { on = "i", run = "plugin smart-enter" }, 16 | 17 | { on = "N", run = "back" }, 18 | { on = "I", run = "forward" }, 19 | 20 | # Seeking 21 | { on = "<C-u>", run = "seek -5" }, 22 | { on = "<C-e>", run = "seek 5" }, 23 | 24 | # Operation 25 | { on = "l", run = "link" }, 26 | { on = "L", run = "link --relative" }, 27 | 28 | # Find 29 | { on = "-", run = "find_arrow" }, 30 | { on = "=", run = "find_arrow --previous" }, 31 | 32 | # Goto 33 | { on = [ "g", "r" ], run = 'shell -- ya emit cd "$(git rev-parse --show-toplevel)"' }, 34 | { on = [ "g", "v" ], run = 'shell -- ya emit cd "$(zoxide query Friends)"' }, 35 | { on = [ "g", "c" ], run = "plugin vcs-files" }, 36 | 37 | # Shell 38 | { on = "$", run = "shell --block $SHELL" }, 39 | 40 | # Plugins 41 | { on = "M", run = "plugin mount" }, 42 | { on = "<C-d>", run = "plugin diff" }, 43 | { on = [ "c", "m" ], run = "plugin chmod" }, 44 | { on = [ "b", "a" ], run = "plugin mactag add" }, 45 | { on = [ "b", "r" ], run = "plugin mactag remove" }, 46 | { on = "<C-1>", run = "plugin toggle-pane max-parent" }, 47 | { on = "<C-2>", run = "plugin toggle-pane max-current" }, 48 | { on = "<C-3>", run = "plugin toggle-pane max-preview" }, 49 | ] 50 | 51 | [tasks] 52 | 53 | prepend_keymap = [ 54 | { on = "u", run = "arrow prev" }, 55 | { on = "e", run = "arrow next" }, 56 | ] 57 | 58 | [spot] 59 | 60 | prepend_keymap = [ 61 | { on = "u", run = "arrow prev" }, 62 | { on = "e", run = "arrow next" }, 63 | { on = "n", run = "swipe prev" }, 64 | { on = "i", run = "swipe next" }, 65 | ] 66 | 67 | [pick] 68 | 69 | prepend_keymap = [ 70 | { on = "u", run = "arrow prev" }, 71 | { on = "e", run = "arrow next" }, 72 | ] 73 | 74 | [input] 75 | 76 | prepend_keymap = [ 77 | # Mode 78 | { on = "k", run = "insert" }, 79 | { on = "<C-n>", run = [ "move bol", "insert" ] }, 80 | { on = "<C-i>", run = [ "move eol", "insert --append" ] }, 81 | 82 | # Character-wise movement 83 | { on = "n", run = "move -1" }, 84 | { on = "i", run = "move 1" }, 85 | 86 | # Word-wise movement 87 | { on = "h", run = "forward --end-of-word" }, 88 | 89 | # Line-wise movement 90 | { on = "N", run = "move bol" }, 91 | { on = "I", run = "move eol" }, 92 | 93 | # Cut/Yank/Paste 94 | { on = "x", run = [ "delete", "move 1 --in-operating" ] }, 95 | 96 | # Undo/Redo 97 | { on = "l", run = "undo" }, 98 | { on = "L", run = "redo" }, 99 | ] 100 | 101 | [confirm] 102 | 103 | prepend_keymap = [ 104 | { on = "u", run = "arrow prev" }, 105 | { on = "e", run = "arrow next" }, 106 | ] 107 | 108 | [cmp] 109 | 110 | prepend_keymap = [ 111 | { on = "<C-u>", run = "arrow prev" }, 112 | { on = "<C-e>", run = "arrow next" }, 113 | ] 114 | 115 | [help] 116 | 117 | prepend_keymap = [ 118 | # Navigation 119 | { on = "u", run = "arrow prev" }, 120 | { on = "e", run = "arrow next" }, 121 | 122 | { on = "U", run = "arrow -5" }, 123 | { on = "E", run = "arrow 5" }, 124 | ] 125 | -------------------------------------------------------------------------------- /nvim/lua/core.lua: -------------------------------------------------------------------------------- 1 | -- Editing 2 | vim.opt.number = true 3 | vim.opt.cursorline = true 4 | 5 | vim.opt.clipboard = "unnamedplus" 6 | 7 | vim.opt.wrap = false 8 | vim.opt.linebreak = true 9 | vim.opt.showbreak = "↳" 10 | vim.opt.whichwrap = "h,l,<,>" 11 | 12 | vim.opt.scrolloff = 5 13 | vim.opt.sidescrolloff = 5 14 | vim.opt.virtualedit = "block" 15 | 16 | -- Searching 17 | vim.opt.ignorecase = true 18 | vim.opt.smartcase = true 19 | vim.opt.infercase = true 20 | vim.opt.hlsearch = false 21 | 22 | -- Indent 23 | vim.opt.tabstop = 2 24 | vim.opt.shiftwidth = 2 25 | vim.opt.smartindent = true 26 | 27 | -- Folding 28 | vim.opt.foldlevel = 99 29 | vim.opt.foldmethod = "expr" 30 | vim.opt.foldexpr = "nvim_treesitter#foldexpr()" 31 | 32 | -- UI 33 | vim.opt.winblend = 0 34 | vim.opt.pumblend = 0 35 | vim.opt.pumheight = 15 36 | 37 | vim.opt.showmode = false 38 | vim.opt.showcmd = false 39 | vim.opt.cmdheight = 0 40 | vim.opt.laststatus = 3 41 | 42 | vim.opt.ruler = false 43 | vim.opt.signcolumn = "yes" 44 | vim.opt.shortmess = "fimnxsTAIcF" 45 | 46 | -- Cache/Log file 47 | vim.opt.swapfile = false 48 | vim.opt.undofile = true 49 | vim.opt.undodir = vim.fn.expand("$HOME/.cache/nvim/undo") 50 | vim.opt.backupdir = vim.fn.expand("$HOME/.cache/nvim/backup") 51 | vim.opt.viewdir = vim.fn.expand("$HOME/.cache/nvim/view") 52 | vim.lsp.log.set_level("off") 53 | 54 | -- Rendering 55 | vim.opt.termguicolors = true 56 | 57 | -- Misc 58 | vim.opt.history = 1000 59 | vim.opt.wildignorecase = true 60 | 61 | vim.opt.ttimeoutlen = 10 62 | 63 | vim.g.loaded_gzip = 1 64 | vim.g.loaded_netrw = 1 65 | vim.g.loaded_netrwPlugin = 1 66 | vim.g.loaded_matchparen = 1 67 | vim.g.loaded_tar = 1 68 | vim.g.loaded_tarPlugin = 1 69 | vim.g.loaded_zip = 1 70 | vim.g.loaded_zipPlugin = 1 71 | 72 | vim.g.loaded_python3_provider = 0 73 | vim.g.loaded_ruby_provider = 0 74 | vim.g.loaded_node_provider = 0 75 | vim.g.loaded_perl_provider = 0 76 | 77 | -- Diagnostic 78 | vim.opt.updatetime = 300 79 | vim.cmd([[autocmd CursorHold * lua vim.diagnostic.open_float()]]) 80 | 81 | vim.fn.sign_define("DiagnosticSignError", { text = " ", texthl = "DiagnosticSignError" }) 82 | vim.fn.sign_define("DiagnosticSignWarn", { text = " ", texthl = "DiagnosticSignWarn" }) 83 | vim.fn.sign_define("DiagnosticSignInfo", { text = " ", texthl = "DiagnosticSignInfo" }) 84 | vim.fn.sign_define("DiagnosticSignHint", { text = "󰌵", texthl = "DiagnosticSignHint" }) 85 | 86 | vim.diagnostic.config { 87 | virtual_text = false, 88 | float = { header = "", prefix = "", focusable = false }, 89 | update_in_insert = true, 90 | severity_sort = true, 91 | } 92 | 93 | -- Restore cursor position when opening a file 94 | -- https://github.com/neovim/neovim/issues/16339#issuecomment-1457394370 95 | vim.api.nvim_create_autocmd("BufRead", { 96 | callback = function(opts) 97 | vim.api.nvim_create_autocmd("BufWinEnter", { 98 | once = true, 99 | buffer = opts.buf, 100 | callback = function() 101 | local ft = vim.bo[opts.buf].filetype 102 | local last_known_line = vim.api.nvim_buf_get_mark(opts.buf, '"')[1] 103 | if 104 | not (ft:match("commit") and ft:match("rebase")) 105 | and last_known_line > 1 106 | and last_known_line <= vim.api.nvim_buf_line_count(opts.buf) 107 | then 108 | vim.api.nvim_feedkeys('g`"', "nx", false) 109 | end 110 | end, 111 | }) 112 | end, 113 | }) 114 | -------------------------------------------------------------------------------- /kitty/window.py: -------------------------------------------------------------------------------- 1 | from kittens.tui.handler import result_handler 2 | 3 | directions = { 4 | "top": "u", 5 | "bottom": "e", 6 | "left": "n", 7 | "right": "i", 8 | } 9 | 10 | 11 | def main(args): 12 | pass 13 | 14 | 15 | @result_handler(no_ui=True) 16 | def handle_result(args, answer, target_window_id, boss): 17 | window = boss.active_window 18 | if window is None: 19 | return 20 | 21 | cmd = window.child.foreground_cmdline[0] 22 | act = args[1] # e.g. -jump 23 | if act[0] == "-" and cmd[-4:] == "nvim": 24 | second = directions[args[2]] if len(args) > 2 else "" 25 | window.write_to_child(f"\x1b[119;8u{act[1]}{second}") 26 | return 27 | 28 | if (act == "-close" or act == "-quit") and cmd[-4:] == "yazi": 29 | window.write_to_child(f"\x1b[99;5u") 30 | return 31 | 32 | def split(direction): 33 | if direction == "top" or direction == "bottom": 34 | boss.launch("--cwd=current", "--location=hsplit") 35 | else: 36 | boss.launch("--cwd=current", "--location=vsplit") 37 | 38 | if direction == "top" or direction == "left": 39 | boss.active_tab.move_window(direction) 40 | 41 | def close(): 42 | boss.close_window() 43 | 44 | def quit(): 45 | boss.quit() 46 | 47 | def jump(direction): 48 | boss.active_tab.neighboring_window(direction) 49 | 50 | # https://github.com/chancez/dotfiles/blob/master/kitty/.config/kitty/relative_resize.py 51 | def resize(direction): 52 | neighbors = boss.active_tab.current_layout.neighbors_for_window( 53 | window, boss.active_tab.windows 54 | ) 55 | top, bottom = neighbors.get("top"), neighbors.get("bottom") 56 | left, right = neighbors.get("left"), neighbors.get("right") 57 | 58 | if direction == "top": 59 | if top and bottom: 60 | boss.active_tab.resize_window("shorter", 10) 61 | elif top: 62 | boss.active_tab.resize_window("taller", 10) 63 | elif bottom: 64 | boss.active_tab.resize_window("shorter", 10) 65 | elif direction == "bottom": 66 | if top and bottom: 67 | boss.active_tab.resize_window("taller", 10) 68 | elif top: 69 | boss.active_tab.resize_window("shorter", 10) 70 | elif bottom: 71 | boss.active_tab.resize_window("taller", 10) 72 | elif direction == "left": 73 | if left and right: 74 | boss.active_tab.resize_window("narrower", 10) 75 | elif left: 76 | boss.active_tab.resize_window("wider", 10) 77 | elif right: 78 | boss.active_tab.resize_window("narrower", 10) 79 | elif direction == "right": 80 | if left and right: 81 | boss.active_tab.resize_window("wider", 10) 82 | elif left: 83 | boss.active_tab.resize_window("narrower", 10) 84 | elif right: 85 | boss.active_tab.resize_window("wider", 10) 86 | 87 | def move(direction): 88 | boss.active_tab.move_window(direction) 89 | 90 | act = act[1:] 91 | if act == "split": 92 | split(args[2]) 93 | elif act == "close": 94 | close() 95 | elif act == "quit": 96 | quit() 97 | elif act == "jump": 98 | jump(args[2]) 99 | elif act == "resize": 100 | resize(args[2]) 101 | elif act == "move": 102 | move(args[2]) 103 | -------------------------------------------------------------------------------- /nvim/lua/keymap.lua: -------------------------------------------------------------------------------- 1 | -- leader key 2 | vim.g.mapleader = " " 3 | vim.g.maplocalleader = "," 4 | vim.keymap.set("", "<Space>", "<Nop>") 5 | 6 | -- special keys 7 | vim.keymap.set({ "n", "v" }, ";", ":") 8 | vim.keymap.set("", "<Tab>", "<Nop>") -- Will be handled in `plugins/completion.lua` 9 | 10 | -- reserved keys 11 | vim.keymap.set("", "s", "<Nop>") 12 | vim.keymap.set("", "S", "<Nop>") 13 | vim.keymap.set("", "o", "<Nop>") 14 | vim.keymap.set("", "O", "<Nop>") 15 | 16 | -- up, down, left, right 17 | vim.keymap.set("", "u", "k") 18 | vim.keymap.set("", "U", "5k") 19 | vim.keymap.set("", "e", "j") 20 | vim.keymap.set("", "E", "5j") 21 | vim.keymap.set("", "n", "h") 22 | vim.keymap.set("", "N", "^") 23 | vim.keymap.set("", "i", "l", { nowait = true }) 24 | vim.keymap.set("", "I", "$") 25 | 26 | vim.keymap.set("n", "<C-u>", 'line(".")>1 ? ":m .-2<CR>" : ""', { expr = true, silent = true }) 27 | vim.keymap.set("n", "<C-e>", 'line(".")<line("$") ? ":m .+1<CR>" : ""', { expr = true, silent = true }) 28 | vim.keymap.set("v", "<C-u>", 'line(".")>1 ? ":m \'<-2<CR>gv" : ""', { expr = true, silent = true }) 29 | vim.keymap.set("v", "<C-e>", 'line(".")<line("$") ? ":m \'>+1<CR>gv" : ""', { expr = true, silent = true }) 30 | 31 | vim.keymap.set("c", "<C-u>", "<Up>") 32 | vim.keymap.set("c", "<C-e>", "<Down>") 33 | 34 | -- word navigation keys 35 | vim.keymap.set("", "h", "e") 36 | vim.keymap.set("", "H", "E") 37 | 38 | -- insert mode keys 39 | vim.keymap.set("n", "k", function() return #vim.fn.getline(".") == 0 and '"_cc' or "i" end, { expr = true }) 40 | vim.keymap.set("v", "k", "i") 41 | vim.keymap.set("v", "K", "I") 42 | vim.keymap.set("", "m", "o") 43 | vim.keymap.set("", "M", "O") 44 | 45 | vim.keymap.set("n", "<C-n>", "I") 46 | vim.keymap.set("i", "<C-n>", "<Esc>I") 47 | vim.keymap.set("n", "<C-i>", "A") 48 | vim.keymap.set("i", "<C-i>", "<Esc>A") 49 | 50 | -- redo, undo 51 | vim.keymap.set("n", "l", "u") 52 | vim.keymap.set("n", "L", "<C-r>") 53 | 54 | -- yank, paste 55 | vim.keymap.set("x", "p", '"_dP') 56 | vim.keymap.set("x", "P", '"_dp') 57 | 58 | vim.keymap.set({ "n", "v" }, "x", '"_x') 59 | 60 | vim.keymap.set("n", "dw", 'vb"_d') 61 | vim.keymap.set("n", "cw", 'vb"_c') 62 | 63 | -- search keys 64 | vim.keymap.set("n", "-", "'Nn'[v:searchforward]", { expr = true }) 65 | vim.keymap.set("x", "-", "'Nn'[v:searchforward]", { expr = true }) 66 | vim.keymap.set("o", "-", "'Nn'[v:searchforward]", { expr = true }) 67 | vim.keymap.set("n", "=", "'nN'[v:searchforward]", { expr = true }) 68 | vim.keymap.set("x", "=", "'nN'[v:searchforward]", { expr = true }) 69 | vim.keymap.set("o", "=", "'nN'[v:searchforward]", { expr = true }) 70 | 71 | vim.keymap.set("v", "-", function() require("utils").search(false) end) 72 | vim.keymap.set("v", "=", function() require("utils").search(true) end) 73 | 74 | -- tab management 75 | vim.keymap.set({ "n", "v" }, "tt", ":tabe<CR>", { silent = true }) 76 | vim.keymap.set({ "n", "v" }, "tT", ":tab split<CR>", { silent = true }) 77 | vim.keymap.set({ "n", "v" }, "tn", ":-tabnext<CR>", { silent = true }) 78 | vim.keymap.set({ "n", "v" }, "ti", ":+tabnext<CR>", { silent = true }) 79 | vim.keymap.set({ "n", "v" }, "tN", ":-tabmove<CR>", { silent = true }) 80 | vim.keymap.set({ "n", "v" }, "tI", ":+tabmove<CR>", { silent = true }) 81 | 82 | -- other keys 83 | vim.keymap.set("n", "<C-S-M-s>", ":up<CR>", { silent = true }) 84 | vim.keymap.set("i", "<C-S-M-s>", "<Esc>:up<CR>a", { silent = true }) 85 | vim.keymap.set("v", "<C-S-M-s>", "<Esc>:up<CR>", { silent = true }) 86 | 87 | vim.keymap.set("", "<C-a>", "ggVG$") 88 | vim.keymap.set({ "i", "v" }, "<C-a>", "<Esc>ggVG$") 89 | 90 | vim.keymap.set("", "<C-r>", ":filetype detect<CR>", { silent = true }) 91 | vim.keymap.set("i", "<C-r>", "<Esc>:filetype detect<CR>a", { silent = true }) 92 | 93 | vim.keymap.set("", "<C-->", "<C-a>") 94 | vim.keymap.set({ "i", "v" }, "<C-->", "<Esc><C-a>a") 95 | vim.keymap.set("", "<C-=>", "<C-x>") 96 | vim.keymap.set({ "i", "v" }, "<C-=>", "<Esc><C-x>a") 97 | 98 | vim.keymap.set("n", "<leader>`", function() require("lazy").profile() end) 99 | -------------------------------------------------------------------------------- /nvim/lua/plugins/parser.lua: -------------------------------------------------------------------------------- 1 | local M = { 2 | ts_langs = { 3 | -- https://github.com/nvim-treesitter/nvim-treesitter#supported-languages 4 | "bash", 5 | "c", 6 | "cmake", 7 | "comment", 8 | "cpp", 9 | "css", 10 | "dart", 11 | "diff", 12 | "dockerfile", 13 | "fish", 14 | "git_rebase", 15 | "gitattributes", 16 | "gitcommit", 17 | "gitignore", 18 | "go", 19 | "gomod", 20 | "gosum", 21 | "gowork", 22 | "graphql", 23 | "html", 24 | "ini", 25 | "java", 26 | "javascript", 27 | "json", 28 | "json5", 29 | "jsonc", 30 | "kdl", 31 | "latex", 32 | "lua", 33 | "luap", 34 | "make", 35 | "markdown", 36 | "markdown_inline", 37 | "nix", 38 | "php", 39 | "pug", 40 | "python", 41 | "regex", 42 | "ruby", 43 | "ron", 44 | "rust", 45 | "scss", 46 | "smali", 47 | "sql", 48 | "svelte", 49 | "swift", 50 | "toml", 51 | "tsx", 52 | "typescript", 53 | "vim", 54 | "vue", 55 | "yaml", 56 | "zig", 57 | }, 58 | } 59 | 60 | return { 61 | { 62 | "nvim-treesitter/nvim-treesitter", 63 | dependencies = { 64 | "windwp/nvim-ts-autotag", 65 | "nvim-treesitter/nvim-treesitter-textobjects", 66 | }, 67 | build = ":TSUpdate", 68 | event = { "BufReadPre", "BufNewFile" }, 69 | config = function() 70 | require("nvim-treesitter.configs").setup { 71 | ensure_installed = M.ts_langs, 72 | highlight = { 73 | enable = true, 74 | disable = function(lang, bufnr) return vim.api.nvim_buf_line_count(bufnr) > 5000 end, 75 | }, 76 | incremental_selection = { 77 | enable = true, 78 | keymaps = { 79 | init_selection = "<CR>", 80 | node_incremental = "<CR>", 81 | node_decremental = "<S-CR>", 82 | scope_incremental = false, 83 | }, 84 | }, 85 | indent = { enable = true }, 86 | autotag = { enable = true }, 87 | textobjects = { 88 | move = { 89 | enable = true, 90 | set_jumps = true, 91 | goto_next_end = { 92 | ["]a"] = "@parameter.outer", 93 | ["]f"] = "@function.outer", 94 | ["]c"] = "@class.outer", 95 | }, 96 | goto_previous_end = { 97 | ["[A"] = "@parameter.outer", 98 | ["[F"] = "@function.outer", 99 | ["[C"] = "@class.outer", 100 | }, 101 | goto_previous_start = { 102 | ["[a"] = "@parameter.outer", 103 | ["[f"] = "@function.outer", 104 | ["[c"] = "@class.outer", 105 | }, 106 | goto_next_start = { 107 | ["]A"] = "@parameter.outer", 108 | ["]F"] = "@function.outer", 109 | ["]C"] = "@class.outer", 110 | }, 111 | }, 112 | select = { 113 | enable = true, 114 | lookahead = true, 115 | keymaps = { 116 | -- https://github.com/nvim-treesitter/nvim-treesitter-textobjects/blob/master/scripts/minimal_init.lua#L41 117 | ["af"] = "@function.outer", 118 | ["kf"] = "@function.inner", 119 | ["ab"] = "@block.outer", 120 | ["kb"] = "@block.inner", 121 | ["aa"] = "@parameter.outer", 122 | ["ka"] = "@parameter.inner", 123 | ["ac"] = "@comment.outer", 124 | }, 125 | include_surrounding_whitespace = true, 126 | }, 127 | }, 128 | } 129 | end, 130 | }, 131 | 132 | { 133 | "nvim-treesitter/nvim-treesitter-context", 134 | dependencies = { "nvim-treesitter/nvim-treesitter" }, 135 | event = { "BufReadPost", "BufNewFile" }, 136 | config = true, 137 | }, 138 | 139 | { 140 | "HiPhish/rainbow-delimiters.nvim", 141 | dependencies = { "nvim-treesitter/nvim-treesitter" }, 142 | event = { "BufReadPost", "BufNewFile" }, 143 | config = function() 144 | local rainbow = require("rainbow-delimiters") 145 | 146 | vim.g.rainbow_delimiters = { 147 | query = { 148 | [""] = "rainbow-delimiters", 149 | lua = "rainbow-blocks", 150 | html = "rainbow-tags", 151 | javascript = "rainbow-delimiters-react", 152 | }, 153 | strategy = { 154 | [""] = rainbow.strategy["global"], 155 | vim = rainbow.strategy["local"], 156 | }, 157 | } 158 | end, 159 | }, 160 | } 161 | -------------------------------------------------------------------------------- /mpv/shaders/Anime4K_Denoise_Bilateral_Mode.glsl: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019-2021 bloc97 4 | // All rights reserved. 5 | 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | 24 | //!DESC Anime4K-v3.2-Denoise-Bilateral-Mode-Luma 25 | //!HOOK MAIN 26 | //!BIND HOOKED 27 | //!SAVE LINELUMA 28 | //!COMPONENTS 1 29 | 30 | float get_luma(vec4 rgba) { 31 | return dot(vec4(0.299, 0.587, 0.114, 0.0), rgba); 32 | } 33 | 34 | vec4 hook() { 35 | return vec4(get_luma(HOOKED_tex(HOOKED_pos)), 0.0, 0.0, 0.0); 36 | } 37 | 38 | //!DESC Anime4K-v3.1-Denoise-Bilateral-Mode-Apply 39 | //!HOOK MAIN 40 | //!BIND HOOKED 41 | //!BIND LINELUMA 42 | 43 | #define INTENSITY_SIGMA 0.1 //Intensity window size, higher is stronger denoise, must be a positive real number 44 | #define SPATIAL_SIGMA 1.0 //Spatial window size, higher is stronger denoise, must be a positive real number. 45 | #define HISTOGRAM_REGULARIZATION 0.2 //Histogram regularization window size, higher values approximate a bilateral "closest-to-mean" filter. 46 | 47 | #define INTENSITY_POWER_CURVE 1.0 //Intensity window power curve. Setting it to 0 will make the intensity window treat all intensities equally, while increasing it will make the window narrower in darker intensities and wider in brighter intensities. 48 | 49 | #define KERNELSIZE int(max(int(SPATIAL_SIGMA), 1) * 2 + 1) //Kernel size, must be an positive odd integer. 50 | #define KERNELHALFSIZE (int(KERNELSIZE/2)) //Half of the kernel size without remainder. Must be equal to trunc(KERNELSIZE/2). 51 | #define KERNELLEN (KERNELSIZE * KERNELSIZE) //Total area of kernel. Must be equal to KERNELSIZE * KERNELSIZE. 52 | 53 | #define GETOFFSET(i) vec2((i % KERNELSIZE) - KERNELHALFSIZE, (i / KERNELSIZE) - KERNELHALFSIZE) 54 | 55 | float gaussian(float x, float s, float m) { 56 | float scaled = (x - m) / s; 57 | return exp(-0.5 * scaled * scaled); 58 | } 59 | 60 | vec4 getMode(vec4 v[KERNELLEN], float w[KERNELLEN]) { 61 | vec4 maxv = vec4(0); 62 | float maxw = 0.0; 63 | 64 | for (int i=0; i<KERNELLEN; i++) { 65 | if (w[i] >= maxw) { 66 | maxw = w[i]; 67 | maxv = v[i]; 68 | } 69 | } 70 | 71 | return maxv; 72 | } 73 | 74 | vec4 hook() { 75 | vec4 histogram_v[KERNELLEN]; 76 | float histogram_l[KERNELLEN]; 77 | float histogram_w[KERNELLEN]; 78 | float histogram_wn[KERNELLEN]; 79 | 80 | float vc = LINELUMA_tex(HOOKED_pos).x; 81 | 82 | float is = pow(vc + 0.0001, INTENSITY_POWER_CURVE) * INTENSITY_SIGMA; 83 | float ss = SPATIAL_SIGMA; 84 | 85 | for (int i=0; i<KERNELLEN; i++) { 86 | vec2 ipos = GETOFFSET(i); 87 | histogram_v[i] = HOOKED_texOff(ipos); 88 | histogram_l[i] = LINELUMA_texOff(ipos).x; 89 | histogram_w[i] = gaussian(histogram_l[i], is, vc) * gaussian(length(ipos), ss, 0.0); 90 | histogram_wn[i] = 0.0; 91 | } 92 | 93 | for (int i=0; i<KERNELLEN; i++) { 94 | histogram_wn[i] += gaussian(0.0, HISTOGRAM_REGULARIZATION, 0.0) * histogram_w[i]; 95 | for (int j=(i+1); j<KERNELLEN; j++) { 96 | float d = gaussian(histogram_l[j], HISTOGRAM_REGULARIZATION, histogram_l[i]); 97 | histogram_wn[j] += d * histogram_w[i]; 98 | histogram_wn[i] += d * histogram_w[j]; 99 | } 100 | } 101 | 102 | return getMode(histogram_v, histogram_wn); 103 | } -------------------------------------------------------------------------------- /mpv/input.conf: -------------------------------------------------------------------------------- 1 | # Mouse 2 | MBTN_LEFT ignore 3 | MBTN_LEFT_DBL cycle fullscreen 4 | MBTN_RIGHT cycle pause 5 | MBTN_BACK playlist-prev 6 | MBTN_FORWARD playlist-next 7 | 8 | # Special keys 9 | ESC {encode} quit 4 10 | SPACE cycle pause 11 | ENTER cycle fullscreen 12 | CLOSE_WIN quit 13 | CLOSE_WIN {encode} quit 4 14 | 15 | # Arrow keys 16 | u add volume 2 17 | e add volume -2 18 | n no-osd seek -3 exact 19 | i no-osd seek 3 exact 20 | 21 | # Seeking 22 | Meta+n no-osd sub-seek -1 23 | Meta+i no-osd sub-seek 1 24 | Shift+n seek -10 25 | Shift+i seek 10 26 | , frame-back-step 27 | . frame-step 28 | 29 | # Speed 30 | [ multiply speed 1/1.1 31 | ] multiply speed 1.1 32 | { multiply speed 0.5 33 | } multiply speed 2.0 34 | BS set speed 1.0 35 | Shift+BS set speed 0.26 36 | 37 | # Subtitle 38 | Meta+u cycle sub 39 | Meta+e cycle sub down 40 | Shift+u add sub-pos -5 41 | Shift+e add sub-pos +5 42 | Ctrl+- add sub-scale +0.1 43 | Ctrl+= add sub-scale -0.1 44 | 45 | # Playlist 46 | < playlist-prev 47 | > playlist-next 48 | 49 | # Delay 50 | Ctrl+u add sub-delay -0.1 51 | Ctrl+e add sub-delay +0.1 52 | Ctrl+Shift+u add sub-delay -1 53 | Ctrl+Shift+e add sub-delay +1 54 | Ctrl+n add audio-delay 0.100 55 | Ctrl+i add audio-delay -0.100 56 | 57 | # Panning / Zooming 58 | Meta+Shift+u add video-pan-y 0.1 59 | Meta+Shift+e add video-pan-y -0.1 60 | Meta+Shift+n add video-pan-x 0.1 61 | Meta+Shift+i add video-pan-x -0.1 62 | Meta+- add video-zoom -0.1 63 | Meta+= add video-zoom 0.1 64 | Meta+BS set video-zoom 0; set video-pan-x 0; set video-pan-y 0 65 | 66 | # Misc 67 | ` script-binding console/enable 68 | m cycle mute 69 | v script-binding stats/display-stats-toggle 70 | t cycle ontop 71 | a cycle-values video-aspect-override "16:9" "4:3" "2.35:1" "-1" 72 | 73 | s cycle sub-visibility 74 | S cycle secondary-sub-visibility 75 | r cycle video 76 | R cycle audio 77 | c screenshot video 78 | C screenshot 79 | l ab-loop 80 | L cycle-values loop-file "inf" "no" 81 | 82 | Meta+1 set current-window-scale 0.5 83 | Meta+2 set current-window-scale 1.0 84 | 85 | 1 add contrast 1 86 | ! add contrast -1 87 | 2 add brightness 1 88 | @ add brightness -1 89 | 3 add gamma 1 90 | SHARP add gamma -1 91 | 4 add saturation 1 92 | $ add saturation -1 93 | 94 | # Filter 95 | Ctrl+1 no-osd change-list glsl-shaders set "~~/shaders/Anime4K_Clamp_Highlights.glsl:~~/shaders/Anime4K_Restore_CNN_M.glsl:~~/shaders/Anime4K_Upscale_CNN_x2_M.glsl:~~/shaders/Anime4K_AutoDownscalePre_x2.glsl:~~/shaders/Anime4K_AutoDownscalePre_x4.glsl:~~/shaders/Anime4K_Upscale_CNN_x2_S.glsl"; show-text "Anime4K: Mode A (Fast)" 96 | Ctrl+! no-osd change-list glsl-shaders set "~~/shaders/Anime4K_Clamp_Highlights.glsl:~~/shaders/Anime4K_Restore_CNN_M.glsl:~~/shaders/Anime4K_Upscale_CNN_x2_M.glsl:~~/shaders/Anime4K_Restore_CNN_S.glsl:~~/shaders/Anime4K_AutoDownscalePre_x2.glsl:~~/shaders/Anime4K_AutoDownscalePre_x4.glsl:~~/shaders/Anime4K_Upscale_CNN_x2_S.glsl"; show-text "Anime4K: Mode A+A (Fast)" 97 | Ctrl+2 no-osd change-list glsl-shaders set "~~/shaders/Anime4K_Clamp_Highlights.glsl:~~/shaders/Anime4K_Restore_CNN_Soft_M.glsl:~~/shaders/Anime4K_Upscale_CNN_x2_M.glsl:~~/shaders/Anime4K_AutoDownscalePre_x2.glsl:~~/shaders/Anime4K_AutoDownscalePre_x4.glsl:~~/shaders/Anime4K_Upscale_CNN_x2_S.glsl"; show-text "Anime4K: Mode B (Fast)" 98 | Ctrl+@ no-osd change-list glsl-shaders set "~~/shaders/Anime4K_Clamp_Highlights.glsl:~~/shaders/Anime4K_Restore_CNN_Soft_M.glsl:~~/shaders/Anime4K_Upscale_CNN_x2_M.glsl:~~/shaders/Anime4K_AutoDownscalePre_x2.glsl:~~/shaders/Anime4K_AutoDownscalePre_x4.glsl:~~/shaders/Anime4K_Restore_CNN_Soft_S.glsl:~~/shaders/Anime4K_Upscale_CNN_x2_S.glsl"; show-text "Anime4K: Mode B+B (Fast)" 99 | Ctrl+3 no-osd change-list glsl-shaders set "~~/shaders/Anime4K_Clamp_Highlights.glsl:~~/shaders/Anime4K_Upscale_Denoise_CNN_x2_M.glsl:~~/shaders/Anime4K_AutoDownscalePre_x2.glsl:~~/shaders/Anime4K_AutoDownscalePre_x4.glsl:~~/shaders/Anime4K_Upscale_CNN_x2_S.glsl"; show-text "Anime4K: Mode C (Fast)" 100 | Ctrl+# no-osd change-list glsl-shaders set "~~/shaders/Anime4K_Clamp_Highlights.glsl:~~/shaders/Anime4K_Upscale_Denoise_CNN_x2_M.glsl:~~/shaders/Anime4K_AutoDownscalePre_x2.glsl:~~/shaders/Anime4K_AutoDownscalePre_x4.glsl:~~/shaders/Anime4K_Restore_CNN_S.glsl:~~/shaders/Anime4K_Upscale_CNN_x2_S.glsl"; show-text "Anime4K: Mode C+A (Fast)" 101 | Ctrl+0 no-osd change-list glsl-shaders clr ""; show-text "GLSL shaders cleared" 102 | 103 | -------------------------------------------------------------------------------- /mpv/shaders/Anime4K_Upscale_DoG_x2.glsl: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019-2021 bloc97 4 | // All rights reserved. 5 | 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | 24 | //!DESC Anime4K-v3.2-Upscale-DoG-x2-Luma 25 | //!HOOK MAIN 26 | //!BIND HOOKED 27 | //!SAVE LINELUMA 28 | //!COMPONENTS 1 29 | 30 | float get_luma(vec4 rgba) { 31 | return dot(vec4(0.299, 0.587, 0.114, 0.0), rgba); 32 | } 33 | 34 | vec4 hook() { 35 | return vec4(get_luma(HOOKED_tex(HOOKED_pos)), 0.0, 0.0, 0.0); 36 | } 37 | 38 | //!DESC Anime4K-v3.2-Upscale-DoG-x2-Kernel-X 39 | //!WHEN OUTPUT.w MAIN.w / 1.200 > OUTPUT.h MAIN.h / 1.200 > * 40 | //!HOOK MAIN 41 | //!BIND HOOKED 42 | //!BIND LINELUMA 43 | //!SAVE GAUSS_X2 44 | //!COMPONENTS 3 45 | 46 | #define L_tex LINELUMA_tex 47 | 48 | float max3v(float a, float b, float c) { 49 | return max(max(a, b), c); 50 | } 51 | float min3v(float a, float b, float c) { 52 | return min(min(a, b), c); 53 | } 54 | 55 | vec2 minmax3(vec2 pos, vec2 d) { 56 | float a = L_tex(pos - d).x; 57 | float b = L_tex(pos).x; 58 | float c = L_tex(pos + d).x; 59 | 60 | return vec2(min3v(a, b, c), max3v(a, b, c)); 61 | } 62 | 63 | float lumGaussian7(vec2 pos, vec2 d) { 64 | float g = (L_tex(pos - (d + d)).x + L_tex(pos + (d + d)).x) * 0.06136; 65 | g = g + (L_tex(pos - d).x + L_tex(pos + d).x) * 0.24477; 66 | g = g + (L_tex(pos).x) * 0.38774; 67 | 68 | return g; 69 | } 70 | 71 | 72 | vec4 hook() { 73 | return vec4(lumGaussian7(HOOKED_pos, vec2(HOOKED_pt.x, 0)), minmax3(HOOKED_pos, vec2(HOOKED_pt.x, 0)), 0); 74 | } 75 | 76 | 77 | //!DESC Anime4K-v3.2-Upscale-DoG-x2-Kernel-Y 78 | //!WHEN OUTPUT.w MAIN.w / 1.200 > OUTPUT.h MAIN.h / 1.200 > * 79 | //!HOOK MAIN 80 | //!BIND HOOKED 81 | //!BIND GAUSS_X2 82 | //!SAVE GAUSS_X2 83 | //!COMPONENTS 3 84 | 85 | #define L_tex GAUSS_X2_tex 86 | 87 | float max3v(float a, float b, float c) { 88 | return max(max(a, b), c); 89 | } 90 | float min3v(float a, float b, float c) { 91 | return min(min(a, b), c); 92 | } 93 | 94 | vec2 minmax3(vec2 pos, vec2 d) { 95 | float a0 = L_tex(pos - d).y; 96 | float b0 = L_tex(pos).y; 97 | float c0 = L_tex(pos + d).y; 98 | 99 | float a1 = L_tex(pos - d).z; 100 | float b1 = L_tex(pos).z; 101 | float c1 = L_tex(pos + d).z; 102 | 103 | return vec2(min3v(a0, b0, c0), max3v(a1, b1, c1)); 104 | } 105 | 106 | float lumGaussian7(vec2 pos, vec2 d) { 107 | float g = (L_tex(pos - (d + d)).x + L_tex(pos + (d + d)).x) * 0.06136; 108 | g = g + (L_tex(pos - d).x + L_tex(pos + d).x) * 0.24477; 109 | g = g + (L_tex(pos).x) * 0.38774; 110 | 111 | return g; 112 | } 113 | 114 | 115 | vec4 hook() { 116 | return vec4(lumGaussian7(HOOKED_pos, vec2(0, HOOKED_pt.y)), minmax3(HOOKED_pos, vec2(0, HOOKED_pt.y)), 0); 117 | } 118 | 119 | //!DESC Anime4K-v3.2-Upscale-DoG-x2-Apply 120 | //!WHEN OUTPUT.w MAIN.w / 1.200 > OUTPUT.h MAIN.h / 1.200 > * 121 | //!HOOK MAIN 122 | //!BIND HOOKED 123 | //!BIND LINELUMA 124 | //!BIND GAUSS_X2 125 | //!WIDTH MAIN.w 2 * 126 | //!HEIGHT MAIN.h 2 * 127 | 128 | #define STRENGTH 0.8 //De-blur proportional strength, higher is sharper. 129 | 130 | #define L_tex LINELUMA_tex 131 | 132 | vec4 hook() { 133 | 134 | float c = (L_tex(HOOKED_pos).x - GAUSS_X2_tex(HOOKED_pos).x) * STRENGTH; 135 | float cc = clamp(c + L_tex(HOOKED_pos).x, GAUSS_X2_tex(HOOKED_pos).y, GAUSS_X2_tex(HOOKED_pos).z) - L_tex(HOOKED_pos).x; 136 | 137 | //This trick is only possible if the inverse Y->RGB matrix has 1 for every row... (which is the case for BT.709) 138 | //Otherwise we would need to convert RGB to YUV, modify Y then convert back to RGB. 139 | return HOOKED_tex(HOOKED_pos) + cc; 140 | } 141 | 142 | 143 | 144 | -------------------------------------------------------------------------------- /mpv/shaders/Anime4K_Denoise_Bilateral_Median.glsl: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019-2021 bloc97 4 | // All rights reserved. 5 | 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | 24 | //!DESC Anime4K-v3.2-Denoise-Bilateral-Median-Luma 25 | //!HOOK MAIN 26 | //!BIND HOOKED 27 | //!SAVE LINELUMA 28 | //!COMPONENTS 1 29 | 30 | float get_luma(vec4 rgba) { 31 | return dot(vec4(0.299, 0.587, 0.114, 0.0), rgba); 32 | } 33 | 34 | vec4 hook() { 35 | return vec4(get_luma(HOOKED_tex(HOOKED_pos)), 0.0, 0.0, 0.0); 36 | } 37 | 38 | //!DESC Anime4K-v3.2-Denoise-Bilateral-Median-Apply 39 | //!HOOK MAIN 40 | //!BIND HOOKED 41 | //!BIND LINELUMA 42 | 43 | #define INTENSITY_SIGMA 0.1 //Intensity window size, higher is stronger denoise, must be a positive real number 44 | #define SPATIAL_SIGMA 1.0 //Spatial window size, higher is stronger denoise, must be a positive real number. 45 | #define HISTOGRAM_REGULARIZATION 0.0 //Histogram regularization window size, higher values approximate a bilateral "closest-to-mean" filter. 46 | 47 | #define INTENSITY_POWER_CURVE 1.0 //Intensity window power curve. Setting it to 0 will make the intensity window treat all intensities equally, while increasing it will make the window narrower in darker intensities and wider in brighter intensities. 48 | 49 | #define KERNELSIZE int(max(int(SPATIAL_SIGMA), 1) * 2 + 1) //Kernel size, must be an positive odd integer. 50 | #define KERNELHALFSIZE (int(KERNELSIZE/2)) //Half of the kernel size without remainder. Must be equal to trunc(KERNELSIZE/2). 51 | #define KERNELLEN (KERNELSIZE * KERNELSIZE) //Total area of kernel. Must be equal to KERNELSIZE * KERNELSIZE. 52 | 53 | #define GETOFFSET(i) vec2((i % KERNELSIZE) - KERNELHALFSIZE, (i / KERNELSIZE) - KERNELHALFSIZE) 54 | 55 | float gaussian(float x, float s, float m) { 56 | float scaled = (x - m) / s; 57 | return exp(-0.5 * scaled * scaled); 58 | } 59 | 60 | vec4 getMedian(vec4 v[KERNELLEN], float w[KERNELLEN], float n) { 61 | 62 | for (int i=0; i<KERNELLEN; i++) { 63 | float w_above = 0.0; 64 | float w_below = 0.0; 65 | for (int j=0; j<KERNELLEN; j++) { 66 | if (v[j].x > v[i].x) { 67 | w_above += w[j]; 68 | } else if (v[j].x < v[i].x) { 69 | w_below += w[j]; 70 | } 71 | } 72 | 73 | if ((n - w_above) / n >= 0.5 && w_below / n <= 0.5) { 74 | return v[i]; 75 | } 76 | } 77 | } 78 | 79 | vec4 hook() { 80 | vec4 histogram_v[KERNELLEN]; 81 | float histogram_l[KERNELLEN]; 82 | float histogram_w[KERNELLEN]; 83 | float n = 0.0; 84 | 85 | float vc = LINELUMA_tex(HOOKED_pos).x; 86 | 87 | float is = pow(vc + 0.0001, INTENSITY_POWER_CURVE) * INTENSITY_SIGMA; 88 | float ss = SPATIAL_SIGMA; 89 | 90 | for (int i=0; i<KERNELLEN; i++) { 91 | vec2 ipos = GETOFFSET(i); 92 | histogram_v[i] = HOOKED_texOff(ipos); 93 | histogram_l[i] = LINELUMA_texOff(ipos).x; 94 | histogram_w[i] = gaussian(histogram_l[i], is, vc) * gaussian(length(ipos), ss, 0.0); 95 | n += histogram_w[i]; 96 | } 97 | 98 | if (HISTOGRAM_REGULARIZATION > 0.0) { 99 | float histogram_wn[KERNELLEN]; 100 | n = 0.0; 101 | 102 | for (int i=0; i<KERNELLEN; i++) { 103 | histogram_wn[i] = 0.0; 104 | } 105 | 106 | for (int i=0; i<KERNELLEN; i++) { 107 | histogram_wn[i] += gaussian(0.0, HISTOGRAM_REGULARIZATION, 0.0) * histogram_w[i]; 108 | for (int j=(i+1); j<KERNELLEN; j++) { 109 | float d = gaussian(histogram_l[j], HISTOGRAM_REGULARIZATION, histogram_l[i]); 110 | histogram_wn[j] += d * histogram_w[i]; 111 | histogram_wn[i] += d * histogram_w[j]; 112 | } 113 | n += histogram_wn[i]; 114 | } 115 | 116 | return getMedian(histogram_v, histogram_wn, n); 117 | } 118 | 119 | return getMedian(histogram_v, histogram_w, n); 120 | } -------------------------------------------------------------------------------- /rules/eslint/plugins/json.js: -------------------------------------------------------------------------------- 1 | import jsonSchemaPlugin, { configs as jsonSchemaConfigs } from "eslint-plugin-json-schema-validator" 2 | import jsoncPlugin, { configs as jsoncConfigs } from "eslint-plugin-jsonc" 3 | import jsoncParser from "jsonc-eslint-parser" 4 | 5 | import { fmRules } from "./formatting.js" 6 | 7 | export const jsoncRules = { 8 | // https://ota-meshi.github.io/eslint-plugin-jsonc/rules/#jsonc-rules 9 | "jsonc/no-binary-expression" : "warn", 10 | "jsonc/no-binary-numeric-literals" : "warn", 11 | "jsonc/no-escape-sequence-in-identifier": "warn", 12 | "jsonc/no-hexadecimal-numeric-literals" : "warn", 13 | "jsonc/no-number-props" : "warn", 14 | "jsonc/no-numeric-separators" : "warn", 15 | "jsonc/no-octal-numeric-literals" : "warn", 16 | "jsonc/no-parenthesized" : "warn", 17 | "jsonc/no-plus-sign" : "warn", 18 | "jsonc/no-template-literals" : "warn", 19 | "jsonc/no-unicode-codepoint-escapes" : "warn", 20 | "jsonc/valid-json-number" : "warn", 21 | 22 | // https://ota-meshi.github.io/eslint-plugin-jsonc/rules/#extension-rules 23 | "jsonc/array-bracket-newline" : fmRules["array-bracket-newline"], 24 | "jsonc/array-bracket-spacing" : fmRules["array-bracket-spacing"], 25 | "jsonc/array-element-newline" : fmRules["array-element-newline"], 26 | "jsonc/comma-dangle" : ["warn", "never"], 27 | "jsonc/comma-style" : fmRules["comma-style"], 28 | "jsonc/indent" : fmRules.indent, 29 | "jsonc/key-spacing" : fmRules["key-spacing"], 30 | "jsonc/no-floating-decimal" : fmRules["no-floating-decimal"], 31 | "jsonc/object-curly-newline" : fmRules["object-curly-newline"], 32 | "jsonc/object-curly-spacing" : fmRules["object-curly-spacing"], 33 | "jsonc/object-property-newline": fmRules["object-property-newline"], 34 | "jsonc/quote-props" : "warn", 35 | "jsonc/quotes" : fmRules.quotes, 36 | "jsonc/space-unary-ops" : fmRules["space-unary-ops"], 37 | } 38 | 39 | /** @type { import('eslint').Linter.FlatConfig[] } */ 40 | export const json = [ 41 | { 42 | files : ["**/*.{json,jsonc}"], 43 | languageOptions: { parser: jsoncParser }, 44 | plugins : { 45 | "jsonc" : jsoncPlugin, 46 | "json-schema-validator": jsonSchemaPlugin, 47 | }, 48 | rules: { 49 | // eslint-plugin-jsonc 50 | ...jsoncConfigs["recommended-with-jsonc"].rules, 51 | ...jsoncRules, 52 | 53 | // eslint-plugin-json-schema-validator 54 | ...jsonSchemaConfigs.recommended.rules, 55 | }, 56 | }, 57 | { 58 | files : ["**/*.json5"], 59 | languageOptions: { parser: jsoncParser }, 60 | plugins : { 61 | "jsonc" : jsoncPlugin, 62 | "json-schema-validator": jsonSchemaPlugin, 63 | }, 64 | rules: { 65 | // eslint-plugin-jsonc 66 | ...jsoncConfigs["recommended-with-json5"].rules, 67 | ...jsoncRules, 68 | 69 | "jsonc/no-hexadecimal-numeric-literals": "off", 70 | "jsonc/no-plus-sign" : "off", 71 | "jsonc/valid-json-number" : "off", 72 | 73 | "jsonc/comma-dangle": fmRules["comma-dangle"], 74 | "jsonc/quote-props" : fmRules["quote-props"], 75 | 76 | // eslint-plugin-json-schema-validator 77 | ...jsonSchemaConfigs.recommended.rules, 78 | }, 79 | }, 80 | { 81 | files: ["package.json"], 82 | rules: { 83 | "jsonc/sort-keys": [ 84 | "warn", 85 | { 86 | pathPattern: "^$", 87 | order : [ 88 | "name", 89 | "type", 90 | "version", 91 | "scripts", 92 | "engines", 93 | "packageManager", 94 | 95 | "bin", 96 | "main", 97 | "module", 98 | "browser", 99 | "exports", 100 | 101 | "private", 102 | "author", 103 | "repository", 104 | "homepage", 105 | "bugs", 106 | "funding", 107 | "license", 108 | "description", 109 | "keywords", 110 | "publishConfig", 111 | 112 | "dependencies", 113 | "devDependencies", 114 | "peerDependencies", 115 | "peerDependenciesMeta", 116 | "bundledDependencies", 117 | "optionalDependencies", 118 | ], 119 | }, 120 | { 121 | pathPattern: "^scripts.*$", 122 | order : [ 123 | { keyPattern: "^pre:.*$" }, 124 | { keyPattern: "^dev.*$" }, 125 | { keyPattern: "^build.*$" }, 126 | { keyPattern: "^generate.*$" }, 127 | { keyPattern: "^preview.*$" }, 128 | { keyPattern: "^test.*$" }, 129 | { keyPattern: "^lint.*$" }, 130 | { keyPattern: "^release.*$" }, 131 | ], 132 | }, 133 | { 134 | pathPattern: "^exports.*$", 135 | order : ["import", "require", "types"], 136 | }, 137 | { 138 | pathPattern: "^(dev|peer|bundled|optional)?[Dd]ependencies$", 139 | order : { type: "asc" }, 140 | }, 141 | ], 142 | "jsonc/key-spacing": ["warn", {}], 143 | }, 144 | }, 145 | ] 146 | 147 | -------------------------------------------------------------------------------- /mpv/scripts/seek-to.lua: -------------------------------------------------------------------------------- 1 | local assdraw = require 'mp.assdraw' 2 | local active = false 3 | local cursor_position = 1 4 | local time_scale = {60*60*10, 60*60, 60*10, 60, 10, 1, 0.1, 0.01, 0.001} 5 | 6 | local ass_begin = mp.get_property("osd-ass-cc/0") 7 | local ass_end = mp.get_property("osd-ass-cc/1") 8 | 9 | local history = { {} } 10 | for i = 1, 9 do 11 | history[1][i] = 0 12 | end 13 | local history_position = 1 14 | 15 | -- timer to redraw periodically the message 16 | -- to avoid leaving bindings when the seeker disappears for whatever reason 17 | -- pretty hacky tbh 18 | local timer = nil 19 | local timer_duration = 3 20 | 21 | function show_seeker() 22 | local prepend_char = {'','',':','',':','','.','',''} 23 | local str = '' 24 | for i = 1, 9 do 25 | str = str .. prepend_char[i] 26 | if i == cursor_position then 27 | str = str .. '{\\b1}' .. history[history_position][i] .. '{\\r}' 28 | else 29 | str = str .. history[history_position][i] 30 | end 31 | end 32 | mp.osd_message("Seek to: " .. ass_begin .. str .. ass_end, timer_duration) 33 | end 34 | 35 | function copy_history_to_last() 36 | if history_position ~= #history then 37 | for i = 1, 9 do 38 | history[#history][i] = history[history_position][i] 39 | end 40 | history_position = #history 41 | end 42 | end 43 | 44 | function change_number(i) 45 | -- can't set above 60 minutes or seconds 46 | if (cursor_position == 3 or cursor_position == 5) and i >= 6 then 47 | return 48 | end 49 | if history[history_position][cursor_position] ~= i then 50 | copy_history_to_last() 51 | history[#history][cursor_position] = i 52 | end 53 | shift_cursor(false) 54 | end 55 | 56 | function shift_cursor(left) 57 | if left then 58 | cursor_position = math.max(1, cursor_position - 1) 59 | else 60 | cursor_position = math.min(cursor_position + 1, 9) 61 | end 62 | end 63 | 64 | function current_time_as_sec(time) 65 | local sec = 0 66 | for i = 1, 9 do 67 | sec = sec + time_scale[i] * time[i] 68 | end 69 | return sec 70 | end 71 | 72 | function time_equal(lhs, rhs) 73 | for i = 1, 9 do 74 | if lhs[i] ~= rhs[i] then 75 | return false 76 | end 77 | end 78 | return true 79 | end 80 | 81 | function seek_to() 82 | copy_history_to_last() 83 | mp.commandv("osd-bar", "seek", current_time_as_sec(history[history_position]), "absolute") 84 | --deduplicate consecutive timestamps 85 | if #history == 1 or not time_equal(history[history_position], history[#history - 1]) then 86 | history[#history + 1] = {} 87 | history_position = #history 88 | end 89 | for i = 1, 9 do 90 | history[#history][i] = 0 91 | end 92 | end 93 | 94 | function backspace() 95 | if cursor_position ~= 9 or current_time[9] == 0 then 96 | shift_cursor(true) 97 | end 98 | if history[history_position][cursor_position] ~= 0 then 99 | copy_history_to_last() 100 | history[#history][cursor_position] = 0 101 | end 102 | end 103 | 104 | function history_move(up) 105 | if up then 106 | history_position = math.max(1, history_position - 1) 107 | else 108 | history_position = math.min(history_position + 1, #history) 109 | end 110 | end 111 | 112 | local key_mappings = { 113 | LEFT = function() shift_cursor(true) show_seeker() end, 114 | RIGHT = function() shift_cursor(false) show_seeker() end, 115 | UP = function() history_move(true) show_seeker() end, 116 | DOWN = function() history_move(false) show_seeker() end, 117 | BS = function() backspace() show_seeker() end, 118 | ESC = function() set_inactive() end, 119 | ENTER = function() seek_to() set_inactive() end 120 | } 121 | for i = 0, 9 do 122 | local func = function() change_number(i) show_seeker() end 123 | key_mappings[string.format("KP%d", i)] = func 124 | key_mappings[string.format("%d", i)] = func 125 | end 126 | 127 | function set_active() 128 | if not mp.get_property("seekable") then return end 129 | -- find duration of the video and set cursor position accordingly 130 | local duration = mp.get_property_number("duration") 131 | if duration ~= nil then 132 | for i = 1, 9 do 133 | if duration > time_scale[i] then 134 | cursor_position = i 135 | break 136 | end 137 | end 138 | end 139 | for key, func in pairs(key_mappings) do 140 | mp.add_forced_key_binding(key, "seek-to-"..key, func) 141 | end 142 | show_seeker() 143 | timer = mp.add_periodic_timer(timer_duration, show_seeker) 144 | active = true 145 | end 146 | 147 | function set_inactive() 148 | mp.osd_message("") 149 | for key, _ in pairs(key_mappings) do 150 | mp.remove_key_binding("seek-to-"..key) 151 | end 152 | timer:kill() 153 | active = false 154 | end 155 | 156 | mp.add_key_binding(nil, "toggle-seeker", function() if active then set_inactive() else set_active() end end) 157 | 158 | -------------------------------------------------------------------------------- /nix/darwin/software.nix: -------------------------------------------------------------------------------- 1 | { pkgs, ... }: 2 | 3 | let 4 | base = { 5 | cmake = "nix"; 6 | zsh = "nix"; 7 | less = "nix"; 8 | gnused = "nix"; 9 | wget = "nix"; 10 | }; 11 | 12 | cli = { 13 | eza = "nix"; 14 | bat = "nix"; 15 | zoxide = "nix"; 16 | fd = "nix"; 17 | fzf = "nix"; 18 | ripgrep = "nix"; 19 | du-dust = "nix"; 20 | tldr = "nix"; 21 | tig = "nix"; 22 | btop = "nix"; 23 | tree = "nix"; 24 | tmux = "nix"; 25 | starship = "nix"; 26 | hyperfine = "nix"; 27 | 28 | # Neovim 29 | neovim = "nix"; 30 | tree-sitter = "nix"; 31 | 32 | # Network 33 | nali = "nix"; 34 | aria = "nix"; 35 | dogdns = "nix"; 36 | httpie = "nix"; 37 | nmap = "nix"; 38 | telnet = "brew"; 39 | 40 | # Archive 41 | unar = "nix"; 42 | sevenzip = "brew"; 43 | brotli = "nix"; 44 | upx = "nix"; 45 | rar = "nix"; 46 | 47 | # Graphic 48 | ffmpeg = "nix"; 49 | graphviz = "nix"; 50 | exiftool = "nix"; 51 | ffmpegthumbnailer = "nix"; 52 | 53 | # JSON 54 | jless = "nix"; 55 | jq = "nix"; 56 | jc = "nix"; 57 | 58 | # Writting 59 | hugo = "nix"; 60 | 61 | # macOS 62 | duti = "nix"; 63 | }; 64 | 65 | utility = { 66 | adguard = "cask"; 67 | alfred = "cask"; 68 | "1password" = "cask"; 69 | squirrel = "cask"; 70 | bettermouse = "cask"; 71 | maczip = "cask"; 72 | downie = "cask"; 73 | aerial = "cask"; 74 | 75 | # Terminal 76 | kitty = "nix"; 77 | iterm2 = "nix"; 78 | 79 | # Browser 80 | google-chrome = "cask"; 81 | # google-chrome-canary = "cask"; 82 | firefox = "cask"; 83 | microsoft-edge = "cask"; 84 | 85 | # Filesync 86 | OneDrive = 823766827; 87 | "Transmit 5" = 1436522307; 88 | }; 89 | 90 | gui = { 91 | # Development 92 | vscode = "nix"; 93 | fork = "cask"; 94 | postman = "nix"; 95 | coderunner = "cask"; 96 | dash = "cask"; 97 | orbstack = "cask"; 98 | imhex = "cask"; 99 | wireshark = "nix"; 100 | proxyman = "cask"; 101 | another-redis-desktop-manager = "cask"; 102 | "Microsoft Remote Desktop" = 1295203466; 103 | "Cleaner for Xcode" = 1296084683; 104 | 105 | # Database 106 | "jetbrains.datagrip" = "nix"; 107 | "Sequel Ace" = 1518036000; 108 | 109 | # Social 110 | Telegram = 747648890; 111 | discord = "nix"; 112 | element-desktop = "nix"; 113 | WeChat = 836500024; 114 | 115 | # Movie 116 | mpv-unwrapped = "nix"; 117 | iina = "nix"; 118 | spotify = "nix"; 119 | 120 | # Screen recording 121 | shottr = "cask"; 122 | kap = "cask"; 123 | screenflow = "cask"; 124 | obs = "cask"; 125 | 126 | # Writting 127 | notion = "cask"; 128 | obsidian = "nix"; 129 | raindropio = "cask"; 130 | "Reeder 5" = 1529448980; 131 | 132 | # Design 133 | sip = "cask"; 134 | "OmniGraffle 7" = 1142578753; 135 | # "Affinity Photo" = 824183456; 136 | 137 | # Others 138 | "TickTick" = 966085870; 139 | "Text Scanner" = 1452523807; 140 | } // { 141 | # Development 142 | ## "altair-graphql-client" 143 | ## charles = "nix"; 144 | ## paw = "cask"; 145 | 146 | # Database 147 | ## "Navicat Premium 16" = 1594061654; 148 | 149 | # Social 150 | ## lark = "cask"; 151 | ## "QQ" = 451108668; 152 | ## "DingTalk" = 1435447041; 153 | 154 | # Writting 155 | ## calibre = "cask"; 156 | 157 | # Others 158 | ## parallels = "cask"; 159 | ## "Dynamic Wallpaper Engine" = 1453504509; 160 | }; 161 | 162 | languages = { 163 | # Nix 164 | nixpkgs-fmt = "nix"; 165 | 166 | # Golang 167 | go = "nix"; 168 | 169 | # Node.js 170 | nodejs = "nix"; 171 | "nodePackages.pnpm" = "nix"; 172 | bun = "nix"; 173 | 174 | # Rust 175 | "rust-bin.nightly.latest.minimal" = "nix"; 176 | 177 | # Python 178 | python3 = "nix"; 179 | 180 | # Lua 181 | lua = "nix"; 182 | luarocks = "nix"; 183 | 184 | # PHP 185 | php82 = "nix"; 186 | "php82Packages.composer" = "nix"; 187 | "php82Packages.psysh" = "nix"; 188 | }; 189 | 190 | fonts = { 191 | font-sf-mono = "cask"; 192 | font-fira-code = "cask"; 193 | font-roboto-mono = "cask"; 194 | font-dejavu = "cask"; 195 | font-symbols-only-nerd-font = "cask"; 196 | sf-symbols = "cask"; 197 | }; 198 | 199 | external = { 200 | # Zsh plugins 201 | zsh-autosuggestions = "nix"; 202 | zsh-completions = "nix"; 203 | zsh-history-substring-search = "nix"; 204 | zsh-syntax-highlighting = "nix"; 205 | }; 206 | in 207 | 208 | with builtins; let 209 | all = base // cli // utility // gui // languages // fonts // external; 210 | grouped = groupBy 211 | (item: if typeOf all.${item} == "int" then "mas" else all.${item}) 212 | (attrNames all); 213 | grouped' = mapAttrs 214 | (group: items: map 215 | (item: { 216 | nix = foldl' (carry: key: carry.${key}) pkgs (filter isString (split "\\." item)); 217 | mas = { name = item; value = all.${item}; }; 218 | }.${group} or item) 219 | items 220 | ) 221 | grouped; 222 | in 223 | grouped' // { mas = builtins.listToAttrs grouped'.mas; } 224 | 225 | -------------------------------------------------------------------------------- /zsh/keymap.zsh: -------------------------------------------------------------------------------- 1 | # Widgets 2 | function vi-yank-wrapped { 3 | local last_key="$KEYS[-1]" 4 | local ori_buffer="$CUTBUFFER" 5 | 6 | zle vi-yank 7 | if [[ "$last_key" = "Y" ]] then 8 | echo -n "$CUTBUFFER" | pbcopy -i 9 | CUTBUFFER="$ori_buffer" 10 | fi 11 | } 12 | zle -N vi-yank-wrapped 13 | 14 | bindkey -s "^y" "y\n" 15 | 16 | # Menu 17 | bindkey -rpM menuselect "" 18 | bindkey -M menuselect "^I" complete-word 19 | bindkey -M menuselect "^[" send-break 20 | bindkey -M menuselect "^U" up-line-or-history 21 | bindkey -M menuselect "^E" down-line-or-history 22 | bindkey -M menuselect "^N" backward-char 23 | bindkey -M menuselect "^[[105;5u" forward-char # Ctrl+i in CSI u, configured in kitty.conf and tmux.conf both 24 | 25 | # Command 26 | bindkey -rpM command "" 27 | bindkey -M command "^[" send-break 28 | bindkey -M command "^M" accept-line 29 | 30 | # Normal mode 31 | bindkey -rpM vicmd "" 32 | bindkey -M vicmd "^W" backward-delete-word 33 | bindkey -M vicmd "^L" clear-screen 34 | bindkey -M vicmd "^M" accept-line 35 | bindkey -M vicmd "u" up-line 36 | bindkey -M vicmd "^U" history-substring-search-up 37 | bindkey -M vicmd "e" down-line 38 | bindkey -M vicmd "^E" history-substring-search-down 39 | bindkey -M vicmd "n" vi-backward-char 40 | bindkey -M vicmd "N" vi-first-non-blank 41 | bindkey -M vicmd "^N" vi-insert-bol 42 | bindkey -M vicmd "i" vi-forward-char 43 | bindkey -M vicmd "I" vi-end-of-line 44 | bindkey -M vicmd "^[[105;5u" vi-add-eol # Ctrl+i in CSI u, configured in kitty.conf and tmux.conf both 45 | bindkey -M vicmd "^[[44;5u" edit-command-line # Ctrl+, in CSI u, configured in kitty.conf and tmux.conf both 46 | 47 | bindkey -M vicmd "b" vi-backward-word 48 | bindkey -M vicmd "B" vi-backward-blank-word 49 | bindkey -M vicmd "h" vi-forward-word-end 50 | bindkey -M vicmd "H" vi-forward-blank-word-end 51 | bindkey -M vicmd "w" vi-forward-word 52 | bindkey -M vicmd "W" vi-forward-blank-word 53 | bindkey -M vicmd "a" vi-add-next 54 | bindkey -M vicmd "A" vi-add-eol 55 | bindkey -M vicmd "k" vi-insert 56 | bindkey -M vicmd "K" vi-insert-bol 57 | bindkey -M vicmd "m" vi-open-line-below 58 | bindkey -M vicmd "M" vi-open-line-above 59 | 60 | bindkey -M vicmd "d" vi-delete 61 | bindkey -M vicmd "D" vi-kill-eol 62 | bindkey -M vicmd "c" vi-change 63 | bindkey -M vicmd "C" vi-change-eol 64 | bindkey -M vicmd "x" vi-delete-char 65 | bindkey -M vicmd "X" vi-backward-delete-char 66 | bindkey -M vicmd "r" vi-replace-chars 67 | bindkey -M vicmd "R" vi-replace 68 | 69 | bindkey -M vicmd "y" vi-yank-wrapped 70 | bindkey -M vicmd "Y" vi-yank-wrapped 71 | bindkey -M vicmd "p" vi-put-after 72 | bindkey -M vicmd "P" vi-put-before 73 | 74 | bindkey -M vicmd "v" visual-mode 75 | bindkey -M vicmd "V" visual-line-mode 76 | bindkey -M vicmd "l" undo 77 | bindkey -M vicmd "L" redo 78 | 79 | # bindkey -M vicmd ";" execute-named-cmd 80 | bindkey -M vicmd "." vi-repeat-change 81 | bindkey -M vicmd "," edit-command-line 82 | bindkey -M vicmd "\-" vi-repeat-search 83 | bindkey -M vicmd "=" vi-rev-repeat-search 84 | 85 | bindkey -M vicmd "0"-"9" digit-argument 86 | bindkey -M vicmd "<" vi-unindent 87 | bindkey -M vicmd ">" vi-indent 88 | bindkey -M vicmd "J" vi-join 89 | 90 | bindkey -M vicmd "gu" vi-down-case 91 | bindkey -M vicmd "gU" vi-up-case 92 | bindkey -M vicmd "gs" vi-swap-case 93 | bindkey -M vicmd "ge" vi-backward-word-end 94 | bindkey -M vicmd "gE" vi-backward-blank-word-end 95 | bindkey -M vicmd "gg" beginning-of-buffer-or-history 96 | bindkey -M vicmd "fb" vi-match-bracket 97 | 98 | # Insert mode 99 | bindkey -M viins "^?" backward-delete-char # Backspace 100 | bindkey -M viins "^W" backward-delete-word 101 | bindkey -M viins "^U" history-substring-search-up 102 | bindkey -M viins "^E" history-substring-search-down 103 | bindkey -M viins "^N" vi-insert-bol 104 | bindkey -M viins "^[[105;5u" vi-add-eol # Ctrl+i in CSI u, configured in kitty.conf 105 | bindkey -M viins "^[[44;5u" edit-command-line # Ctrl+, in CSI u, configured in kitty.conf and tmux.conf both 106 | 107 | # Visual mode 108 | bindkey -rpM visual "" 109 | bindkey -M visual "^[" deactivate-region # Esc 110 | bindkey -M visual "u" up-line 111 | bindkey -M visual "^U" history-substring-search-up 112 | bindkey -M visual "e" down-line 113 | bindkey -M visual "^E" history-substring-search-down 114 | bindkey -M visual "aw" select-a-word 115 | bindkey -M visual "aW" select-a-blank-word 116 | bindkey -M visual "aa" select-a-shell-word 117 | bindkey -M visual "kw" select-in-word 118 | bindkey -M visual "kW" select-in-blank-word 119 | bindkey -M visual "kk" select-in-shell-word 120 | bindkey -M visual "x" vi-delete 121 | bindkey -M visual "p" put-replace-selection 122 | 123 | # Operator pending mode 124 | bindkey -rpM viopp "" 125 | bindkey -M viopp "^[" vi-cmd-mode 126 | bindkey -M viopp "u" up-line 127 | bindkey -M viopp "e" down-line 128 | bindkey -M viopp "aw" select-a-word 129 | bindkey -M viopp "aW" select-a-blank-word 130 | bindkey -M viopp "aa" select-a-shell-word 131 | bindkey -M viopp "kw" select-in-word 132 | bindkey -M viopp "kW" select-in-blank-word 133 | bindkey -M viopp "kk" select-in-shell-word 134 | 135 | -------------------------------------------------------------------------------- /tmux/tmux.conf: -------------------------------------------------------------------------------- 1 | # vim:fileencoding=utf-8:foldmethod=marker 2 | 3 | #: Reset {{{ 4 | 5 | unbind C-b 6 | unbind C-f 7 | unbind % 8 | unbind "'" 9 | unbind -T copy-mode-vi u 10 | unbind -T copy-mode-vi e 11 | unbind -T copy-mode-vi n 12 | unbind -T copy-mode-vi i 13 | 14 | #: }}} 15 | 16 | 17 | 18 | #: Global configs {{{ 19 | 20 | set -g default-shell /opt/homebrew/bin/zsh 21 | # Change the default $TERM to tmux-256color 22 | set -g default-terminal "tmux-256color" 23 | # Enable RGB colour if running in xterm(1) 24 | set -ga terminal-overrides ",xterm*:Tc" 25 | 26 | # Turn the mouse on, but without copy mode dragging 27 | set -g mouse on 28 | unbind -n MouseDrag1Pane 29 | unbind -Tcopy-mode MouseDrag1Pane 30 | 31 | # Address vim mode switching delay (http://superuser.com/a/252717/65504) 32 | set -sg escape-time 1 33 | 34 | # Enable the new keyboard protocol for Tmux, and applying to the applications inside it on demand 35 | set -s extended-keys on 36 | 37 | # Increase scrollback buffer size from 2000 to 50000 lines 38 | set -g history-limit 50000 39 | 40 | # No bells at all 41 | set -g bell-action none 42 | 43 | # Focus events enabled for terminals that support them 44 | set -g focus-events on 45 | 46 | #: }}} 47 | 48 | 49 | 50 | #: Global key bindings {{{ 51 | 52 | # Change the prefix key to C-Space 53 | set -g prefix C-Space 54 | bind C-Space send-prefix 55 | 56 | # Remap ; to : for convenience 57 | bind \; command-prompt 58 | 59 | # Use neovim key bindings 60 | set -g mode-keys vi 61 | set -g status-keys vi 62 | 63 | # Increase repeat time for repeatable commands 64 | set -g repeat-time 1000 65 | 66 | bind -n C-u if "test '#{pane_current_command}' = 'zsh'" "copy-mode; send -N 5 -X cursor-up" "send C-u" 67 | bind -n C-e if "test '#{pane_current_command}' = 'zsh'" "copy-mode; send -N 5 -X cursor-down" "send C-e" 68 | 69 | # A workround of Ctrl-i, since tmux has a bug that recognizes the Ctrl+i and Tab of CSI u as the same key 70 | # https://github.com/tmux/tmux/issues/2705 71 | bind -n C-\; "send Escape '[105;5u'" 72 | # Force to enable CSI u of Ctrl+, for all program, in the zsh it's handled as "edit current command via neovim" 73 | bind -n C-, "send Escape '[44;5u'" 74 | 75 | bind p paste-buffer # Paste 76 | bind C-p choose-buffer # Tmux clipboard history 77 | #bind "'" delete-buffer\; display "Clipboard history deleted" 78 | 79 | #: }}} 80 | 81 | 82 | 83 | #: Pane {{{ 84 | 85 | bind -r u select-pane -U 86 | bind -r e select-pane -D 87 | bind -r n select-pane -L 88 | bind -r i select-pane -R 89 | 90 | bind -r C-u resize-pane -U 5 91 | bind -r C-e resize-pane -D 5 92 | bind -r C-n resize-pane -L 5 93 | bind -r C-i resize-pane -R 5 94 | 95 | bind -r N swap-pane -d -t -1 96 | bind -r I swap-pane -d -t +1 97 | 98 | bind -r x kill-pane 99 | 100 | #: }}} 101 | 102 | 103 | 104 | #: Window {{{ 105 | 106 | # Highlight window when it has new activity 107 | setw -g monitor-activity on 108 | set -g visual-activity on 109 | 110 | # Start window/pane index at 1 111 | set -g base-index 1 112 | set -g pane-base-index 1 113 | # Re-number windows when one is closed 114 | set -g renumber-windows on 115 | 116 | bind n new-window -c "#{pane_current_path}" 117 | bind r command-prompt "rename-window %%" 118 | bind C-x kill-window 119 | 120 | bind -r [ previous-window 121 | bind -r ] next-window 122 | bind -r C-[ swap-window -d -t -1 123 | bind -r C-] swap-window -d -t +1 124 | 125 | bind -r - split-window -h -c "#{pane_current_path}" 126 | bind -r = split-window -v -c "#{pane_current_path}" 127 | 128 | #: }}} 129 | 130 | 131 | 132 | #: Session {{{ 133 | 134 | bind R command-prompt "rename-session %%" 135 | bind q confirm-before -p "kill-session #S? (y/n)" kill-session 136 | 137 | #: }}} 138 | 139 | 140 | 141 | # : Vim mode {{{ 142 | 143 | bind Escape copy-mode 144 | 145 | bind -T copy-mode-vi u send -X cursor-up 146 | bind -T copy-mode-vi U send -N 5 -X cursor-up 147 | bind -T copy-mode-vi e send -X cursor-down 148 | bind -T copy-mode-vi E send -N 5 -X cursor-down 149 | bind -T copy-mode-vi n send -X cursor-left 150 | bind -T copy-mode-vi N send -X start-of-line 151 | bind -T copy-mode-vi i send -X cursor-right 152 | bind -T copy-mode-vi I send -X end-of-line 153 | 154 | bind -T copy-mode-vi v send -X begin-selection 155 | #bind -T copy-mode-vi y send -X copy-pipe-and-cancel "reattach-to-user-namespace pbcopy" 156 | 157 | #: }}} 158 | 159 | 160 | 161 | #: Status {{{ 162 | 163 | # If running inside tmux ($TMUX is set), then change the status line to red 164 | %if #{TMUX} 165 | set status-bg red 166 | %endif 167 | 168 | # Refresh `status-left` and `status-right` more often, from every 15s to 5s 169 | set -g status-interval 5 170 | 171 | #: }}} 172 | 173 | 174 | 175 | #: Plugins {{{ 176 | 177 | set -g @plugin "tmux-plugins/tpm" 178 | set -g @plugin "dracula/tmux" 179 | set -g @plugin 'tmux-plugins/tmux-yank' 180 | set -g @plugin 'tmux-plugins/tmux-open' 181 | 182 | TMUX_FZF_LAUNCH_KEY="f" 183 | set -g @plugin 'sainnhe/tmux-fzf' 184 | 185 | set -g @resurrect-strategy-nvim 'session' 186 | set -g @resurrect-capture-pane-contents 'on' 187 | set -g @plugin 'tmux-plugins/tmux-resurrect' 188 | set -g @plugin 'tmux-plugins/tmux-continuum' 189 | 190 | # Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf) 191 | run "~/.config/tmux/plugins/tpm/tpm" 192 | 193 | #: }}} 194 | -------------------------------------------------------------------------------- /kitty/kitty.conf: -------------------------------------------------------------------------------- 1 | # vim:fileencoding=utf-8:foldmethod=marker 2 | 3 | #: Fonts {{{ 4 | font_family SF Mono 5 | # font_family Monaco 6 | # font_family Fira Code 7 | # font_family Cascadia Code 8 | font_size 18.0 9 | modify_font cell_width -1px 10 | modify_font cell_height 10px 11 | modify_font underline_position 5 12 | modify_font strikethrough_position 5 13 | modify_font cell_height 130% 14 | 15 | #: }}} 16 | 17 | 18 | #: Color scheme {{{ 19 | 20 | # include themes/dracula.conf 21 | include themes/catppuccin/macchiato.conf 22 | 23 | background_opacity 0.9 24 | background_blur 20 25 | 26 | window_padding_width 4 27 | 28 | #: }}} 29 | 30 | 31 | #: Cursor {{{ 32 | 33 | cursor none 34 | cursor_blink_interval -1 ease-in-out 35 | 36 | # cursor_trail 1 37 | # cursor_trail_decay 0.1 0.2 38 | # cursor_trail_start_threshold 10 39 | 40 | #: }}} 41 | 42 | 43 | #: Scrollback {{{ 44 | 45 | scrollback_lines -1 46 | 47 | scrollback_fill_enlarged_window yes 48 | 49 | #: }}} 50 | 51 | 52 | #: Mouse {{{ 53 | 54 | # url_color #0087bd 55 | # url_style curly 56 | 57 | url_prefixes file ftp ftps git http https mailto sftp ssh 58 | 59 | strip_trailing_spaces always 60 | 61 | select_by_word_characters @-./_~?&=%+# 62 | 63 | #: }}} 64 | 65 | 66 | #: Performance tuning {{{ 67 | 68 | input_delay 0 69 | 70 | sync_to_monitor no 71 | 72 | #: }}} 73 | 74 | 75 | #: Window layout {{{ 76 | 77 | remember_window_size no 78 | initial_window_width 1080 79 | initial_window_height 720 80 | 81 | enabled_layouts splits, stack 82 | 83 | #: }}} 84 | 85 | 86 | #: Tab bar {{{ 87 | 88 | tab_bar_style powerline 89 | 90 | tab_powerline_style round 91 | 92 | #: }}} 93 | 94 | 95 | #: Advanced {{{ 96 | 97 | allow_remote_control socket-only 98 | listen_on unix:/tmp/kitty_term 99 | remote_control_password "" kitten 100 | 101 | #: }}} 102 | 103 | 104 | #: OS specific tweaks {{{ 105 | 106 | macos_option_as_alt yes 107 | 108 | macos_quit_when_last_window_closed yes 109 | 110 | macos_show_window_title_in window 111 | 112 | macos_colorspace displayp3 113 | 114 | text_composition_strategy 1.2 20 115 | 116 | #: }}} 117 | 118 | 119 | #: Keyboard shortcuts {{{ 120 | 121 | clear_all_shortcuts yes 122 | 123 | #: Special key {{{ 124 | 125 | map ctrl+i kitten keymap.py "C-i" 126 | 127 | # Edit current command via neovim, specific to zsh 128 | map ctrl+, send_text normal,application \x1b[44;5u 129 | 130 | #: }}} 131 | 132 | #: Clipboard {{{ 133 | 134 | map cmd+c copy_to_clipboard 135 | map cmd+v paste_from_clipboard 136 | map cmd+shift+v paste_from_selection 137 | 138 | #: }}} 139 | 140 | #: Scrolling {{{ 141 | 142 | map alt+u combine : scroll_line_up : scroll_line_up : scroll_line_up : scroll_line_up : scroll_line_up 143 | map alt+e combine : scroll_line_down : scroll_line_down : scroll_line_down : scroll_line_down : scroll_line_down 144 | 145 | map cmd+/ scroll_to_prompt -1 146 | map cmd+shift+/ scroll_to_prompt 1 147 | 148 | map cmd+alt+/ show_last_command_output 149 | 150 | #: }}} 151 | 152 | #: Window management {{{ 153 | 154 | map cmd+ctrl+u kitten window.py +split top 155 | map cmd+ctrl+e kitten window.py +split bottom 156 | map cmd+ctrl+n kitten window.py +split left 157 | map cmd+ctrl+i kitten window.py +split right 158 | map cmd+w kitten window.py -close 159 | 160 | map cmd+u kitten window.py -jump top 161 | map cmd+e kitten window.py -jump bottom 162 | map cmd+n kitten window.py -jump left 163 | map cmd+i kitten window.py -jump right 164 | map cmd+shift+u kitten window.py -resize top 165 | map cmd+shift+e kitten window.py -resize bottom 166 | map cmd+shift+n kitten window.py -resize left 167 | map cmd+shift+i kitten window.py -resize right 168 | map cmd+alt+u kitten window.py -move top 169 | map cmd+alt+e kitten window.py -move bottom 170 | map cmd+alt+n kitten window.py -move left 171 | map cmd+alt+i kitten window.py -move right 172 | 173 | map cmd+enter toggle_layout stack 174 | 175 | #: }}} 176 | 177 | #: Tab management {{{ 178 | 179 | map cmd+t new_tab 180 | map cmd+shift+w close_tab 181 | map cmd+shift+k set_tab_title 182 | 183 | map cmd+[ previous_tab 184 | map cmd+] next_tab 185 | map cmd+alt+[ move_tab_forward 186 | map cmd+alt+] move_tab_backward 187 | 188 | map cmd+1 goto_tab 1 189 | map cmd+2 goto_tab 2 190 | map cmd+3 goto_tab 3 191 | map cmd+4 goto_tab 4 192 | map cmd+5 goto_tab 5 193 | map cmd+6 goto_tab 6 194 | 195 | #: }}} 196 | 197 | #: Font sizes {{{ 198 | 199 | map cmd+equal change_font_size all +1.0 200 | map cmd+minus change_font_size all -1.0 201 | map cmd+0 change_font_size all 0 202 | 203 | #: }}} 204 | 205 | #: Select and act on visible text {{{ 206 | 207 | map cmd+o open_url_with_hints 208 | map cmd+q kitten window.py -quit 209 | map cmd+l kitten hints --type line --program - 210 | map cmd+p kitten hints --type path --program - 211 | map cmd+shift+p kitten hints --type path 212 | 213 | #: }}} 214 | 215 | #: Miscellaneous {{{ 216 | 217 | map cmd+backspace send_text all \u17 218 | map cmd+s kitten keymap.py "S-s" 219 | map cmd+r clear_terminal to_cursor active 220 | map cmd+f combine : show_scrollback : send_text normal,application / 221 | map cmd+shift+f toggle_maximized 222 | 223 | #: }}} 224 | 225 | #: }}} 226 | -------------------------------------------------------------------------------- /nvim/lazy-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "FixCursorHold.nvim": { "branch": "master", "commit": "1900f89dc17c603eec29960f57c00bd9ae696495" }, 3 | "LuaSnip": { "branch": "master", "commit": "b3104910bb5ebf40492aadffae18f2528fa757d9" }, 4 | "SchemaStore.nvim": { "branch": "main", "commit": "8ebf58bd467f353d18cfa71776b33b28a68130de" }, 5 | "catppuccin": { "branch": "main", "commit": "30fa4d122d9b22ad8b2e0ab1b533c8c26c4dde86" }, 6 | "cmp-buffer": { "branch": "main", "commit": "b74fab3656eea9de20a9b8116afa3cfc4ec09657" }, 7 | "cmp-cmdline": { "branch": "main", "commit": "d126061b624e0af6c3a556428712dd4d4194ec6d" }, 8 | "cmp-nvim-lsp": { "branch": "main", "commit": "bd5a7d6db125d4654b50eeae9f5217f24bb22fd3" }, 9 | "cmp-path": { "branch": "main", "commit": "c642487086dbd9a93160e1679a1327be111cbc25" }, 10 | "cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" }, 11 | "conform.nvim": { "branch": "master", "commit": "b4aab989db276993ea5dcb78872be494ce546521" }, 12 | "copilot.lua": { "branch": "master", "commit": "f7732213e41995439171f35bdd2bf1c809f8e8e7" }, 13 | "cspell.nvim": { "branch": "main", "commit": "07d75238648ef99c0c5c05f4cfd83093d0a01dd4" }, 14 | "dressing.nvim": { "branch": "master", "commit": "2d7c2db2507fa3c4956142ee607431ddb2828639" }, 15 | "friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" }, 16 | "gitlinker.nvim": { "branch": "master", "commit": "cc59f732f3d043b626c8702cb725c82e54d35c25" }, 17 | "gitsigns.nvim": { "branch": "main", "commit": "f780609807eca1f783a36a8a31c30a48fbe150c5" }, 18 | "grug-far.nvim": { "branch": "main", "commit": "50d9ee2b5a19634670441948e7e4afaa042f1059" }, 19 | "inc-rename.nvim": { "branch": "main", "commit": "8ae25b35ae16ca4bd5de3d3c472eec3b574018d4" }, 20 | "lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" }, 21 | "lualine.nvim": { "branch": "master", "commit": "b8c23159c0161f4b89196f74ee3a6d02cdc3a955" }, 22 | "mason-tool-installer.nvim": { "branch": "main", "commit": "517ef5994ef9d6b738322664d5fdd948f0fdeb46" }, 23 | "mason.nvim": { "branch": "main", "commit": "7dc4facca9702f95353d5a1f87daf23d78e31c2a" }, 24 | "mini.comment": { "branch": "main", "commit": "a9474da9175b27a5c32ee712433c23b9b0f7f139" }, 25 | "neotest": { "branch": "master", "commit": "2cf3544fb55cdd428a9a1b7154aea9c9823426e8" }, 26 | "neotest-plenary": { "branch": "master", "commit": "3523adcf9ffaad1911960c5813b0136c1b63a2ec" }, 27 | "neotest-rust": { "branch": "main", "commit": "2c9941d4a358839918fac21d20fc8fef0e1ad05f" }, 28 | "noice.nvim": { "branch": "main", "commit": "0427460c2d7f673ad60eb02b35f5e9926cf67c59" }, 29 | "none-ls.nvim": { "branch": "main", "commit": "78111a97cebed3dfda8157af8141bf1915cfc327" }, 30 | "nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" }, 31 | "nvim-autopairs": { "branch": "master", "commit": "23320e75953ac82e559c610bec5a90d9c6dfa743" }, 32 | "nvim-cmp": { "branch": "main", "commit": "b5311ab3ed9c846b585c0c15b7559be131ec4be9" }, 33 | "nvim-lint": { "branch": "master", "commit": "0864f81c681e15d9bdc1156fe3a17bd07db5a3ed" }, 34 | "nvim-lspconfig": { "branch": "master", "commit": "1f7fbc34e6420476142b5cc85e9bee52717540fb" }, 35 | "nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" }, 36 | "nvim-notify": { "branch": "master", "commit": "8701bece920b38ea289b457f902e2ad184131a5d" }, 37 | "nvim-surround": { "branch": "main", "commit": "a868c256c861044beb9794b4dd126480dcdfbdad" }, 38 | "nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" }, 39 | "nvim-treesitter-context": { "branch": "master", "commit": "41847d3dafb5004464708a3db06b14f12bde548a" }, 40 | "nvim-treesitter-textobjects": { "branch": "master", "commit": "71385f191ec06ffc60e80e6b0c9a9d5daed4824c" }, 41 | "nvim-ts-autotag": { "branch": "main", "commit": "c4ca798ab95b316a768d51eaaaee48f64a4a46bc" }, 42 | "nvim-ts-context-commentstring": { "branch": "main", "commit": "1b212c2eee76d787bbea6aa5e92a2b534e7b4f8f" }, 43 | "nvim-web-devicons": { "branch": "master", "commit": "6e51ca170563330e063720449c21f43e27ca0bc1" }, 44 | "plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" }, 45 | "rainbow-delimiters.nvim": { "branch": "master", "commit": "687ef75fdbd497eabc9eea92b52e7b4d403b3319" }, 46 | "smart-open.nvim": { "branch": "main", "commit": "f079c3201a0a62b1582563bd5ce4256c253634d4" }, 47 | "sort.nvim": { "branch": "main", "commit": "bb92140e1b96d62339bd5ab5b6df1eecca0d5da6" }, 48 | "sqlite.lua": { "branch": "master", "commit": "50092d60feb242602d7578398c6eb53b4a8ffe7b" }, 49 | "telescope-fzy-native.nvim": { "branch": "master", "commit": "282f069504515eec762ab6d6c89903377252bf5b" }, 50 | "telescope.nvim": { "branch": "master", "commit": "b4da76be54691e854d3e0e02c36b0245f945c2c7" }, 51 | "tokyonight.nvim": { "branch": "main", "commit": "057ef5d260c1931f1dffd0f052c685dcd14100a3" }, 52 | "treesj": { "branch": "main", "commit": "4770492244ccecdc9b01e0e81fa8f2f6b4a23841" }, 53 | "trouble.nvim": { "branch": "main", "commit": "3fb3bd737be8866e5f3a170abc70b4da8b5dd45a" }, 54 | "vim-illuminate": { "branch": "master", "commit": "0d1e93684da00ab7c057410fecfc24f434698898" }, 55 | "vim-visual-multi": { "branch": "master", "commit": "a6975e7c1ee157615bbc80fc25e4392f71c344d4" }, 56 | "yazi.nvim": { "branch": "main", "commit": "acd50311d83e0332dad4a2c172de00359b647d6a" } 57 | } 58 | -------------------------------------------------------------------------------- /mpv/shaders/Anime4K_Deblur_DoG.glsl: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019-2021 bloc97 4 | // All rights reserved. 5 | 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | 24 | //!DESC Anime4K-v3.2-Deblur-DoG-(HQ)-Luma 25 | //!HOOK MAIN 26 | //!BIND HOOKED 27 | //!SAVE LINELUMA 28 | //!COMPONENTS 1 29 | 30 | float get_luma(vec4 rgba) { 31 | return dot(vec4(0.299, 0.587, 0.114, 0.0), rgba); 32 | } 33 | 34 | vec4 hook() { 35 | return vec4(get_luma(HOOKED_tex(HOOKED_pos)), 0.0, 0.0, 0.0); 36 | } 37 | 38 | //!DESC Anime4K-v3.2-Deblur-DoG-Kernel-X 39 | //!HOOK MAIN 40 | //!BIND HOOKED 41 | //!BIND LINELUMA 42 | //!SAVE MMKERNEL 43 | //!COMPONENTS 3 44 | 45 | #define L_tex LINELUMA_tex 46 | 47 | float max3v(float a, float b, float c) { 48 | return max(max(a, b), c); 49 | } 50 | float min3v(float a, float b, float c) { 51 | return min(min(a, b), c); 52 | } 53 | 54 | vec2 minmax3(vec2 pos, vec2 d) { 55 | float a = L_tex(pos - d).x; 56 | float b = L_tex(pos).x; 57 | float c = L_tex(pos + d).x; 58 | 59 | return vec2(min3v(a, b, c), max3v(a, b, c)); 60 | } 61 | 62 | float lumGaussian7(vec2 pos, vec2 d) { 63 | float g = (L_tex(pos - (d + d)).x + L_tex(pos + (d + d)).x) * 0.06136; 64 | g = g + (L_tex(pos - d).x + L_tex(pos + d).x) * 0.24477; 65 | g = g + (L_tex(pos).x) * 0.38774; 66 | 67 | return g; 68 | } 69 | 70 | 71 | vec4 hook() { 72 | return vec4(lumGaussian7(HOOKED_pos, vec2(HOOKED_pt.x, 0.0)), minmax3(HOOKED_pos, vec2(HOOKED_pt.x, 0.0)), 0.0); 73 | } 74 | 75 | 76 | //!DESC Anime4K-v3.2-Deblur-DoG-Kernel-Y 77 | //!HOOK MAIN 78 | //!BIND HOOKED 79 | //!BIND MMKERNEL 80 | //!SAVE MMKERNEL 81 | //!COMPONENTS 3 82 | 83 | #define L_tex MMKERNEL_tex 84 | 85 | float max3v(float a, float b, float c) { 86 | return max(max(a, b), c); 87 | } 88 | float min3v(float a, float b, float c) { 89 | return min(min(a, b), c); 90 | } 91 | 92 | vec2 minmax3(vec2 pos, vec2 d) { 93 | float a0 = L_tex(pos - d).y; 94 | float b0 = L_tex(pos).y; 95 | float c0 = L_tex(pos + d).y; 96 | 97 | float a1 = L_tex(pos - d).z; 98 | float b1 = L_tex(pos).z; 99 | float c1 = L_tex(pos + d).z; 100 | 101 | return vec2(min3v(a0, b0, c0), max3v(a1, b1, c1)); 102 | } 103 | 104 | float lumGaussian7(vec2 pos, vec2 d) { 105 | float g = (L_tex(pos - (d + d)).x + L_tex(pos + (d + d)).x) * 0.06136; 106 | g = g + (L_tex(pos - d).x + L_tex(pos + d).x) * 0.24477; 107 | g = g + (L_tex(pos).x) * 0.38774; 108 | 109 | return g; 110 | } 111 | 112 | 113 | vec4 hook() { 114 | return vec4(lumGaussian7(HOOKED_pos, vec2(0.0, HOOKED_pt.y)), minmax3(HOOKED_pos, vec2(0.0, HOOKED_pt.y)), 0.0); 115 | } 116 | 117 | //!DESC Anime4K-v3.2-Deblur-DoG-Apply 118 | //!HOOK MAIN 119 | //!BIND HOOKED 120 | //!BIND LINELUMA 121 | //!BIND MMKERNEL 122 | 123 | #define STRENGTH 0.6 //De-blur proportional strength, higher is sharper. However, it is better to tweak BLUR_CURVE instead to avoid ringing. 124 | #define BLUR_CURVE 0.6 //De-blur power curve, lower is sharper. Good values are between 0.3 - 1. Values greater than 1 softens the image; 125 | #define BLUR_THRESHOLD 0.1 //Value where curve kicks in, used to not de-blur already sharp edges. Only de-blur values that fall below this threshold. 126 | #define NOISE_THRESHOLD 0.001 //Value where curve stops, used to not sharpen noise. Only de-blur values that fall above this threshold. 127 | 128 | #define L_tex LINELUMA_tex 129 | 130 | vec4 hook() { 131 | float c = (L_tex(HOOKED_pos).x - MMKERNEL_tex(HOOKED_pos).x) * STRENGTH; 132 | 133 | float t_range = BLUR_THRESHOLD - NOISE_THRESHOLD; 134 | 135 | float c_t = abs(c); 136 | if (c_t > NOISE_THRESHOLD) { 137 | c_t = (c_t - NOISE_THRESHOLD) / t_range; 138 | c_t = pow(c_t, BLUR_CURVE); 139 | c_t = c_t * t_range + NOISE_THRESHOLD; 140 | c_t = c_t * sign(c); 141 | } else { 142 | c_t = c; 143 | } 144 | 145 | float cc = clamp(c_t + L_tex(HOOKED_pos).x, MMKERNEL_tex(HOOKED_pos).y, MMKERNEL_tex(HOOKED_pos).z) - L_tex(HOOKED_pos).x; 146 | 147 | //This trick is only possible if the inverse Y->RGB matrix has 1 for every row... (which is the case for BT.709) 148 | //Otherwise we would need to convert RGB to YUV, modify Y then convert back to RGB. 149 | return HOOKED_tex(HOOKED_pos) + cc; 150 | } 151 | 152 | 153 | 154 | -------------------------------------------------------------------------------- /mpv/shaders/Anime4K_Upscale_Deblur_DoG_x2.glsl: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019-2021 bloc97 4 | // All rights reserved. 5 | 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | 24 | //!DESC Anime4K-v3.2-Upscale-Deblur-DoG-x2-Luma 25 | //!HOOK MAIN 26 | //!BIND HOOKED 27 | //!SAVE LINELUMA 28 | //!COMPONENTS 1 29 | 30 | float get_luma(vec4 rgba) { 31 | return dot(vec4(0.299, 0.587, 0.114, 0.0), rgba); 32 | } 33 | 34 | vec4 hook() { 35 | return vec4(get_luma(HOOKED_tex(HOOKED_pos)), 0.0, 0.0, 0.0); 36 | } 37 | 38 | //!DESC Anime4K-v3.2-Upscale-Deblur-DoG-x2-Kernel-X 39 | //!WHEN OUTPUT.w MAIN.w / 1.200 > OUTPUT.h MAIN.h / 1.200 > * 40 | //!HOOK MAIN 41 | //!BIND HOOKED 42 | //!BIND LINELUMA 43 | //!SAVE GAUSS_X2 44 | //!COMPONENTS 3 45 | 46 | #define L_tex LINELUMA_tex 47 | 48 | float max3v(float a, float b, float c) { 49 | return max(max(a, b), c); 50 | } 51 | float min3v(float a, float b, float c) { 52 | return min(min(a, b), c); 53 | } 54 | 55 | vec2 minmax3(vec2 pos, vec2 d) { 56 | float a = L_tex(pos - d).x; 57 | float b = L_tex(pos).x; 58 | float c = L_tex(pos + d).x; 59 | 60 | return vec2(min3v(a, b, c), max3v(a, b, c)); 61 | } 62 | 63 | float lumGaussian7(vec2 pos, vec2 d) { 64 | float g = (L_tex(pos - (d + d)).x + L_tex(pos + (d + d)).x) * 0.06136; 65 | g = g + (L_tex(pos - d).x + L_tex(pos + d).x) * 0.24477; 66 | g = g + (L_tex(pos).x) * 0.38774; 67 | 68 | return g; 69 | } 70 | 71 | 72 | vec4 hook() { 73 | return vec4(lumGaussian7(HOOKED_pos, vec2(HOOKED_pt.x, 0)), minmax3(HOOKED_pos, vec2(HOOKED_pt.x, 0)), 0); 74 | } 75 | 76 | 77 | //!DESC Anime4K-v3.2-Upscale-Deblur-DoG-x2-Kernel-Y 78 | //!WHEN OUTPUT.w MAIN.w / 1.200 > OUTPUT.h MAIN.h / 1.200 > * 79 | //!HOOK MAIN 80 | //!BIND HOOKED 81 | //!BIND GAUSS_X2 82 | //!SAVE GAUSS_X2 83 | //!COMPONENTS 3 84 | 85 | #define L_tex GAUSS_X2_tex 86 | 87 | float max3v(float a, float b, float c) { 88 | return max(max(a, b), c); 89 | } 90 | float min3v(float a, float b, float c) { 91 | return min(min(a, b), c); 92 | } 93 | 94 | vec2 minmax3(vec2 pos, vec2 d) { 95 | float a0 = L_tex(pos - d).y; 96 | float b0 = L_tex(pos).y; 97 | float c0 = L_tex(pos + d).y; 98 | 99 | float a1 = L_tex(pos - d).z; 100 | float b1 = L_tex(pos).z; 101 | float c1 = L_tex(pos + d).z; 102 | 103 | return vec2(min3v(a0, b0, c0), max3v(a1, b1, c1)); 104 | } 105 | 106 | float lumGaussian7(vec2 pos, vec2 d) { 107 | float g = (L_tex(pos - (d + d)).x + L_tex(pos + (d + d)).x) * 0.06136; 108 | g = g + (L_tex(pos - d).x + L_tex(pos + d).x) * 0.24477; 109 | g = g + (L_tex(pos).x) * 0.38774; 110 | 111 | return g; 112 | } 113 | 114 | 115 | vec4 hook() { 116 | return vec4(lumGaussian7(HOOKED_pos, vec2(0, HOOKED_pt.y)), minmax3(HOOKED_pos, vec2(0, HOOKED_pt.y)), 0); 117 | } 118 | 119 | //!DESC Anime4K-v3.2-Upscale-Deblur-DoG-x2-Apply 120 | //!WHEN OUTPUT.w MAIN.w / 1.200 > OUTPUT.h MAIN.h / 1.200 > * 121 | //!HOOK MAIN 122 | //!BIND HOOKED 123 | //!BIND LINELUMA 124 | //!BIND GAUSS_X2 125 | //!WIDTH MAIN.w 2 * 126 | //!HEIGHT MAIN.h 2 * 127 | 128 | #define STRENGTH 0.6 //De-blur proportional strength, higher is sharper. However, it is better to tweak BLUR_CURVE instead to avoid ringing. 129 | #define BLUR_CURVE 0.6 //De-blur power curve, lower is sharper. Good values are between 0.3 - 1. Values greater than 1 softens the image; 130 | #define BLUR_THRESHOLD 0.1 //Value where curve kicks in, used to not de-blur already sharp edges. Only de-blur values that fall below this threshold. 131 | #define NOISE_THRESHOLD 0.001 //Value where curve stops, used to not sharpen noise. Only de-blur values that fall above this threshold. 132 | 133 | #define L_tex LINELUMA_tex 134 | 135 | vec4 hook() { 136 | float c = (L_tex(HOOKED_pos).x - GAUSS_X2_tex(HOOKED_pos).x) * STRENGTH; 137 | 138 | float t_range = BLUR_THRESHOLD - NOISE_THRESHOLD; 139 | 140 | float c_t = abs(c); 141 | if (c_t > NOISE_THRESHOLD && c_t < BLUR_THRESHOLD) { 142 | c_t = (c_t - NOISE_THRESHOLD) / t_range; 143 | c_t = pow(c_t, BLUR_CURVE); 144 | c_t = c_t * t_range + NOISE_THRESHOLD; 145 | c_t = c_t * sign(c); 146 | } else { 147 | c_t = c; 148 | } 149 | 150 | float cc = clamp(c_t + L_tex(HOOKED_pos).x, GAUSS_X2_tex(HOOKED_pos).y, GAUSS_X2_tex(HOOKED_pos).z) - L_tex(HOOKED_pos).x; 151 | 152 | //This trick is only possible if the inverse Y->RGB matrix has 1 for every row... (which is the case for BT.709) 153 | //Otherwise we would need to convert RGB to YUV, modify Y then convert back to RGB. 154 | return HOOKED_tex(HOOKED_pos) + cc; 155 | } 156 | 157 | 158 | 159 | -------------------------------------------------------------------------------- /nvim/lua/window.lua: -------------------------------------------------------------------------------- 1 | local mappings = { 2 | k = "top", 3 | j = "bottom", 4 | h = "left", 5 | l = "right", 6 | } 7 | 8 | local function jump(direction) 9 | local prev = vim.fn.winnr() 10 | vim.cmd("wincmd " .. direction) 11 | 12 | if vim.fn.winnr() == prev then 13 | -- the `--to=$KITTY_LISTEN_ON` env is passed automatically 14 | vim.fn.system("kitty @ kitten window.py +jump " .. mappings[direction]) 15 | end 16 | end 17 | 18 | local function resize(direction) 19 | local cur = vim.fn.winnr() 20 | local cur_pos = vim.fn.win_screenpos(0) 21 | 22 | local function neighbor(target) 23 | local comp = vim.fn.winnr(target) 24 | if cur == comp then 25 | return false 26 | end 27 | 28 | local comp_pos = vim.fn.win_screenpos(comp) 29 | if target == "k" or target == "j" then 30 | return comp_pos[0] == cur_pos[0] 31 | else 32 | return comp_pos[1] == cur_pos[1] 33 | end 34 | end 35 | 36 | local top, bottom = neighbor("k"), neighbor("j") 37 | local left, right = neighbor("h"), neighbor("l") 38 | 39 | local modifier 40 | if direction == "k" then 41 | if top and bottom then 42 | modifier = "-" 43 | elseif top then 44 | modifier = "+" 45 | elseif bottom then 46 | modifier = "-" 47 | end 48 | elseif direction == "j" then 49 | if top and bottom then 50 | modifier = "+" 51 | elseif top then 52 | modifier = "-" 53 | elseif bottom then 54 | modifier = "+" 55 | end 56 | elseif direction == "h" then 57 | if left and right then 58 | modifier = "-" 59 | elseif left then 60 | modifier = "+" 61 | elseif right then 62 | modifier = "-" 63 | end 64 | elseif direction == "l" then 65 | if left and right then 66 | modifier = "+" 67 | elseif left then 68 | modifier = "-" 69 | elseif right then 70 | modifier = "+" 71 | end 72 | end 73 | 74 | if modifier == nil then 75 | vim.fn.system("kitty @ kitten window.py +resize " .. mappings[direction]) 76 | elseif direction == "k" or direction == "j" then 77 | vim.cmd("resize " .. modifier .. "10") 78 | else 79 | vim.cmd("vertical resize " .. modifier .. "10") 80 | end 81 | end 82 | 83 | local function move(direction) 84 | local prev = vim.fn.winnr() 85 | vim.cmd("wincmd " .. string.upper(direction)) 86 | 87 | if vim.fn.winnr() == prev then 88 | vim.fn.system("kitty @ kitten window.py +move " .. mappings[direction]) 89 | end 90 | end 91 | 92 | local function restore_cursor(opts) 93 | if opts.args == "force" or vim.bo.buftype == "terminal" then 94 | vim.cmd("startinsert") 95 | local line, col = unpack(vim.api.nvim_win_get_cursor(0)) 96 | vim.api.nvim_win_set_cursor(0, { line, col + 1 }) 97 | end 98 | end 99 | 100 | vim.api.nvim_create_user_command("WindowJumpTop", function() jump("k") end, {}) 101 | vim.api.nvim_create_user_command("WindowJumpBottom", function() jump("j") end, {}) 102 | vim.api.nvim_create_user_command("WindowJumpLeft", function() jump("h") end, {}) 103 | vim.api.nvim_create_user_command("WindowJumpRight", function() jump("l") end, {}) 104 | 105 | vim.api.nvim_create_user_command("WindowResizeTop", function() resize("k") end, {}) 106 | vim.api.nvim_create_user_command("WindowResizeBottom", function() resize("j") end, {}) 107 | vim.api.nvim_create_user_command("WindowResizeLeft", function() resize("h") end, {}) 108 | vim.api.nvim_create_user_command("WindowResizeRight", function() resize("l") end, {}) 109 | 110 | vim.api.nvim_create_user_command("WindowMoveTop", function() move("k") end, {}) 111 | vim.api.nvim_create_user_command("WindowMoveBottom", function() move("j") end, {}) 112 | vim.api.nvim_create_user_command("WindowMoveLeft", function() move("h") end, {}) 113 | vim.api.nvim_create_user_command("WindowMoveRight", function() move("l") end, {}) 114 | 115 | vim.api.nvim_create_user_command("RestoreCursor", restore_cursor, { nargs = "?" }) 116 | 117 | local function map_set(key, cmd, term) 118 | vim.keymap.set("", "<C-S-M-w>" .. key, string.format(":%s<CR>:RestoreCursor<CR>", cmd), { silent = true }) 119 | vim.keymap.set("i", "<C-S-M-w>" .. key, string.format("<Esc>:%s<CR>:RestoreCursor<CR>", cmd), { silent = true }) 120 | 121 | if term == 1 then 122 | vim.keymap.set("t", "<C-S-M-w>" .. key, string.format("<C-\\><C-n>:%s<CR>", cmd), { silent = true }) 123 | elseif term == 2 then 124 | vim.keymap.set("t", "<C-S-M-w>" .. key, string.format("<C-\\><C-n>:%s<CR>:startinsert<CR>", cmd), { silent = true }) 125 | end 126 | end 127 | 128 | local function on_close(mode) 129 | return function() 130 | local ft = vim.bo.filetype 131 | if ft == "TelescopePrompt" then 132 | return "<C-w>w" 133 | end 134 | if mode == "c" then 135 | return "<Esc>" 136 | end 137 | if mode == "i" then 138 | return "<Esc>:q<CR>" 139 | end 140 | return ":q<CR>" 141 | end 142 | end 143 | 144 | -- Splitting 145 | vim.opt.splitbelow = true 146 | vim.opt.splitright = true 147 | 148 | vim.keymap.set("n", "su", ":set nosplitbelow<CR>:split<CR>:set splitbelow<CR>", { silent = true }) 149 | vim.keymap.set("n", "se", ":set splitbelow<CR>:split<CR>", { silent = true }) 150 | vim.keymap.set("n", "sn", ":set nosplitright<CR>:vsplit<CR>:set splitright<CR>", { silent = true }) 151 | vim.keymap.set("n", "si", ":set splitright<CR>:vsplit<CR>", { silent = true }) 152 | 153 | -- Closing 154 | vim.keymap.set("", "<C-S-M-w>c", on_close(""), { expr = true, silent = true }) 155 | vim.keymap.set("i", "<C-S-M-w>c", on_close("i"), { expr = true, silent = true }) 156 | vim.keymap.set("c", "<C-S-M-w>c", on_close("c"), { expr = true, silent = true }) 157 | 158 | -- Quitting 159 | vim.keymap.set("", "<C-S-M-w>q", ":qa<CR>", { silent = true }) 160 | vim.keymap.set("i", "<C-S-M-w>q", "<Esc>:qa<CR>", { silent = true }) 161 | vim.keymap.set("c", "<C-S-M-w>q", "<Esc>:qa<CR>", { silent = true }) 162 | 163 | -- Jumping 164 | map_set("ju", "WindowJumpTop", 1) 165 | map_set("je", "WindowJumpBottom", 1) 166 | map_set("jn", "WindowJumpLeft", 1) 167 | map_set("ji", "WindowJumpRight", 1) 168 | 169 | -- Resizing 170 | map_set("ru", "WindowResizeTop", 2) 171 | map_set("re", "WindowResizeBottom", 2) 172 | map_set("rn", "WindowResizeLeft", 2) 173 | map_set("ri", "WindowResizeRight", 2) 174 | 175 | -- Moving 176 | map_set("mu", "WindowMoveTop", 2) 177 | map_set("me", "WindowMoveBottom", 2) 178 | map_set("mn", "WindowMoveLeft", 2) 179 | map_set("mi", "WindowMoveRight", 2) 180 | -------------------------------------------------------------------------------- /mpv/shaders/Anime4K_Darken_HQ.glsl: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019-2021 bloc97 4 | // All rights reserved. 5 | 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | 24 | //!DESC Anime4K-v3.2-Darken-DoG-(HQ)-Luma 25 | //!HOOK MAIN 26 | //!BIND HOOKED 27 | //!SAVE LINELUMA 28 | //!COMPONENTS 1 29 | 30 | float get_luma(vec4 rgba) { 31 | return dot(vec4(0.299, 0.587, 0.114, 0.0), rgba); 32 | } 33 | 34 | vec4 hook() { 35 | return vec4(get_luma(HOOKED_tex(HOOKED_pos)), 0.0, 0.0, 0.0); 36 | } 37 | 38 | //!DESC Anime4K-v3.2-Darken-DoG-(HQ)-Difference-X 39 | //!HOOK MAIN 40 | //!BIND HOOKED 41 | //!BIND LINELUMA 42 | //!SAVE LINEKERNEL 43 | //!COMPONENTS 1 44 | 45 | #define SPATIAL_SIGMA (1.0 * float(HOOKED_size.y) / 1080.0) //Spatial window size, must be a positive real number. 46 | 47 | #define KERNELSIZE (max(int(ceil(SPATIAL_SIGMA * 2.0)), 1) * 2 + 1) //Kernel size, must be an positive odd integer. 48 | #define KERNELHALFSIZE (int(KERNELSIZE/2)) //Half of the kernel size without remainder. Must be equal to trunc(KERNELSIZE/2). 49 | #define KERNELLEN (KERNELSIZE * KERNELSIZE) //Total area of kernel. Must be equal to KERNELSIZE * KERNELSIZE. 50 | 51 | float gaussian(float x, float s, float m) { 52 | float scaled = (x - m) / s; 53 | return exp(-0.5 * scaled * scaled); 54 | } 55 | 56 | float comp_gaussian_x() { 57 | 58 | float g = 0.0; 59 | float gn = 0.0; 60 | 61 | for (int i=0; i<KERNELSIZE; i++) { 62 | float di = float(i - KERNELHALFSIZE); 63 | float gf = gaussian(di, SPATIAL_SIGMA, 0.0); 64 | 65 | g = g + LINELUMA_texOff(vec2(di, 0.0)).x * gf; 66 | gn = gn + gf; 67 | 68 | } 69 | 70 | return g / gn; 71 | } 72 | 73 | vec4 hook() { 74 | return vec4(comp_gaussian_x(), 0.0, 0.0, 0.0); 75 | } 76 | 77 | //!DESC Anime4K-v3.2-Darken-DoG-(HQ)-Difference-Y 78 | //!HOOK MAIN 79 | //!BIND HOOKED 80 | //!BIND LINELUMA 81 | //!BIND LINEKERNEL 82 | //!SAVE LINEKERNEL 83 | //!COMPONENTS 1 84 | 85 | #define SPATIAL_SIGMA (1.0 * float(HOOKED_size.y) / 1080.0) //Spatial window size, must be a positive real number. 86 | 87 | #define KERNELSIZE (max(int(ceil(SPATIAL_SIGMA * 2.0)), 1) * 2 + 1) //Kernel size, must be an positive odd integer. 88 | #define KERNELHALFSIZE (int(KERNELSIZE/2)) //Half of the kernel size without remainder. Must be equal to trunc(KERNELSIZE/2). 89 | #define KERNELLEN (KERNELSIZE * KERNELSIZE) //Total area of kernel. Must be equal to KERNELSIZE * KERNELSIZE. 90 | 91 | float gaussian(float x, float s, float m) { 92 | float scaled = (x - m) / s; 93 | return exp(-0.5 * scaled * scaled); 94 | } 95 | 96 | float comp_gaussian_y() { 97 | 98 | float g = 0.0; 99 | float gn = 0.0; 100 | 101 | for (int i=0; i<KERNELSIZE; i++) { 102 | float di = float(i - KERNELHALFSIZE); 103 | float gf = gaussian(di, SPATIAL_SIGMA, 0.0); 104 | 105 | g = g + LINEKERNEL_texOff(vec2(0.0, di)).x * gf; 106 | gn = gn + gf; 107 | 108 | } 109 | 110 | return g / gn; 111 | } 112 | 113 | vec4 hook() { 114 | return vec4(min(LINELUMA_tex(HOOKED_pos).x - comp_gaussian_y(), 0.0), 0.0, 0.0, 0.0); 115 | } 116 | 117 | //!DESC Anime4K-v3.2-Darken-DoG-(HQ)-Gaussian-X 118 | //!HOOK MAIN 119 | //!BIND HOOKED 120 | //!BIND LINEKERNEL 121 | //!SAVE LINEKERNEL 122 | //!COMPONENTS 1 123 | 124 | #define SPATIAL_SIGMA (1.0 * float(HOOKED_size.y) / 1080.0) //Spatial window size, must be a positive real number. 125 | 126 | #define KERNELSIZE (max(int(ceil(SPATIAL_SIGMA * 2.0)), 1) * 2 + 1) //Kernel size, must be an positive odd integer. 127 | #define KERNELHALFSIZE (int(KERNELSIZE/2)) //Half of the kernel size without remainder. Must be equal to trunc(KERNELSIZE/2). 128 | #define KERNELLEN (KERNELSIZE * KERNELSIZE) //Total area of kernel. Must be equal to KERNELSIZE * KERNELSIZE. 129 | 130 | float gaussian(float x, float s, float m) { 131 | float scaled = (x - m) / s; 132 | return exp(-0.5 * scaled * scaled); 133 | } 134 | 135 | float comp_gaussian_x() { 136 | 137 | float g = 0.0; 138 | float gn = 0.0; 139 | 140 | for (int i=0; i<KERNELSIZE; i++) { 141 | float di = float(i - KERNELHALFSIZE); 142 | float gf = gaussian(di, SPATIAL_SIGMA, 0.0); 143 | 144 | g = g + LINEKERNEL_texOff(vec2(di, 0.0)).x * gf; 145 | gn = gn + gf; 146 | 147 | } 148 | 149 | return g / gn; 150 | } 151 | 152 | vec4 hook() { 153 | return vec4(comp_gaussian_x(), 0.0, 0.0, 0.0); 154 | } 155 | 156 | //!DESC Anime4K-v3.2-Darken-DoG-(HQ)-Gaussian-Y 157 | //!HOOK MAIN 158 | //!BIND HOOKED 159 | //!BIND LINEKERNEL 160 | 161 | #define SPATIAL_SIGMA (1.0 * float(HOOKED_size.y) / 1080.0) //Spatial window size, must be a positive real number. 162 | 163 | #define KERNELSIZE (max(int(ceil(SPATIAL_SIGMA * 2.0)), 1) * 2 + 1) //Kernel size, must be an positive odd integer. 164 | #define KERNELHALFSIZE (int(KERNELSIZE/2)) //Half of the kernel size without remainder. Must be equal to trunc(KERNELSIZE/2). 165 | #define KERNELLEN (KERNELSIZE * KERNELSIZE) //Total area of kernel. Must be equal to KERNELSIZE * KERNELSIZE. 166 | 167 | float gaussian(float x, float s, float m) { 168 | float scaled = (x - m) / s; 169 | return exp(-0.5 * scaled * scaled); 170 | } 171 | 172 | float comp_gaussian_y() { 173 | 174 | float g = 0.0; 175 | float gn = 0.0; 176 | 177 | for (int i=0; i<KERNELSIZE; i++) { 178 | float di = float(i - KERNELHALFSIZE); 179 | float gf = gaussian(di, SPATIAL_SIGMA, 0.0); 180 | 181 | g = g + LINEKERNEL_texOff(vec2(0.0, di)).x * gf; 182 | gn = gn + gf; 183 | 184 | } 185 | 186 | return g / gn; 187 | } 188 | 189 | 190 | 191 | #define STRENGTH 1.5 //Line darken proportional strength, higher is darker. 192 | 193 | vec4 hook() { 194 | //This trick is only possible if the inverse Y->RGB matrix has 1 for every row... (which is the case for BT.709) 195 | //Otherwise we would need to convert RGB to YUV, modify Y then convert back to RGB. 196 | return HOOKED_tex(HOOKED_pos) + (comp_gaussian_y() * STRENGTH); 197 | } 198 | 199 | -------------------------------------------------------------------------------- /nix/darwin/default.nix: -------------------------------------------------------------------------------- 1 | { pkgs, lib, ... }: 2 | 3 | let software = import ./software.nix { inherit pkgs; }; 4 | in 5 | { 6 | nix.configureBuildUsers = true; 7 | 8 | security.pam.enableSudoTouchIdAuth = true; 9 | 10 | environment = { 11 | loginShell = pkgs.zsh; 12 | systemPackages = software.nix; 13 | }; 14 | 15 | homebrew = { 16 | enable = true; 17 | caskArgs.no_quarantine = true; 18 | onActivation = { 19 | autoUpdate = true; 20 | cleanup = "zap"; 21 | upgrade = true; 22 | }; 23 | taps = [ 24 | "homebrew/cask-fonts" 25 | "homebrew/cask-versions" 26 | ]; 27 | brews = software.brew; 28 | casks = software.cask; 29 | #masApps = software.mas; 30 | }; 31 | 32 | system.defaults = { 33 | NSGlobalDomain = { 34 | # Auto hide the menubar 35 | _HIHideMenuBar = true; 36 | 37 | # Enable full keyboard access for all controls 38 | AppleKeyboardUIMode = 3; 39 | 40 | # Enable press-and-hold repeating 41 | ApplePressAndHoldEnabled = false; 42 | InitialKeyRepeat = 10; 43 | KeyRepeat = 1; 44 | 45 | # Disable "Natural" scrolling 46 | "com.apple.swipescrolldirection" = false; 47 | 48 | # Disable smart dash/period/quote substitutions 49 | NSAutomaticDashSubstitutionEnabled = false; 50 | NSAutomaticPeriodSubstitutionEnabled = false; 51 | NSAutomaticQuoteSubstitutionEnabled = false; 52 | 53 | # Disable automatic capitalization 54 | NSAutomaticCapitalizationEnabled = false; 55 | 56 | # Using expanded "save panel" by default 57 | NSNavPanelExpandedStateForSaveMode = true; 58 | NSNavPanelExpandedStateForSaveMode2 = true; 59 | 60 | # Increase window resize speed for Cocoa applications 61 | NSWindowResizeTime = 0.001; 62 | 63 | # Save to disk (not to iCloud) by default 64 | NSDocumentSaveNewDocumentsToCloud = true; 65 | }; 66 | 67 | dock = { 68 | # Set icon size and dock orientation 69 | tilesize = 48; 70 | orientation = "left"; 71 | 72 | # Set dock to auto-hide, and transparentize icons of hidden apps (⌘H) 73 | autohide = true; 74 | showhidden = true; 75 | 76 | # Disable to show recents, and light-dot of running apps 77 | show-recents = false; 78 | show-process-indicators = false; 79 | }; 80 | 81 | finder = { 82 | # Allow quitting via ⌘Q 83 | QuitMenuItem = true; 84 | 85 | # Disable warning when changing a file extension 86 | FXEnableExtensionChangeWarning = false; 87 | 88 | # Show all files and their extensions 89 | AppleShowAllExtensions = true; 90 | AppleShowAllFiles = true; 91 | 92 | # Show path bar, and layout as multi-column 93 | ShowPathbar = true; 94 | FXPreferredViewStyle = "clmv"; 95 | 96 | # Search in current folder by default 97 | FXDefaultSearchScope = "SCcf"; 98 | }; 99 | 100 | trackpad = { 101 | # Enable trackpad tap to click 102 | Clicking = true; 103 | 104 | # Enable 3-finger drag 105 | TrackpadThreeFingerDrag = true; 106 | }; 107 | 108 | ActivityMonitor = { 109 | # Sort by CPU usage 110 | SortColumn = "CPUUsage"; 111 | SortDirection = 0; 112 | }; 113 | 114 | LaunchServices = { 115 | # Disable quarantine for downloaded apps 116 | LSQuarantine = false; 117 | }; 118 | 119 | CustomSystemPreferences = { 120 | NSGlobalDomain = { 121 | # Set the system accent color, TODO: https://github.com/LnL7/nix-darwin/pull/230 122 | AppleAccentColor = 6; 123 | # Jump to the spot that's clicked on the scroll bar, TODO: https://github.com/LnL7/nix-darwin/pull/672 124 | AppleScrollerPagingBehavior = true; 125 | # Prefer tabs when opening documents, TODO: https://github.com/LnL7/nix-darwin/pull/673 126 | AppleWindowTabbingMode = "always"; 127 | }; 128 | "com.apple.finder" = { 129 | # Keep the desktop clean 130 | ShowHardDrivesOnDesktop = false; 131 | ShowRemovableMediaOnDesktop = false; 132 | ShowExternalHardDrivesOnDesktop = false; 133 | ShowMountedServersOnDesktop = false; 134 | 135 | # Show directories first 136 | _FXSortFoldersFirst = true; # TODO: https://github.com/LnL7/nix-darwin/pull/594 137 | 138 | # New window use the $HOME path 139 | NewWindowTarget = "PfHm"; 140 | NewWindowTargetPath = "file://$HOME/"; 141 | 142 | # Allow text selection in Quick Look 143 | QLEnableTextSelection = true; 144 | }; 145 | "com.apple.Safari" = { 146 | # For better privacy 147 | UniversalSearchEnabled = false; 148 | SuppressSearchSuggestions = true; 149 | SendDoNotTrackHTTPHeader = true; 150 | 151 | # Disable auto open safe downloads 152 | AutoOpenSafeDownloads = false; 153 | 154 | # Enable Develop Menu, Web Inspector 155 | IncludeDevelopMenu = true; 156 | IncludeInternalDebugMenu = true; 157 | WebKitDeveloperExtras = true; 158 | WebKitDeveloperExtrasEnabledPreferenceKey = true; 159 | "com.apple.Safari.ContentPageGroupIdentifier.WebKit2DeveloperExtrasEnabled" = true; 160 | }; 161 | "com.apple.universalaccess" = { 162 | # Set the cursor size, TODO: https://github.com/LnL7/nix-darwin/pull/671 163 | mouseDriverCursorSize = 1.5; 164 | }; 165 | "com.apple.screencapture" = { 166 | # Set the filename which screencaptures should be written, TODO: https://github.com/LnL7/nix-darwin/pull/670 167 | name = "screenshot"; 168 | include-date = false; 169 | }; 170 | "com.apple.desktopservices" = { 171 | # Avoid creating .DS_Store files on USB or network volumes 172 | DSDontWriteUSBStores = true; 173 | DSDontWriteNetworkStores = true; 174 | }; 175 | "com.apple.frameworks.diskimages" = { 176 | # Disable disk image verification 177 | skip-verify = true; 178 | skip-verify-locked = true; 179 | skip-verify-remote = true; 180 | }; 181 | "com.apple.CrashReporter" = { 182 | # Disable crash reporter 183 | DialogType = "none"; 184 | }; 185 | "com.apple.AdLib" = { 186 | # Disable personalized advertising 187 | forceLimitAdTracking = true; 188 | allowApplePersonalizedAdvertising = false; 189 | allowIdentifierForAdvertising = false; 190 | }; 191 | }; 192 | }; 193 | 194 | system.activationScripts.setting.text = '' 195 | # Unpin all apps, TODO: https://github.com/LnL7/nix-darwin/pull/619 196 | defaults write com.apple.dock persistent-apps -array "" 197 | 198 | # Show metadata info, but not preview in info panel 199 | defaults write com.apple.finder FXInfoPanesExpanded -dict MetaData -bool true Preview -bool false 200 | 201 | # Allow opening apps from any source 202 | sudo spctl --master-disable 203 | 204 | # Change the default apps 205 | duti -s com.microsoft.VSCode .txt all 206 | duti -s com.microsoft.VSCode .ass all 207 | duti -s io.mpv .mkv all 208 | duti -s com.colliderli.iina .mp4 all 209 | 210 | ~/.config/os/darwin/power.sh 211 | ''; 212 | } 213 | -------------------------------------------------------------------------------- /mpv/shaders/Anime4K_Thin_HQ.glsl: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019-2021 bloc97 4 | // All rights reserved. 5 | 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | 24 | //!DESC Anime4K-v3.2-Thin-(HQ)-Luma 25 | //!HOOK MAIN 26 | //!BIND HOOKED 27 | //!SAVE LINELUMA 28 | //!COMPONENTS 1 29 | 30 | float get_luma(vec4 rgba) { 31 | return dot(vec4(0.299, 0.587, 0.114, 0.0), rgba); 32 | } 33 | 34 | vec4 hook() { 35 | return vec4(get_luma(HOOKED_tex(HOOKED_pos)), 0.0, 0.0, 0.0); 36 | } 37 | 38 | //!DESC Anime4K-v3.2-Thin-(HQ)-Sobel-X 39 | //!HOOK MAIN 40 | //!BIND LINELUMA 41 | //!SAVE LINESOBEL 42 | //!COMPONENTS 2 43 | 44 | vec4 hook() { 45 | float l = LINELUMA_texOff(vec2(-1.0, 0.0)).x; 46 | float c = LINELUMA_tex(LINELUMA_pos).x; 47 | float r = LINELUMA_texOff(vec2(1.0, 0.0)).x; 48 | 49 | float xgrad = (-l + r); 50 | float ygrad = (l + c + c + r); 51 | 52 | return vec4(xgrad, ygrad, 0.0, 0.0); 53 | } 54 | 55 | 56 | //!DESC Anime4K-v3.2-Thin-(HQ)-Sobel-Y 57 | //!HOOK MAIN 58 | //!BIND LINESOBEL 59 | //!SAVE LINESOBEL 60 | //!COMPONENTS 1 61 | 62 | vec4 hook() { 63 | float tx = LINESOBEL_texOff(vec2(0.0, -1.0)).x; 64 | float cx = LINESOBEL_tex(LINESOBEL_pos).x; 65 | float bx = LINESOBEL_texOff(vec2(0.0, 1.0)).x; 66 | 67 | float ty = LINESOBEL_texOff(vec2(0.0, -1.0)).y; 68 | float by = LINESOBEL_texOff(vec2(0.0, 1.0)).y; 69 | 70 | float xgrad = (tx + cx + cx + bx) / 8.0; 71 | 72 | float ygrad = (-ty + by) / 8.0; 73 | 74 | //Computes the luminance's gradient 75 | float norm = sqrt(xgrad * xgrad + ygrad * ygrad); 76 | return vec4(pow(norm, 0.7)); 77 | } 78 | 79 | 80 | //!DESC Anime4K-v3.2-Thin-(HQ)-Gaussian-X 81 | //!HOOK MAIN 82 | //!BIND HOOKED 83 | //!BIND LINESOBEL 84 | //!SAVE LINESOBEL 85 | //!COMPONENTS 1 86 | 87 | #define SPATIAL_SIGMA (2.0 * float(HOOKED_size.y) / 1080.0) //Spatial window size, must be a positive real number. 88 | 89 | #define KERNELSIZE (max(int(ceil(SPATIAL_SIGMA * 2.0)), 1) * 2 + 1) //Kernel size, must be an positive odd integer. 90 | #define KERNELHALFSIZE (int(KERNELSIZE/2)) //Half of the kernel size without remainder. Must be equal to trunc(KERNELSIZE/2). 91 | #define KERNELLEN (KERNELSIZE * KERNELSIZE) //Total area of kernel. Must be equal to KERNELSIZE * KERNELSIZE. 92 | 93 | float gaussian(float x, float s, float m) { 94 | float scaled = (x - m) / s; 95 | return exp(-0.5 * scaled * scaled); 96 | } 97 | 98 | float comp_gaussian_x() { 99 | 100 | float g = 0.0; 101 | float gn = 0.0; 102 | 103 | for (int i=0; i<KERNELSIZE; i++) { 104 | float di = float(i - KERNELHALFSIZE); 105 | float gf = gaussian(di, SPATIAL_SIGMA, 0.0); 106 | 107 | g = g + LINESOBEL_texOff(vec2(di, 0.0)).x * gf; 108 | gn = gn + gf; 109 | 110 | } 111 | 112 | return g / gn; 113 | } 114 | 115 | vec4 hook() { 116 | return vec4(comp_gaussian_x(), 0.0, 0.0, 0.0); 117 | } 118 | 119 | 120 | //!DESC Anime4K-v3.2-Thin-(HQ)-Gaussian-Y 121 | //!HOOK MAIN 122 | //!BIND HOOKED 123 | //!BIND LINESOBEL 124 | //!SAVE LINESOBEL 125 | //!COMPONENTS 1 126 | 127 | #define SPATIAL_SIGMA (2.0 * float(HOOKED_size.y) / 1080.0) //Spatial window size, must be a positive real number. 128 | 129 | #define KERNELSIZE (max(int(ceil(SPATIAL_SIGMA * 2.0)), 1) * 2 + 1) //Kernel size, must be an positive odd integer. 130 | #define KERNELHALFSIZE (int(KERNELSIZE/2)) //Half of the kernel size without remainder. Must be equal to trunc(KERNELSIZE/2). 131 | #define KERNELLEN (KERNELSIZE * KERNELSIZE) //Total area of kernel. Must be equal to KERNELSIZE * KERNELSIZE. 132 | 133 | float gaussian(float x, float s, float m) { 134 | float scaled = (x - m) / s; 135 | return exp(-0.5 * scaled * scaled); 136 | } 137 | 138 | float comp_gaussian_y() { 139 | 140 | float g = 0.0; 141 | float gn = 0.0; 142 | 143 | for (int i=0; i<KERNELSIZE; i++) { 144 | float di = float(i - KERNELHALFSIZE); 145 | float gf = gaussian(di, SPATIAL_SIGMA, 0.0); 146 | 147 | g = g + LINESOBEL_texOff(vec2(0.0, di)).x * gf; 148 | gn = gn + gf; 149 | 150 | } 151 | 152 | return g / gn; 153 | } 154 | 155 | vec4 hook() { 156 | return vec4(comp_gaussian_y(), 0.0, 0.0, 0.0); 157 | } 158 | 159 | //!DESC Anime4K-v3.2-Thin-(HQ)-Kernel-X 160 | //!HOOK MAIN 161 | //!BIND LINESOBEL 162 | //!SAVE LINESOBEL 163 | //!COMPONENTS 2 164 | 165 | vec4 hook() { 166 | float l = LINESOBEL_texOff(vec2(-1.0, 0.0)).x; 167 | float c = LINESOBEL_tex(LINESOBEL_pos).x; 168 | float r = LINESOBEL_texOff(vec2(1.0, 0.0)).x; 169 | 170 | float xgrad = (-l + r); 171 | float ygrad = (l + c + c + r); 172 | 173 | return vec4(xgrad, ygrad, 0.0, 0.0); 174 | } 175 | 176 | 177 | //!DESC Anime4K-v3.2-Thin-(HQ)-Kernel-Y 178 | //!HOOK MAIN 179 | //!BIND LINESOBEL 180 | //!SAVE LINESOBEL 181 | //!COMPONENTS 2 182 | 183 | vec4 hook() { 184 | float tx = LINESOBEL_texOff(vec2(0.0, -1.0)).x; 185 | float cx = LINESOBEL_tex(LINESOBEL_pos).x; 186 | float bx = LINESOBEL_texOff(vec2(0.0, 1.0)).x; 187 | 188 | float ty = LINESOBEL_texOff(vec2(0.0, -1.0)).y; 189 | float by = LINESOBEL_texOff(vec2(0.0, 1.0)).y; 190 | 191 | float xgrad = (tx + cx + cx + bx) / 8.0; 192 | 193 | float ygrad = (-ty + by) / 8.0; 194 | 195 | //Computes the luminance's gradient 196 | return vec4(xgrad, ygrad, 0.0, 0.0); 197 | } 198 | 199 | 200 | //!DESC Anime4K-v3.2-Thin-(HQ)-Warp 201 | //!HOOK MAIN 202 | //!BIND HOOKED 203 | //!BIND LINESOBEL 204 | 205 | #define STRENGTH 0.6 //Strength of warping for each iteration 206 | #define ITERATIONS 1 //Number of iterations for the forwards solver, decreasing strength and increasing iterations improves quality at the cost of speed. 207 | 208 | vec4 hook() { 209 | vec2 d = HOOKED_pt; 210 | 211 | float relstr = HOOKED_size.y / 1080.0 * STRENGTH; 212 | 213 | vec2 pos = HOOKED_pos; 214 | for (int i=0; i<ITERATIONS; i++) { 215 | vec2 dn = LINESOBEL_tex(pos).xy; 216 | vec2 dd = (dn / (length(dn) + 0.01)) * d * relstr; //Quasi-normalization for large vectors, avoids divide by zero 217 | pos -= dd; 218 | } 219 | 220 | return HOOKED_tex(pos); 221 | 222 | } 223 | -------------------------------------------------------------------------------- /mpv/shaders/Anime4K_Thin_Fast.glsl: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019-2021 bloc97 4 | // All rights reserved. 5 | 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | 24 | //!DESC Anime4K-v3.2-Thin-(Fast)-Luma 25 | //!HOOK MAIN 26 | //!BIND HOOKED 27 | //!SAVE LINELUMA 28 | //!COMPONENTS 1 29 | 30 | float get_luma(vec4 rgba) { 31 | return dot(vec4(0.299, 0.587, 0.114, 0.0), rgba); 32 | } 33 | 34 | vec4 hook() { 35 | return vec4(get_luma(HOOKED_tex(HOOKED_pos)), 0.0, 0.0, 0.0); 36 | } 37 | 38 | //!DESC Anime4K-v3.2-Thin-(Fast)-Sobel-X 39 | //!HOOK MAIN 40 | //!BIND LINELUMA 41 | //!SAVE LINESOBEL 42 | //!WIDTH HOOKED.w 2 / 43 | //!HEIGHT HOOKED.h 2 / 44 | //!COMPONENTS 2 45 | 46 | vec4 hook() { 47 | float l = LINELUMA_texOff(vec2(-1.0, 0.0)).x; 48 | float c = LINELUMA_tex(LINELUMA_pos).x; 49 | float r = LINELUMA_texOff(vec2(1.0, 0.0)).x; 50 | 51 | float xgrad = (-l + r); 52 | float ygrad = (l + c + c + r); 53 | 54 | return vec4(xgrad, ygrad, 0.0, 0.0); 55 | } 56 | 57 | 58 | //!DESC Anime4K-v3.2-Thin-(Fast)-Sobel-Y 59 | //!HOOK MAIN 60 | //!BIND LINESOBEL 61 | //!SAVE LINESOBEL 62 | //!WIDTH HOOKED.w 2 / 63 | //!HEIGHT HOOKED.h 2 / 64 | //!COMPONENTS 1 65 | 66 | vec4 hook() { 67 | float tx = LINESOBEL_texOff(vec2(0.0, -0.5)).x; 68 | float cx = LINESOBEL_tex(LINESOBEL_pos).x; 69 | float bx = LINESOBEL_texOff(vec2(0.0, 0.5)).x; 70 | 71 | float ty = LINESOBEL_texOff(vec2(0.0, -0.5)).y; 72 | float by = LINESOBEL_texOff(vec2(0.0, 0.5)).y; 73 | 74 | float xgrad = (tx + cx + cx + bx) / 8.0; 75 | 76 | float ygrad = (-ty + by) / 8.0; 77 | 78 | //Computes the luminance's gradient 79 | float norm = sqrt(xgrad * xgrad + ygrad * ygrad); 80 | return vec4(pow(norm, 0.7)); 81 | } 82 | 83 | 84 | //!DESC Anime4K-v3.2-Thin-(Fast)-Gaussian-X 85 | //!HOOK MAIN 86 | //!BIND HOOKED 87 | //!BIND LINESOBEL 88 | //!SAVE LINESOBEL 89 | //!WIDTH HOOKED.w 2 / 90 | //!HEIGHT HOOKED.h 2 / 91 | //!COMPONENTS 1 92 | 93 | #define SPATIAL_SIGMA (1.0 * float(HOOKED_size.y) / 1080.0) //Spatial window size, must be a positive real number. 94 | 95 | #define KERNELSIZE (max(int(ceil(SPATIAL_SIGMA * 2.0)), 1) * 2 + 1) //Kernel size, must be an positive odd integer. 96 | #define KERNELHALFSIZE (int(KERNELSIZE/2)) //Half of the kernel size without remainder. Must be equal to trunc(KERNELSIZE/2). 97 | #define KERNELLEN (KERNELSIZE * KERNELSIZE) //Total area of kernel. Must be equal to KERNELSIZE * KERNELSIZE. 98 | 99 | float gaussian(float x, float s, float m) { 100 | float scaled = (x - m) / s; 101 | return exp(-0.5 * scaled * scaled); 102 | } 103 | 104 | float comp_gaussian_x() { 105 | 106 | float g = 0.0; 107 | float gn = 0.0; 108 | 109 | for (int i=0; i<KERNELSIZE; i++) { 110 | float di = float(i - KERNELHALFSIZE); 111 | float gf = gaussian(di, SPATIAL_SIGMA, 0.0); 112 | 113 | g = g + LINESOBEL_texOff(vec2(di, 0.0)).x * gf; 114 | gn = gn + gf; 115 | 116 | } 117 | 118 | return g / gn; 119 | } 120 | 121 | vec4 hook() { 122 | return vec4(comp_gaussian_x(), 0.0, 0.0, 0.0); 123 | } 124 | 125 | 126 | //!DESC Anime4K-v3.2-Thin-(Fast)-Gaussian-Y 127 | //!HOOK MAIN 128 | //!BIND HOOKED 129 | //!BIND LINESOBEL 130 | //!SAVE LINESOBEL 131 | //!WIDTH HOOKED.w 2 / 132 | //!HEIGHT HOOKED.h 2 / 133 | //!COMPONENTS 1 134 | 135 | #define SPATIAL_SIGMA (1.0 * float(HOOKED_size.y) / 1080.0) //Spatial window size, must be a positive real number. 136 | 137 | #define KERNELSIZE (max(int(ceil(SPATIAL_SIGMA * 2.0)), 1) * 2 + 1) //Kernel size, must be an positive odd integer. 138 | #define KERNELHALFSIZE (int(KERNELSIZE/2)) //Half of the kernel size without remainder. Must be equal to trunc(KERNELSIZE/2). 139 | #define KERNELLEN (KERNELSIZE * KERNELSIZE) //Total area of kernel. Must be equal to KERNELSIZE * KERNELSIZE. 140 | 141 | float gaussian(float x, float s, float m) { 142 | float scaled = (x - m) / s; 143 | return exp(-0.5 * scaled * scaled); 144 | } 145 | 146 | float comp_gaussian_y() { 147 | 148 | float g = 0.0; 149 | float gn = 0.0; 150 | 151 | for (int i=0; i<KERNELSIZE; i++) { 152 | float di = float(i - KERNELHALFSIZE); 153 | float gf = gaussian(di, SPATIAL_SIGMA, 0.0); 154 | 155 | g = g + LINESOBEL_texOff(vec2(0.0, di)).x * gf; 156 | gn = gn + gf; 157 | 158 | } 159 | 160 | return g / gn; 161 | } 162 | 163 | vec4 hook() { 164 | return vec4(comp_gaussian_y(), 0.0, 0.0, 0.0); 165 | } 166 | 167 | //!DESC Anime4K-v3.2-Thin-(Fast)-Kernel-X 168 | //!HOOK MAIN 169 | //!BIND LINESOBEL 170 | //!SAVE LINESOBEL 171 | //!WIDTH HOOKED.w 2 / 172 | //!HEIGHT HOOKED.h 2 / 173 | //!COMPONENTS 2 174 | 175 | vec4 hook() { 176 | float l = LINESOBEL_texOff(vec2(-0.5, 0.0)).x; 177 | float c = LINESOBEL_tex(LINESOBEL_pos).x; 178 | float r = LINESOBEL_texOff(vec2(0.5, 0.0)).x; 179 | 180 | float xgrad = (-l + r); 181 | float ygrad = (l + c + c + r); 182 | 183 | return vec4(xgrad, ygrad, 0.0, 0.0); 184 | } 185 | 186 | 187 | //!DESC Anime4K-v3.2-Thin-(Fast)-Kernel-Y 188 | //!HOOK MAIN 189 | //!BIND LINESOBEL 190 | //!SAVE LINESOBEL 191 | //!WIDTH HOOKED.w 2 / 192 | //!HEIGHT HOOKED.h 2 / 193 | //!COMPONENTS 2 194 | 195 | vec4 hook() { 196 | float tx = LINESOBEL_texOff(vec2(0.0, -0.5)).x; 197 | float cx = LINESOBEL_tex(LINESOBEL_pos).x; 198 | float bx = LINESOBEL_texOff(vec2(0.0, 0.5)).x; 199 | 200 | float ty = LINESOBEL_texOff(vec2(0.0, -0.5)).y; 201 | float by = LINESOBEL_texOff(vec2(0.0, 0.5)).y; 202 | 203 | float xgrad = (tx + cx + cx + bx) / 8.0; 204 | 205 | float ygrad = (-ty + by) / 8.0; 206 | 207 | //Computes the luminance's gradient 208 | return vec4(xgrad, ygrad, 0.0, 0.0); 209 | } 210 | 211 | 212 | //!DESC Anime4K-v3.2-Thin-(Fast)-Warp 213 | //!HOOK MAIN 214 | //!BIND HOOKED 215 | //!BIND LINESOBEL 216 | 217 | #define STRENGTH 0.6 //Strength of warping for each iteration 218 | #define ITERATIONS 1 //Number of iterations for the forwards solver, decreasing strength and increasing iterations improves quality at the cost of speed. 219 | 220 | vec4 hook() { 221 | vec2 d = HOOKED_pt; 222 | 223 | float relstr = HOOKED_size.y / 1080.0 * STRENGTH; 224 | 225 | vec2 pos = HOOKED_pos; 226 | for (int i=0; i<ITERATIONS; i++) { 227 | vec2 dn = LINESOBEL_tex(pos).xy; 228 | vec2 dd = (dn / (length(dn) + 0.01)) * d * relstr; //Quasi-normalization for large vectors, avoids divide by zero 229 | pos -= dd; 230 | } 231 | 232 | return HOOKED_tex(pos); 233 | 234 | } 235 | -------------------------------------------------------------------------------- /mpv/shaders/Anime4K_Darken_Fast.glsl: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019-2021 bloc97 4 | // All rights reserved. 5 | 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | 24 | //!DESC Anime4K-v3.2-Darken-DoG-(HQ)-Luma 25 | //!HOOK MAIN 26 | //!BIND HOOKED 27 | //!SAVE LINELUMA 28 | //!COMPONENTS 1 29 | 30 | float get_luma(vec4 rgba) { 31 | return dot(vec4(0.299, 0.587, 0.114, 0.0), rgba); 32 | } 33 | 34 | vec4 hook() { 35 | return vec4(get_luma(HOOKED_tex(HOOKED_pos)), 0.0, 0.0, 0.0); 36 | } 37 | 38 | //!DESC Anime4K-v3.2-Darken-DoG-(Fast)-Difference-X 39 | //!HOOK MAIN 40 | //!BIND HOOKED 41 | //!BIND LINELUMA 42 | //!SAVE LINEKERNEL 43 | //!WIDTH HOOKED.w 2 / 44 | //!HEIGHT HOOKED.h 2 / 45 | //!COMPONENTS 1 46 | 47 | #define SPATIAL_SIGMA (1.0 * float(HOOKED_size.y) / 1080.0) //Spatial window size, must be a positive real number. 48 | 49 | #define KERNELSIZE (max(int(ceil(SPATIAL_SIGMA * 2.0)), 1) * 2 + 1) //Kernel size, must be an positive odd integer. 50 | #define KERNELHALFSIZE (int(KERNELSIZE/2)) //Half of the kernel size without remainder. Must be equal to trunc(KERNELSIZE/2). 51 | #define KERNELLEN (KERNELSIZE * KERNELSIZE) //Total area of kernel. Must be equal to KERNELSIZE * KERNELSIZE. 52 | 53 | float gaussian(float x, float s, float m) { 54 | float scaled = (x - m) / s; 55 | return exp(-0.5 * scaled * scaled); 56 | } 57 | 58 | float comp_gaussian_x() { 59 | 60 | float g = 0.0; 61 | float gn = 0.0; 62 | 63 | for (int i=0; i<KERNELSIZE; i++) { 64 | float di = float(i - KERNELHALFSIZE); 65 | float gf = gaussian(di, SPATIAL_SIGMA, 0.0); 66 | 67 | g = g + LINELUMA_texOff(vec2(di, 0.0)).x * gf; 68 | gn = gn + gf; 69 | 70 | } 71 | 72 | return g / gn; 73 | } 74 | 75 | vec4 hook() { 76 | return vec4(comp_gaussian_x(), 0.0, 0.0, 0.0); 77 | } 78 | 79 | //!DESC Anime4K-v3.2-Darken-DoG-(Fast)-Difference-Y 80 | //!HOOK MAIN 81 | //!BIND HOOKED 82 | //!BIND LINELUMA 83 | //!BIND LINEKERNEL 84 | //!SAVE LINEKERNEL 85 | //!WIDTH HOOKED.w 2 / 86 | //!HEIGHT HOOKED.h 2 / 87 | //!COMPONENTS 1 88 | 89 | #define SPATIAL_SIGMA (0.5 * float(HOOKED_size.y) / 1080.0) //Spatial window size, must be a positive real number. 90 | 91 | #define KERNELSIZE (max(int(ceil(SPATIAL_SIGMA * 2.0)), 1) * 2 + 1) //Kernel size, must be an positive odd integer. 92 | #define KERNELHALFSIZE (int(KERNELSIZE/2)) //Half of the kernel size without remainder. Must be equal to trunc(KERNELSIZE/2). 93 | #define KERNELLEN (KERNELSIZE * KERNELSIZE) //Total area of kernel. Must be equal to KERNELSIZE * KERNELSIZE. 94 | 95 | float gaussian(float x, float s, float m) { 96 | float scaled = (x - m) / s; 97 | return exp(-0.5 * scaled * scaled); 98 | } 99 | 100 | float comp_gaussian_y() { 101 | 102 | float g = 0.0; 103 | float gn = 0.0; 104 | 105 | for (int i=0; i<KERNELSIZE; i++) { 106 | float di = float(i - KERNELHALFSIZE); 107 | float gf = gaussian(di, SPATIAL_SIGMA, 0.0); 108 | 109 | g = g + LINEKERNEL_texOff(vec2(0.0, di)).x * gf; 110 | gn = gn + gf; 111 | 112 | } 113 | 114 | return g / gn; 115 | } 116 | 117 | vec4 hook() { 118 | return vec4(min(LINELUMA_tex(HOOKED_pos).x - comp_gaussian_y(), 0.0), 0.0, 0.0, 0.0); 119 | } 120 | 121 | //!DESC Anime4K-v3.2-Darken-DoG-(Fast)-Gaussian-X 122 | //!HOOK MAIN 123 | //!BIND HOOKED 124 | //!BIND LINEKERNEL 125 | //!SAVE LINEKERNEL 126 | //!WIDTH HOOKED.w 2 / 127 | //!HEIGHT HOOKED.h 2 / 128 | //!COMPONENTS 1 129 | 130 | #define SPATIAL_SIGMA (0.5 * float(HOOKED_size.y) / 1080.0) //Spatial window size, must be a positive real number. 131 | 132 | #define KERNELSIZE (max(int(ceil(SPATIAL_SIGMA * 2.0)), 1) * 2 + 1) //Kernel size, must be an positive odd integer. 133 | #define KERNELHALFSIZE (int(KERNELSIZE/2)) //Half of the kernel size without remainder. Must be equal to trunc(KERNELSIZE/2). 134 | #define KERNELLEN (KERNELSIZE * KERNELSIZE) //Total area of kernel. Must be equal to KERNELSIZE * KERNELSIZE. 135 | 136 | float gaussian(float x, float s, float m) { 137 | float scaled = (x - m) / s; 138 | return exp(-0.5 * scaled * scaled); 139 | } 140 | 141 | float comp_gaussian_x() { 142 | 143 | float g = 0.0; 144 | float gn = 0.0; 145 | 146 | for (int i=0; i<KERNELSIZE; i++) { 147 | float di = float(i - KERNELHALFSIZE); 148 | float gf = gaussian(di, SPATIAL_SIGMA, 0.0); 149 | 150 | g = g + LINEKERNEL_texOff(vec2(di, 0.0)).x * gf; 151 | gn = gn + gf; 152 | 153 | } 154 | 155 | return g / gn; 156 | } 157 | 158 | vec4 hook() { 159 | return vec4(comp_gaussian_x(), 0.0, 0.0, 0.0); 160 | } 161 | 162 | //!DESC Anime4K-v3.2-Darken-DoG-(Fast)-Gaussian-Y 163 | //!HOOK MAIN 164 | //!BIND HOOKED 165 | //!BIND LINEKERNEL 166 | //!SAVE LINEKERNEL 167 | //!WIDTH HOOKED.w 2 / 168 | //!HEIGHT HOOKED.h 2 / 169 | //!COMPONENTS 1 170 | 171 | #define SPATIAL_SIGMA (0.5 * float(HOOKED_size.y) / 1080.0) //Spatial window size, must be a positive real number. 172 | 173 | #define KERNELSIZE (max(int(ceil(SPATIAL_SIGMA * 2.0)), 1) * 2 + 1) //Kernel size, must be an positive odd integer. 174 | #define KERNELHALFSIZE (int(KERNELSIZE/2)) //Half of the kernel size without remainder. Must be equal to trunc(KERNELSIZE/2). 175 | #define KERNELLEN (KERNELSIZE * KERNELSIZE) //Total area of kernel. Must be equal to KERNELSIZE * KERNELSIZE. 176 | 177 | float gaussian(float x, float s, float m) { 178 | float scaled = (x - m) / s; 179 | return exp(-0.5 * scaled * scaled); 180 | } 181 | 182 | float comp_gaussian_y() { 183 | 184 | float g = 0.0; 185 | float gn = 0.0; 186 | 187 | for (int i=0; i<KERNELSIZE; i++) { 188 | float di = float(i - KERNELHALFSIZE); 189 | float gf = gaussian(di, SPATIAL_SIGMA, 0.0); 190 | 191 | g = g + LINEKERNEL_texOff(vec2(0.0, di)).x * gf; 192 | gn = gn + gf; 193 | 194 | } 195 | 196 | return g / gn; 197 | } 198 | 199 | vec4 hook() { 200 | return vec4(comp_gaussian_y(), 0.0, 0.0, 0.0); 201 | } 202 | 203 | 204 | //!DESC Anime4K-v3.2-Darken-DoG-(Fast)-Upsample 205 | //!HOOK MAIN 206 | //!BIND HOOKED 207 | //!BIND LINEKERNEL 208 | 209 | #define STRENGTH 1.5 //Line darken proportional strength, higher is darker. 210 | 211 | vec4 hook() { 212 | //This trick is only possible if the inverse Y->RGB matrix has 1 for every row... (which is the case for BT.709) 213 | //Otherwise we would need to convert RGB to YUV, modify Y then convert back to RGB. 214 | return HOOKED_tex(HOOKED_pos) + (LINEKERNEL_tex(HOOKED_pos).x * STRENGTH); 215 | } 216 | 217 | -------------------------------------------------------------------------------- /mpv/shaders/Anime4K_Darken_VeryFast.glsl: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019-2021 bloc97 4 | // All rights reserved. 5 | 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | 24 | //!DESC Anime4K-v3.2-Darken-DoG-(HQ)-Luma 25 | //!HOOK MAIN 26 | //!BIND HOOKED 27 | //!SAVE LINELUMA 28 | //!WIDTH HOOKED.w 2 / 29 | //!HEIGHT HOOKED.h 2 / 30 | //!COMPONENTS 1 31 | 32 | float get_luma(vec4 rgba) { 33 | return dot(vec4(0.299, 0.587, 0.114, 0.0), rgba); 34 | } 35 | 36 | vec4 hook() { 37 | return vec4(get_luma(HOOKED_tex(HOOKED_pos)), 0.0, 0.0, 0.0); 38 | } 39 | 40 | //!DESC Anime4K-v3.2-Darken-DoG-(VeryFast)-Gaussian-X 41 | //!HOOK MAIN 42 | //!BIND HOOKED 43 | //!BIND LINELUMA 44 | //!SAVE LINEKERNEL 45 | //!WIDTH HOOKED.w 4 / 46 | //!HEIGHT HOOKED.h 4 / 47 | //!COMPONENTS 1 48 | 49 | #define SPATIAL_SIGMA (0.5 * float(HOOKED_size.y) / 1080.0) //Spatial window size, must be a positive real number. 50 | 51 | #define KERNELSIZE (max(int(ceil(SPATIAL_SIGMA * 2.0)), 1) * 2 + 1) //Kernel size, must be an positive odd integer. 52 | #define KERNELHALFSIZE (int(KERNELSIZE/2)) //Half of the kernel size without remainder. Must be equal to trunc(KERNELSIZE/2). 53 | #define KERNELLEN (KERNELSIZE * KERNELSIZE) //Total area of kernel. Must be equal to KERNELSIZE * KERNELSIZE. 54 | 55 | float gaussian(float x, float s, float m) { 56 | float scaled = (x - m) / s; 57 | return exp(-0.5 * scaled * scaled); 58 | } 59 | 60 | float comp_gaussian_x() { 61 | 62 | float g = 0.0; 63 | float gn = 0.0; 64 | 65 | for (int i=0; i<KERNELSIZE; i++) { 66 | float di = float(i - KERNELHALFSIZE); 67 | float gf = gaussian(di, SPATIAL_SIGMA, 0.0); 68 | 69 | g = g + LINELUMA_texOff(vec2(di, 0.0)).x * gf; 70 | gn = gn + gf; 71 | 72 | } 73 | 74 | return g / gn; 75 | } 76 | 77 | vec4 hook() { 78 | return vec4(comp_gaussian_x(), 0.0, 0.0, 0.0); 79 | } 80 | 81 | //!DESC Anime4K-v3.2-Darken-DoG-(VeryFast)-Gaussian-Y 82 | //!HOOK MAIN 83 | //!BIND HOOKED 84 | //!BIND LINELUMA 85 | //!BIND LINEKERNEL 86 | //!SAVE LINEKERNEL 87 | //!WIDTH HOOKED.w 4 / 88 | //!HEIGHT HOOKED.h 4 / 89 | //!COMPONENTS 1 90 | 91 | #define SPATIAL_SIGMA (0.25 * float(HOOKED_size.y) / 1080.0) //Spatial window size, must be a positive real number. 92 | 93 | #define KERNELSIZE (max(int(ceil(SPATIAL_SIGMA * 2.0)), 1) * 2 + 1) //Kernel size, must be an positive odd integer. 94 | #define KERNELHALFSIZE (int(KERNELSIZE/2)) //Half of the kernel size without remainder. Must be equal to trunc(KERNELSIZE/2). 95 | #define KERNELLEN (KERNELSIZE * KERNELSIZE) //Total area of kernel. Must be equal to KERNELSIZE * KERNELSIZE. 96 | 97 | float gaussian(float x, float s, float m) { 98 | float scaled = (x - m) / s; 99 | return exp(-0.5 * scaled * scaled); 100 | } 101 | 102 | float comp_gaussian_y() { 103 | 104 | float g = 0.0; 105 | float gn = 0.0; 106 | 107 | for (int i=0; i<KERNELSIZE; i++) { 108 | float di = float(i - KERNELHALFSIZE); 109 | float gf = gaussian(di, SPATIAL_SIGMA, 0.0); 110 | 111 | g = g + LINEKERNEL_texOff(vec2(0.0, di)).x * gf; 112 | gn = gn + gf; 113 | 114 | } 115 | 116 | return g / gn; 117 | } 118 | 119 | vec4 hook() { 120 | return vec4(min(LINELUMA_tex(HOOKED_pos).x - comp_gaussian_y(), 0.0), 0.0, 0.0, 0.0); 121 | } 122 | 123 | //!DESC Anime4K-v3.2-Darken-DoG-(VeryFast)-Gaussian-X 124 | //!HOOK MAIN 125 | //!BIND HOOKED 126 | //!BIND LINEKERNEL 127 | //!SAVE LINEKERNEL 128 | //!WIDTH HOOKED.w 4 / 129 | //!HEIGHT HOOKED.h 4 / 130 | //!COMPONENTS 1 131 | 132 | #define SPATIAL_SIGMA (0.25 * float(HOOKED_size.y) / 1080.0) //Spatial window size, must be a positive real number. 133 | 134 | #define KERNELSIZE (max(int(ceil(SPATIAL_SIGMA * 2.0)), 1) * 2 + 1) //Kernel size, must be an positive odd integer. 135 | #define KERNELHALFSIZE (int(KERNELSIZE/2)) //Half of the kernel size without remainder. Must be equal to trunc(KERNELSIZE/2). 136 | #define KERNELLEN (KERNELSIZE * KERNELSIZE) //Total area of kernel. Must be equal to KERNELSIZE * KERNELSIZE. 137 | 138 | float gaussian(float x, float s, float m) { 139 | float scaled = (x - m) / s; 140 | return exp(-0.5 * scaled * scaled); 141 | } 142 | 143 | float comp_gaussian_x() { 144 | 145 | float g = 0.0; 146 | float gn = 0.0; 147 | 148 | for (int i=0; i<KERNELSIZE; i++) { 149 | float di = float(i - KERNELHALFSIZE); 150 | float gf = gaussian(di, SPATIAL_SIGMA, 0.0); 151 | 152 | g = g + LINEKERNEL_texOff(vec2(di, 0.0)).x * gf; 153 | gn = gn + gf; 154 | 155 | } 156 | 157 | return g / gn; 158 | } 159 | 160 | vec4 hook() { 161 | return vec4(comp_gaussian_x(), 0.0, 0.0, 0.0); 162 | } 163 | 164 | //!DESC Anime4K-v3.2-Darken-DoG-(VeryFast)-Gaussian-Y 165 | //!HOOK MAIN 166 | //!BIND HOOKED 167 | //!BIND LINEKERNEL 168 | //!SAVE LINEKERNEL 169 | //!WIDTH HOOKED.w 4 / 170 | //!HEIGHT HOOKED.h 4 / 171 | //!COMPONENTS 1 172 | 173 | #define SPATIAL_SIGMA (0.25 * float(HOOKED_size.y) / 1080.0) //Spatial window size, must be a positive real number. 174 | 175 | #define KERNELSIZE (max(int(ceil(SPATIAL_SIGMA * 2.0)), 1) * 2 + 1) //Kernel size, must be an positive odd integer. 176 | #define KERNELHALFSIZE (int(KERNELSIZE/2)) //Half of the kernel size without remainder. Must be equal to trunc(KERNELSIZE/2). 177 | #define KERNELLEN (KERNELSIZE * KERNELSIZE) //Total area of kernel. Must be equal to KERNELSIZE * KERNELSIZE. 178 | 179 | float gaussian(float x, float s, float m) { 180 | float scaled = (x - m) / s; 181 | return exp(-0.5 * scaled * scaled); 182 | } 183 | 184 | float comp_gaussian_y() { 185 | 186 | float g = 0.0; 187 | float gn = 0.0; 188 | 189 | for (int i=0; i<KERNELSIZE; i++) { 190 | float di = float(i - KERNELHALFSIZE); 191 | float gf = gaussian(di, SPATIAL_SIGMA, 0.0); 192 | 193 | g = g + LINEKERNEL_texOff(vec2(0.0, di)).x * gf; 194 | gn = gn + gf; 195 | 196 | } 197 | 198 | return g / gn; 199 | } 200 | 201 | vec4 hook() { 202 | return vec4(comp_gaussian_y(), 0.0, 0.0, 0.0); 203 | } 204 | 205 | 206 | //!DESC Anime4K-v3.2-Darken-DoG-(VeryFast)-Upsample 207 | //!HOOK MAIN 208 | //!BIND HOOKED 209 | //!BIND LINEKERNEL 210 | 211 | #define STRENGTH 1.5 //Line darken proportional strength, higher is darker. 212 | 213 | vec4 hook() { 214 | //This trick is only possible if the inverse Y->RGB matrix has 1 for every row... (which is the case for BT.709) 215 | //Otherwise we would need to convert RGB to YUV, modify Y then convert back to RGB. 216 | return HOOKED_tex(HOOKED_pos) + (LINEKERNEL_tex(HOOKED_pos).x * STRENGTH); 217 | } 218 | 219 | -------------------------------------------------------------------------------- /mpv/shaders/Anime4K_Thin_VeryFast.glsl: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019-2021 bloc97 4 | // All rights reserved. 5 | 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | 24 | //!DESC Anime4K-v3.2-Thin-(VeryFast)-Luma 25 | //!HOOK MAIN 26 | //!BIND HOOKED 27 | //!SAVE LINELUMA 28 | //!WIDTH HOOKED.w 2 / 29 | //!HEIGHT HOOKED.h 2 / 30 | //!COMPONENTS 1 31 | 32 | float get_luma(vec4 rgba) { 33 | return dot(vec4(0.299, 0.587, 0.114, 0.0), rgba); 34 | } 35 | 36 | vec4 hook() { 37 | return vec4(get_luma(HOOKED_tex(HOOKED_pos)), 0.0, 0.0, 0.0); 38 | } 39 | 40 | //!DESC Anime4K-v3.2-Thin-(VeryFast)-Sobel-X 41 | //!HOOK MAIN 42 | //!BIND LINELUMA 43 | //!SAVE LINESOBEL 44 | //!WIDTH HOOKED.w 4 / 45 | //!HEIGHT HOOKED.h 4 / 46 | //!COMPONENTS 2 47 | 48 | vec4 hook() { 49 | float l = LINELUMA_texOff(vec2(-0.5, 0.0)).x; 50 | float c = LINELUMA_tex(LINELUMA_pos).x; 51 | float r = LINELUMA_texOff(vec2(0.5, 0.0)).x; 52 | 53 | float xgrad = (-l + r); 54 | float ygrad = (l + c + c + r); 55 | 56 | return vec4(xgrad, ygrad, 0.0, 0.0); 57 | } 58 | 59 | 60 | //!DESC Anime4K-v3.2-Thin-(VeryFast)-Sobel-Y 61 | //!HOOK MAIN 62 | //!BIND LINESOBEL 63 | //!SAVE LINESOBEL 64 | //!WIDTH HOOKED.w 4 / 65 | //!HEIGHT HOOKED.h 4 / 66 | //!COMPONENTS 1 67 | 68 | vec4 hook() { 69 | float tx = LINESOBEL_texOff(vec2(0.0, -0.25)).x; 70 | float cx = LINESOBEL_tex(LINESOBEL_pos).x; 71 | float bx = LINESOBEL_texOff(vec2(0.0, 0.25)).x; 72 | 73 | float ty = LINESOBEL_texOff(vec2(0.0, -0.25)).y; 74 | float by = LINESOBEL_texOff(vec2(0.0, 0.25)).y; 75 | 76 | float xgrad = (tx + cx + cx + bx) / 8.0; 77 | 78 | float ygrad = (-ty + by) / 8.0; 79 | 80 | //Computes the luminance's gradient 81 | float norm = sqrt(xgrad * xgrad + ygrad * ygrad); 82 | return vec4(pow(norm, 0.7)); 83 | } 84 | 85 | 86 | //!DESC Anime4K-v3.2-Thin-(VeryFast)-Gaussian-X 87 | //!HOOK MAIN 88 | //!BIND HOOKED 89 | //!BIND LINESOBEL 90 | //!SAVE LINESOBEL 91 | //!WIDTH HOOKED.w 4 / 92 | //!HEIGHT HOOKED.h 4 / 93 | //!COMPONENTS 1 94 | 95 | #define SPATIAL_SIGMA (0.5 * float(HOOKED_size.y) / 1080.0) //Spatial window size, must be a positive real number. 96 | 97 | #define KERNELSIZE (max(int(ceil(SPATIAL_SIGMA * 2.0)), 1) * 2 + 1) //Kernel size, must be an positive odd integer. 98 | #define KERNELHALFSIZE (int(KERNELSIZE/2)) //Half of the kernel size without remainder. Must be equal to trunc(KERNELSIZE/2). 99 | #define KERNELLEN (KERNELSIZE * KERNELSIZE) //Total area of kernel. Must be equal to KERNELSIZE * KERNELSIZE. 100 | 101 | float gaussian(float x, float s, float m) { 102 | float scaled = (x - m) / s; 103 | return exp(-0.5 * scaled * scaled); 104 | } 105 | 106 | float comp_gaussian_x() { 107 | 108 | float g = 0.0; 109 | float gn = 0.0; 110 | 111 | for (int i=0; i<KERNELSIZE; i++) { 112 | float di = float(i - KERNELHALFSIZE); 113 | float gf = gaussian(di, SPATIAL_SIGMA, 0.0); 114 | 115 | g = g + LINESOBEL_texOff(vec2(di, 0.0)).x * gf; 116 | gn = gn + gf; 117 | 118 | } 119 | 120 | return g / gn; 121 | } 122 | 123 | vec4 hook() { 124 | return vec4(comp_gaussian_x(), 0.0, 0.0, 0.0); 125 | } 126 | 127 | 128 | //!DESC Anime4K-v3.2-Thin-(VeryFast)-Gaussian-Y 129 | //!HOOK MAIN 130 | //!BIND HOOKED 131 | //!BIND LINESOBEL 132 | //!SAVE LINESOBEL 133 | //!WIDTH HOOKED.w 4 / 134 | //!HEIGHT HOOKED.h 4 / 135 | //!COMPONENTS 1 136 | 137 | #define SPATIAL_SIGMA (0.5 * float(HOOKED_size.y) / 1080.0) //Spatial window size, must be a positive real number. 138 | 139 | #define KERNELSIZE (max(int(ceil(SPATIAL_SIGMA * 2.0)), 1) * 2 + 1) //Kernel size, must be an positive odd integer. 140 | #define KERNELHALFSIZE (int(KERNELSIZE/2)) //Half of the kernel size without remainder. Must be equal to trunc(KERNELSIZE/2). 141 | #define KERNELLEN (KERNELSIZE * KERNELSIZE) //Total area of kernel. Must be equal to KERNELSIZE * KERNELSIZE. 142 | 143 | float gaussian(float x, float s, float m) { 144 | float scaled = (x - m) / s; 145 | return exp(-0.5 * scaled * scaled); 146 | } 147 | 148 | float comp_gaussian_y() { 149 | 150 | float g = 0.0; 151 | float gn = 0.0; 152 | 153 | for (int i=0; i<KERNELSIZE; i++) { 154 | float di = float(i - KERNELHALFSIZE); 155 | float gf = gaussian(di, SPATIAL_SIGMA, 0.0); 156 | 157 | g = g + LINESOBEL_texOff(vec2(0.0, di)).x * gf; 158 | gn = gn + gf; 159 | 160 | } 161 | 162 | return g / gn; 163 | } 164 | 165 | vec4 hook() { 166 | return vec4(comp_gaussian_y(), 0.0, 0.0, 0.0); 167 | } 168 | 169 | //!DESC Anime4K-v3.2-Thin-(VeryFast)-Kernel-X 170 | //!HOOK MAIN 171 | //!BIND LINESOBEL 172 | //!SAVE LINESOBEL 173 | //!WIDTH HOOKED.w 4 / 174 | //!HEIGHT HOOKED.h 4 / 175 | //!COMPONENTS 2 176 | 177 | vec4 hook() { 178 | float l = LINESOBEL_texOff(vec2(-0.25, 0.0)).x; 179 | float c = LINESOBEL_tex(LINESOBEL_pos).x; 180 | float r = LINESOBEL_texOff(vec2(0.25, 0.0)).x; 181 | 182 | float xgrad = (-l + r); 183 | float ygrad = (l + c + c + r); 184 | 185 | return vec4(xgrad, ygrad, 0.0, 0.0); 186 | } 187 | 188 | 189 | //!DESC Anime4K-v3.2-Thin-(VeryFast)-Kernel-Y 190 | //!HOOK MAIN 191 | //!BIND LINESOBEL 192 | //!SAVE LINESOBEL 193 | //!WIDTH HOOKED.w 4 / 194 | //!HEIGHT HOOKED.h 4 / 195 | //!COMPONENTS 2 196 | 197 | vec4 hook() { 198 | float tx = LINESOBEL_texOff(vec2(0.0, -0.25)).x; 199 | float cx = LINESOBEL_tex(LINESOBEL_pos).x; 200 | float bx = LINESOBEL_texOff(vec2(0.0, 0.25)).x; 201 | 202 | float ty = LINESOBEL_texOff(vec2(0.0, -0.25)).y; 203 | float by = LINESOBEL_texOff(vec2(0.0, 0.25)).y; 204 | 205 | float xgrad = (tx + cx + cx + bx) / 8.0; 206 | 207 | float ygrad = (-ty + by) / 8.0; 208 | 209 | //Computes the luminance's gradient 210 | return vec4(xgrad, ygrad, 0.0, 0.0); 211 | } 212 | 213 | 214 | //!DESC Anime4K-v3.2-Thin-(VeryFast)-Warp 215 | //!HOOK MAIN 216 | //!BIND HOOKED 217 | //!BIND LINESOBEL 218 | 219 | #define STRENGTH 0.6 //Strength of warping for each iteration 220 | #define ITERATIONS 1 //Number of iterations for the forwards solver, decreasing strength and increasing iterations improves quality at the cost of speed. 221 | 222 | vec4 hook() { 223 | vec2 d = HOOKED_pt; 224 | 225 | float relstr = HOOKED_size.y / 1080.0 * STRENGTH; 226 | 227 | vec2 pos = HOOKED_pos; 228 | for (int i=0; i<ITERATIONS; i++) { 229 | vec2 dn = LINESOBEL_tex(pos).xy; 230 | vec2 dd = (dn / (length(dn) + 0.01)) * d * relstr; //Quasi-normalization for large vectors, avoids divide by zero 231 | pos -= dd; 232 | } 233 | 234 | return HOOKED_tex(pos); 235 | 236 | } 237 | -------------------------------------------------------------------------------- /mpv/shaders/Anime4K_Upscale_Original_x2.glsl: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019-2021 bloc97 4 | // All rights reserved. 5 | 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | 24 | //!DESC Anime4K-v3.2-Upscale-Original-x2-Luma 25 | //!HOOK MAIN 26 | //!BIND HOOKED 27 | //!SAVE LINELUMA 28 | //!COMPONENTS 1 29 | 30 | float get_luma(vec4 rgba) { 31 | return dot(vec4(0.299, 0.587, 0.114, 0.0), rgba); 32 | } 33 | 34 | vec4 hook() { 35 | return vec4(get_luma(HOOKED_tex(HOOKED_pos)), 0.0, 0.0, 0.0); 36 | } 37 | 38 | //!DESC Anime4K-v3.2-Upscale-Original-x2-Kernel-X 39 | //!HOOK MAIN 40 | //!BIND HOOKED 41 | //!BIND LINELUMA 42 | //!SAVE LUMAD 43 | //!WIDTH MAIN.w 2 * 44 | //!HEIGHT MAIN.h 2 * 45 | //!COMPONENTS 2 46 | 47 | vec4 hook() { 48 | vec2 d = HOOKED_pt; 49 | 50 | //[tl t tr] 51 | //[ l c r] 52 | //[bl b br] 53 | float l = LINELUMA_tex(HOOKED_pos + vec2(-d.x, 0.0)).x; 54 | float c = LINELUMA_tex(HOOKED_pos).x; 55 | float r = LINELUMA_tex(HOOKED_pos + vec2(d.x, 0.0)).x; 56 | 57 | 58 | //Horizontal Gradient 59 | //[-1 0 1] 60 | //[-2 0 2] 61 | //[-1 0 1] 62 | float xgrad = (-l + r); 63 | 64 | //Vertical Gradient 65 | //[-1 -2 -1] 66 | //[ 0 0 0] 67 | //[ 1 2 1] 68 | float ygrad = (l + c + c + r); 69 | 70 | //Computes the luminance's gradient 71 | return vec4(xgrad, ygrad, 0.0, 0.0); 72 | } 73 | 74 | 75 | //!DESC Anime4K-v3.2-Upscale-Original-x2-Kernel-Y 76 | //!HOOK MAIN 77 | //!BIND HOOKED 78 | //!BIND LUMAD 79 | //!SAVE LUMAD 80 | //!WIDTH MAIN.w 2 * 81 | //!HEIGHT MAIN.h 2 * 82 | //!COMPONENTS 2 83 | 84 | 85 | /* --------------------- SETTINGS --------------------- */ 86 | 87 | //Strength of edge refinement, good values are between 0.2 and 4 88 | #define REFINE_STRENGTH 0.5 89 | 90 | 91 | /* --- MODIFY THESE SETTINGS BELOW AT YOUR OWN RISK --- */ 92 | 93 | //Bias of the refinement function, good values are between 0 and 1 94 | #define REFINE_BIAS 0.0 95 | 96 | //Polynomial fit obtained by minimizing MSE error on image 97 | #define P5 ( 11.68129591) 98 | #define P4 (-42.46906057) 99 | #define P3 ( 60.28286266) 100 | #define P2 (-41.84451327) 101 | #define P1 ( 14.05517353) 102 | #define P0 (-1.081521930) 103 | 104 | /* ----------------- END OF SETTINGS ----------------- */ 105 | 106 | float power_function(float x) { 107 | float x2 = x * x; 108 | float x3 = x2 * x; 109 | float x4 = x2 * x2; 110 | float x5 = x2 * x3; 111 | 112 | return P5*x5 + P4*x4 + P3*x3 + P2*x2 + P1*x + P0; 113 | } 114 | 115 | vec4 hook() { 116 | vec2 d = HOOKED_pt; 117 | 118 | //[tl t tr] 119 | //[ l cc r] 120 | //[bl b br] 121 | float tx = LUMAD_tex(HOOKED_pos + vec2(0.0, -d.y)).x; 122 | float cx = LUMAD_tex(HOOKED_pos).x; 123 | float bx = LUMAD_tex(HOOKED_pos + vec2(0.0, d.y)).x; 124 | 125 | 126 | float ty = LUMAD_tex(HOOKED_pos + vec2(0.0, -d.y)).y; 127 | //float cy = LUMAD_tex(HOOKED_pos).y; 128 | float by = LUMAD_tex(HOOKED_pos + vec2(0.0, d.y)).y; 129 | 130 | 131 | //Horizontal Gradient 132 | //[-1 0 1] 133 | //[-2 0 2] 134 | //[-1 0 1] 135 | float xgrad = (tx + cx + cx + bx); 136 | 137 | //Vertical Gradient 138 | //[-1 -2 -1] 139 | //[ 0 0 0] 140 | //[ 1 2 1] 141 | float ygrad = (-ty + by); 142 | 143 | //Computes the luminance's gradient 144 | float sobel_norm = clamp(sqrt(xgrad * xgrad + ygrad * ygrad), 0.0, 1.0); 145 | 146 | float dval = clamp(power_function(clamp(sobel_norm, 0.0, 1.0)) * REFINE_STRENGTH + REFINE_BIAS, 0.0, 1.0); 147 | 148 | return vec4(sobel_norm, dval, 0.0, 0.0); 149 | } 150 | 151 | //!DESC Anime4K-v3.2-Upscale-Original-x2-Kernel-X 152 | //!HOOK MAIN 153 | //!BIND HOOKED 154 | //!BIND LUMAD 155 | //!SAVE LUMAMM 156 | //!WIDTH MAIN.w 2 * 157 | //!HEIGHT MAIN.h 2 * 158 | //!COMPONENTS 2 159 | 160 | 161 | vec4 hook() { 162 | vec2 d = HOOKED_pt; 163 | 164 | if (LUMAD_tex(HOOKED_pos).y < 0.1) { 165 | return vec4(0.0); 166 | } 167 | 168 | //[tl t tr] 169 | //[ l c r] 170 | //[bl b br] 171 | float l = LUMAD_tex(HOOKED_pos + vec2(-d.x, 0.0)).x; 172 | float c = LUMAD_tex(HOOKED_pos).x; 173 | float r = LUMAD_tex(HOOKED_pos + vec2(d.x, 0.0)).x; 174 | 175 | //Horizontal Gradient 176 | //[-1 0 1] 177 | //[-2 0 2] 178 | //[-1 0 1] 179 | float xgrad = (-l + r); 180 | 181 | //Vertical Gradient 182 | //[-1 -2 -1] 183 | //[ 0 0 0] 184 | //[ 1 2 1] 185 | float ygrad = (l + c + c + r); 186 | 187 | 188 | return vec4(xgrad, ygrad, 0.0, 0.0); 189 | } 190 | 191 | 192 | //!DESC Anime4K-v3.2-Upscale-Original-x2-Kernel-Y 193 | //!HOOK MAIN 194 | //!BIND HOOKED 195 | //!BIND LUMAD 196 | //!BIND LUMAMM 197 | //!SAVE LUMAMM 198 | //!WIDTH MAIN.w 2 * 199 | //!HEIGHT MAIN.h 2 * 200 | //!COMPONENTS 2 201 | 202 | vec4 hook() { 203 | vec2 d = HOOKED_pt; 204 | 205 | if (LUMAD_tex(HOOKED_pos).y < 0.1) { 206 | return vec4(0.0); 207 | } 208 | 209 | //[tl t tr] 210 | //[ l cc r] 211 | //[bl b br] 212 | float tx = LUMAMM_tex(HOOKED_pos + vec2(0.0, -d.y)).x; 213 | float cx = LUMAMM_tex(HOOKED_pos).x; 214 | float bx = LUMAMM_tex(HOOKED_pos + vec2(0.0, d.y)).x; 215 | 216 | float ty = LUMAMM_tex(HOOKED_pos + vec2(0.0, -d.y)).y; 217 | //float cy = LUMAMM_tex(HOOKED_pos).y; 218 | float by = LUMAMM_tex(HOOKED_pos + vec2(0.0, d.y)).y; 219 | 220 | //Horizontal Gradient 221 | //[-1 0 1] 222 | //[-2 0 2] 223 | //[-1 0 1] 224 | float xgrad = (tx + cx + cx + bx); 225 | 226 | //Vertical Gradient 227 | //[-1 -2 -1] 228 | //[ 0 0 0] 229 | //[ 1 2 1] 230 | float ygrad = (-ty + by); 231 | 232 | float norm = sqrt(xgrad * xgrad + ygrad * ygrad); 233 | if (norm <= 0.001) { 234 | xgrad = 0.0; 235 | ygrad = 0.0; 236 | norm = 1.0; 237 | } 238 | 239 | return vec4(xgrad/norm, ygrad/norm, 0.0, 0.0); 240 | } 241 | 242 | 243 | //!DESC Anime4K-v3.2-Upscale-Original-x2-Apply 244 | //!HOOK MAIN 245 | //!BIND HOOKED 246 | //!BIND LUMAD 247 | //!BIND LUMAMM 248 | //!WIDTH MAIN.w 2 * 249 | //!HEIGHT MAIN.h 2 * 250 | 251 | 252 | vec4 hook() { 253 | vec2 d = HOOKED_pt; 254 | 255 | float dval = LUMAD_tex(HOOKED_pos).y; 256 | if (dval < 0.1) { 257 | return HOOKED_tex(HOOKED_pos); 258 | } 259 | 260 | vec4 dc = LUMAMM_tex(HOOKED_pos); 261 | if (abs(dc.x + dc.y) <= 0.0001) { 262 | return HOOKED_tex(HOOKED_pos); 263 | } 264 | 265 | float xpos = -sign(dc.x); 266 | float ypos = -sign(dc.y); 267 | 268 | vec4 xval = HOOKED_tex(HOOKED_pos + vec2(d.x * xpos, 0.0)); 269 | vec4 yval = HOOKED_tex(HOOKED_pos + vec2(0.0, d.y * ypos)); 270 | 271 | float xyratio = abs(dc.x) / (abs(dc.x) + abs(dc.y)); 272 | 273 | vec4 avg = xyratio * xval + (1.0 - xyratio) * yval; 274 | 275 | return avg * dval + HOOKED_tex(HOOKED_pos) * (1.0 - dval); 276 | 277 | } 278 | --------------------------------------------------------------------------------