Skip to content

Commit b27c76e

Browse files
committed
add shell examples
1 parent 98ae253 commit b27c76e

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,3 +191,30 @@ mpv-history-daemon merge ~/data/mpv --move ~/.cache/mpv_removed --write-to ~/dat
191191
That takes any eligible files in `~/data/mpv` (merged or new event files), merges them all into `~/data/mpv/merged-...json` (unique filename using the date), and then moves all the files that were merged to `~/.cache/mpv_removed` (moving them to some temporary directory so you can review the merged file, instead of deleting)
192192

193193
My personal script which does this is synced up [here](https://github.com/purarue/bleanser/blob/master/bin/merge-mpv-history)
194+
195+
### Other Example Usage
196+
197+
Through [HPI](https://github.com/purarue/HPI), I have some [shell functions](https://github.com/purarue/HPI/blob/3a97ce376721dd01db5bb33fe296c4d5219a9a9d/scripts/functions.sh#L33-L49) that query this data, e.g. letting me replay the most recently played song:
198+
199+
```bash
200+
alias mpv-from-stdin='mpv --playlist=- --no-audio-display --msg-level=file=error'
201+
# list mpv files I've played recently
202+
mpv-recent() {
203+
local args=()
204+
if [[ -n "$1" ]]; then
205+
args+=("--limit" "$1")
206+
207+
fi
208+
hpi query my.mpv.history_daemon.history --order-type datetime --reverse -s "${args[@]}"
209+
}
210+
mpv-recent-path() {
211+
mpv-recent "$1" | jq -r .path
212+
}
213+
# just replays the most recent song
214+
alias replay='mpv-recent-path 1 | mpv-from-stdin'
215+
# requires https://github.com/purarue/exists, https://github.com/purarue/pura-utils
216+
# prompts me with ~30 recently played songs, lets me pick which one to play
217+
replay-recent() {
218+
mpv-recent-path "$1" | exists | head -n "${1:-$LINES}" | unique | fzf | mpv-from-stdin
219+
}
220+
```

0 commit comments

Comments
 (0)