initial dotfiles

This commit is contained in:
srtk 2026-04-25 16:39:11 +05:30
commit 45e5fe53d2
370 changed files with 25449 additions and 0 deletions

View file

@ -0,0 +1,22 @@
The MIT License (MIT)
Copyright © 2024
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the “Software”), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View file

@ -0,0 +1,29 @@
# audio-preview.yazi
A plugin for [yazi](https://github.com/sxyazi/yazi) to preview soundfiles as spectrogram
using sox
## Requirements
- `sox`
## Installation
```sh
ya pack -a 'gesellkammer/audio-preview'
```
## Usage
Add this to your `yazi.toml`:
```toml
[plugin]
prepend_previewers = [
{ mime = "audio/*", run = "audio-preview" },
]
prepend_preloaders = [
{ mime = "audio/*", run = "audio-preview" },
]
```

View file

@ -0,0 +1,63 @@
local M = {}
function M:peek(job)
local start, cache = os.clock(), ya.file_cache(job)
if not cache or self:preload() ~= 1 then
return
end
ya.sleep(math.max(0, 0.1 + start - os.clock()))
ya.image_show(cache, job.area)
ya.preview_widgets(job, {})
end
function M:seek(job, units)
local h = cx.active.current.hovered
if h and h.url == job.file.url then
local step = ya.clamp(-1, units, 1)
ya.manager_emit("peek", { math.max(0, cx.active.preview.skip + step), only_if = job.file.url })
end
end
function M:preload(job)
ya.dbg("Preloading audio-preview ***")
if not job then
return 1
end
local percentage = 5 + job.skip
if percentage > 95 then
ya.manager_emit("peek", { 90, only_if = job.file.url, upper_bound = true })
return 2
end
local cache = ya.file_cache(job)
if not cache then
return 1
end
local cha = fs.cha(cache)
if cha and cha.len > 0 then
return 1
end
-- generate image
ya.err("Calling sox for: " .. tostring(job.file.url) .. ", cache: " .. tostring(cache))
local child, code = Command("sox")
:arg({tostring(job.file.url),
"-n", "trim", "0:00", "1:00",
"remix", "1",
"rate", "12k",
"spectrogram",
"-o", tostring(cache)})
:spawn()
if not child then
ya.err("spawn `sox` command returns " .. tostring(code))
return 0
end
local status = child:wait()
return status and status.success and 1 or 2
end
return M