Update autoloads, move some aliases, use cuda, use here strings, improve mpv latency, update commits

This commit is contained in:
Alex 2020-07-19 00:43:39 +02:00
parent dc4c2b037e
commit 12bc8dff99
Signed by: caskd
GPG Key ID: F92BA85F61F4C173
16 changed files with 23 additions and 42 deletions

View File

@ -54,10 +54,3 @@ if (( ${+terminfo[smkx]} && ${+terminfo[rmkx]} )); then
add-zle-hook-widget -Uz zle-line-init zle_application_mode_start
add-zle-hook-widget -Uz zle-line-finish zle_application_mode_stop
fi
function edit-buffer() {
BUFFER="${EDITOR:-vi} $BUFFER"
zle accept-line
}
zle -N edit-buffer
bindkey -- '^E' edit-buffer # Quick edit

View File

@ -15,4 +15,4 @@ zstyle ':completion:*:approximate:*' max-errors 1 numeric
zstyle ':completion:*:functions' ignored-patterns '_*'
zstyle ':completion:*:descriptions' format '%U%B%d%b%u'
zstyle ':completion:*:warnings' format '%BSorry, no matches for: %d%b'
autoload -Uz +X compinit && compinit
autoload -Uz compinit && compinit

View File

@ -2,6 +2,7 @@ source "${ZDOTDIR}/custom/prependsudo.zsh"
source "${ZDOTDIR}/custom/aliases.zsh"
source "${ZDOTDIR}/custom/gpg.zsh"
fpath+=("${ZDOTDIR}/custom/functions" "${ZDOTDIR}/custom/segments")
function {prompt_c_{covid_19,docker_host,mpv_mpris,new_mail,todo,weather,newsboat,mumble,sfeed},cprompts:cache:async:{covid,weather,rss},get{mangareader,nhentai},gitsubrepo,osutab,ffmpeg-{compress,gif}}() {
compdef _files mplay
function {prompt_c_{covid_19,docker_host,mpv_mpris,new_mail,todo,weather,newsboat,mumble,sfeed},cprompts:cache:async:{covid,weather,rss},get{gbooru,mangareader,nhentai},gitsubrepo,osutab,ffmpeg-{compress,gif},prettygitlog,paste,mplay,qff}() {
autoload -X
}

View File

@ -1,12 +1,5 @@
# Technically a alias on steroids
function mplay() {
busctl call --no-pager --user org.mpris.MediaPlayer2.mpv /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player OpenUri s "$1"
}
compdef _files mplay
alias recordscreen='ffmpeg -hwaccel vdpau -video_size 1920x1080 -framerate 60 -f x11grab -i :0 -c:v libx264rgb -crf 0 -preset ultrafast -movflags +faststart -tune zerolatency'
alias ytdldown='youtube-dl --no-part --newline -ixcw -R infinite -f bestaudio/best --add-metadata --embed-thumbnail -o "/home/caskd/Media/Music/%(album)s/%(track_number)s - %(track)s.%(ext)s"'
alias ls='ls --color=auto'
alias grep='grep --color=auto'
alias diff='diff --color=auto'
alias paste="curl -F'file=@-'"

View File

@ -1 +1 @@
ffmpeg -hwaccel vdpau -i $1 -vf "normalize,scale=480:-1:flags=spline,mpdecimate" $2
ffmpeg -hwaccel cuda -i $1 -c:v h264 -crf 30 -vf "normalize,scale=480:-1:flags=spline,mpdecimate" $2

View File

@ -1,4 +1,4 @@
local pageinfo="$(curl -sL $1 | grep -oP '(?<=var gallery = new N.gallery\().*(?=\);)' | jq '{"pages": .num_pages,"id": .media_id, "types": [.images.pages[].t], "title": .title.pretty}')"
local pageinfo=$(print $(curl -sL $1 | grep -oP '(?<=window._gallery = JSON.parse\(").*(?="\);)') | jq '{"pages": .num_pages,"id": .media_id, "types": [.images.pages[].t], "title": .title.pretty}')
local media_id=$(print $pageinfo | jq -r '.id')
local types=($(print $pageinfo | jq -r '.types[]'))
local num_pages=$(print $pageinfo | jq '.pages')

View File

@ -1 +1 @@
xinput set-prop 'UGTABLET 6 inch PenTablet Pen (0)' --type=float 153 3.5 0 -0.5 0 2.9 0 0 0 1
xinput --set-float-prop 'UGTABLET 6 inch PenTablet Pen (0)' 'Coordinate Transformation Matrix' 3.5 0 -0.5 0 2.9 0 0 0 1

View File

@ -6,7 +6,7 @@ for f in $feedpath/*; do
for l in ${content[@]}; do
local IFS=$'\t'
local options=($l)
[[ ${options[6]:0:9} == "yt:video:" ]] && [ $options[1] -gt $(($epochtime[1]-14400)) ] && ((count++))
[[ ${options[6]:0:9} == "yt:video:" ]] && [ $options[1] -gt $(($epochtime[1] - 14400)) ] && ((count++))
done
done
print $count > $tmpfile

View File

@ -3,6 +3,6 @@ zstyle -s ':custom:prompts:weather' location REPLY
local result=$(curl -sL https://www.metaweather.com/api/location/${REPLY:-1339615}/ | jq -e '.consolidated_weather[0] | {"temp": .the_temp, "icon": .weather_state_abbr}')
if [ ! -z $result ]; then
local ico=$(print $result | jq -r '.icon')
typeset -g _cprompts_weather=($(print $result | jq -r '.temp') ${colors[$ico]} ${icons[$ico]:-?})
typeset -g _cprompts_weather=($(jq -r '.temp' <<< $result) ${colors[$ico]:-white} ${icons[${ico:-X}]})
print ${_cprompts_weather%%.*} > $tmpfile
fi

View File

@ -5,7 +5,7 @@ zstyle -s ':custom:prompts:covid' country REPLY
local -a stats
if [ ! -v _cprompts_covid ]; then
zstat -A stats +mtime -- $tmpfile 2>/dev/null
if [ $stats[1] -lt $(($epochtime[1]-86400)) ]; then
if [ ${stats[1]:-0} -lt $(($epochtime[1]-86400)) ]; then
cprompts:cache:async:covid &!
else
typeset -g _cprompts_covid=$(< $tmpfile)

View File

@ -1,6 +1,4 @@
([ -v commands\[busctl\] ] && [ -v commands\[jq\] ]) || return
typeset -g _cprompts_mpv
local busout="$(busctl get-property -j --no-pager --timeout=300ms --user org.mpris.MediaPlayer2.mpv /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player Metadata 2>/dev/null)"
[ -z $busout ] && return
_cprompts_mpv="$(print $busout | jq -er '(.data."xesam:title".data // empty)')"
[ -z $_cprompts_mpv ] || p10k segment -b magenta -i '' -t "${_cprompts_mpv:0:20}$([ ${#_cprompts_mpv} -gt 20 ] && print ...)"
zsocket ~/.mpvsock
typeset -ga _cprompts_mpv=($REPLY)
_cprompts_mpv[2]="${${$(print -u $_cprompts_mpv[1] '{ "command": ["get_property", "media-title"] }' && read -Eu $_cprompts_mpv[1])#*\"data\"*:*\"}%%\"*}"
[ -z $_cprompts_mpv[2] ] || p10k segment -b magenta -i '' -t "${_cprompts_mpv[2]:0:20}$([ ${#_cprompts_mpv[2]} -gt 20 ] && print ...)"

View File

@ -1,14 +1,10 @@
setopt local_options nomatch
feedpath=~/.sfeed/feeds/
tmpfile=$CACHEPATH/rss
local tmpfile=$CACHEPATH/rss
[ -r $feedpath ] || return
local -a rss
local -a cache
zstat -A rss +mtime -- $feedpath/* 2>/dev/null
zstat -A cache +mtime -- $tmpfile 2>/dev/null
if [ -r $tmpfile ]; then
([ ! -v _cprompts_sfeed ] || [ $rss[1] -gt $cache[1] ]) && cprompts:cache:async:rss &!
typeset -g _cprompts_sfeed=$(< $tmpfile)
else
cprompts:cache:async:rss &!
fi
([ ! -v _cprompts_sfeed ] || [ ${cache[1]:-0} -lt $(($epochtime[1] - 1800)) ]) && cprompts:cache:async:rss &!
[ -r $tmpfile ] || return
typeset -g _cprompts_sfeed=$(< $tmpfile)
[ ${_cprompts_sfeed:-0} -ne 0 ] && p10k segment -b red -i '' -t "+${_cprompts_sfeed:-unknown}"

View File

@ -1,5 +1,5 @@
([ -v commands\[curl\] ] && [ -v commands\[jq\] ]) || return
local tmpfile=${CACHEPATH}/weather
local tmpfile=$CACHEPATH/weather
local -a stats
# Fancy stuff
@ -28,7 +28,7 @@ colors[sn]="white"
if [ ! -v _cprompts_weather ]; then
zstat -A stats +mtime -- $tmpfile 2>/dev/null
if [ $stats[1] -lt $(($epochtime[1]-21600)) ]; then
if [ ${stats[1]:-0} -lt $(($epochtime[1]-21600)) ]; then
cprompts:cache:async:weather &!
else
typeset -g _cprompts_weather=($(< $tmpfile))

@ -1 +1 @@
Subproject commit 6b69030bfb6fff74733f58aa493e7b2b41c8ae6b
Subproject commit 6c9d0977a6378239f4153f5d3700bc5f70b36c3d

View File

@ -1,5 +1,5 @@
typeset -g HISTFILE=~/.histfile
typeset -g CACHEPATH=/tmp
typeset -g CACHEPATH=~/.cache
typeset -g HISTSIZE=1000
typeset -g SAVEHIST=1000
typeset -g ZLE_RPROMPT_INDENT=0

@ -1 +1 @@
Subproject commit f8b1470314be9fd25df90fa40d45c727c193ba96
Subproject commit fb929edc30192407a9298aad64f55ca1b19a464e