2 ms·
Here's my script for playing videos in a folder. The command is , (comma) When you download a video from certain sites, ctime is the time you created the file
by nextaccountic 4y ago
Here's my script for playing videos in a folder. The command is , (comma)
When you download a video from certain sites, ctime is the time you created the file (so the time you downloaded) but the video still comes with a timestamp which is saved as the mtime (I'm not sure why this happens, maybe there's a http header for that?), and I presume it's the time when the video was first uploaded to the site?
Here's a favorite of mine: all my scripts' -h simply show the source code
$ cat $(which ,)
#!/bin/sh
#export DRI_PRIME=1
cmd=mpv
param='-fs --msg-level=all=no,cplayer=info'
filter='/Playing/!d; s/^Playing: //'
order='%C@' # by default, order by ctime
sort=-n # (which is a numeric sort)
reverse=-r # ... show newer videos first
depth= # ... and do it recursively
loop= # ... without looping
[[ -n $MYT_MUTE ]] && set -- -u "$@"
[[ -n $MYT_1 ]] && set -- -1 "$@"
[[ -n $MYT_REC ]] && set -- -r "$@"
while getopts 1rcmsaRnolugh o; do
case "$o" in
1) depth='-maxdepth 1';; # just the current directory
r) depth=;; # recursively
# a video uploaded in 2009 but downloaded in 2015 will have
# mtime in 2009 and ctime in 2015
#
# (note: moving the video to another directory actually bumps
# the ctime)
c) order='%C@'; sort=-n;; # order by ctime (download time)
m) order='%T@'; sort=-n;; # order by mtime (upload time)
s) order='%s'; sort=-n;; # order by size
a) order='alpha'; sort=;; # order lexicographically
R) order='random'; sort=-n;; # order at random
n) reverse=-r;; # newer first
o) reverse=;; # older first
l) loop=--loop=inf;; # infinite loop
u) mute=--mute=yes;; # no sound
g) filter=; param=;; # debug
h) ${PAGER-less} "$0"; exit;;
esac
done
shift $((OPTIND-1))
find -L "$@" $depth -mindepth 0 \
-not -path '*/\.*' \
-type f \
-name '*.*' \
-printf "$order %p\0" \
| awk 'BEGIN { RS="\0"; srand() } {
if ($1 == "random")
sub ($1, int(rand()*100000));
printf "%s\0", $0
}' \
| sort -z $sort $reverse \
| sed -zr 's/^[^ ]+ //' \
| xargs -0 $cmd $loop $mute $param 2>&1 \
| sed "$filter"
# -exec $cmd {} + | sed "$sed"
- nextaccountic 4y agoAlso here's a emacs lisp snippet for window switching that I never managed to publish but I just can't use emacs without it. With it I press super+left and super+right to cycle windows such that if I'm on a non-asterisk buffer, it cycles only through such kind of buffer (and scratch), but if I'm on an asterisk* buffer (except scratch), it cycles only through asterisk buffers, skipping some bad buffers. And super+up goes to a non-asterisk buffer, and super+down goes to an asterisk buffer: https://github.com/dlight/dotemacs/blob/master/bindings.el#L274 https://github.com/dlight/dotemacs/blob/master/bindings.el#L... This is brittle-looking but I didn't know how to test if a buffer is special other than checking the buffer name (I'm sure there's a better way). Anyway I kept looking if emacs already had this, but apparently not Maybe someone will think it is useful so: (defun keys (a) (when a (global-set-key (read-kbd-macro (nth 0 a)) (nth 1 a)) (keys (cddr a)))) (keys '( "<s-left>" my-previous-buffer "<s-right>" my-next-buffer "<s-up>" next-regular-buffer "<s-down>" previous-star-buffer )) (defun switch-to-previous-buffer () (interactive) (switch-to-buffer (other-buffer))) (defun matching-buffer () ;(string-match "^\\*.*\\*$" (buffer-name))) (string-match "^\\*.*$" (buffer-name))) (defun my-next-buffer () (interactive) (if (matching-buffer) (next-star-buffer) (next-regular-buffer))) (defun my-previous-buffer () (interactive) (if (matching-buffer) (previous-star-buffer) (previous-regular-buffer))) (defun next-regular-buffer () (interactive) (next-buffer) (if (matching-buffer) (next-regular-buffer))) (defun next-regular-buffer-or-scratch () (interactive) (next-buffer) (if (and (matching-buffer) (not (equal "*scratch*" (buffer-name)))) (next-regular-buffer-or-scratch))) (defun previous-regular-buffer () (interactive) (previous-buffer) (if (matching-buffer) (previous-regular-buffer))) (defun bad-buffer (a) (member a '("*Backtrace*" "*Completions*" "*Messages*" "*Help*" "*Egg:Select Action*"))) (defun next-star-buffer () (interactive) (next-buffer) (if (or (not (matching-buffer)) (bad-buffer (buffer-name))) (next-star-buffer))) (defun previous-star-buffer () (interactive) (previous-buffer) (if (or (not (matching-buffer)) (bad-buffer (buffer-name))) (previous-star-buffer)))
- crtasm 4y ago