diff --git a/custom/aliases.zsh b/custom/aliases.zsh index e0cb15b..99ede65 100644 --- a/custom/aliases.zsh +++ b/custom/aliases.zsh @@ -1,3 +1,9 @@ +# 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' diff --git a/custom/segments.zsh b/custom/segments.zsh index af1de44..ef5f0eb 100644 --- a/custom/segments.zsh +++ b/custom/segments.zsh @@ -1,8 +1,8 @@ -function prompt_docker_host() { +function prompt_c_docker_host() { p10k segment -b blue -i '' -t "${DOCKER_HOST#*://}" -c "${DOCKER_HOST#*://}" } typeset -g POWERLEVEL9K_DOCKER_HOST_SHOW_ON_COMMAND='docker' -function prompt_new_mail() { +function prompt_c_new_mail() { if [ ! -v _cprompts_mail_count ]; then local new_mails=(~/Mail/*/Inbox/new/*(.N)) typeset -g _cprompts_mail_count=${#new_mails} @@ -10,14 +10,14 @@ function prompt_new_mail() { [[ ${_cprompts_mail_count} -gt 0 ]] || return p10k segment -b yellow -i '' -t "${_cprompts_mail_count:-unknown}" } -function prompt_youtube() { +function prompt_c_youtube() { local newsboatdb=~/.newsboat/cache.db if [ ! -v _cprompts_youtube ]; then typeset -g _cprompts_youtube="$(sqlite3 ${newsboatdb} --ascii 'SELECT COUNT(id) FROM rss_item WHERE unread == 1 AND guid GLOB "yt:video:*"')" fi p10k segment -b red -i '' -t "${_cprompts_youtube}" } -function prompt_covid_19() { +function prompt_c_covid_19() { local tmpfile=${CACHEPATH}/covid local -a stats if [ ! -v _cprompts_covid ]; then @@ -31,7 +31,7 @@ function prompt_covid_19() { fi p10k segment -b red -i '' -t "${_cprompts_covid:-unknown}" } -function prompt_weather() { +function prompt_c_weather() { local tmpfile=${CACHEPATH}/weather local -a stats @@ -75,10 +75,31 @@ function prompt_weather() { p10k segment -b ${_cprompts_weather[2]:-white} -i ${_cprompts_weather[3]:-\?} -t "${_cprompts_weather[1]:-unknown}" } -function prompt_mpv_mpris() { +function prompt_c_mpv_mpris() { 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:artist".data[0] // empty) + " - " + (.data."xesam:title".data // empty))')" + format='((.data."xesam:artist".data[0] // empty) + " - " + (.data."xesam:title".data // empty))' + _cprompts_mpv="$(print $busout | jq -er $format)" [ -z $_cprompts_mpv ] || p10k segment -b magenta -i '' -t "${_cprompts_mpv:0:40}$([ ${#_cprompts_mpv} -gt 40 ] && print ...)" } +function prompt_c_todo() { + [ -r todo.txt ] || return + local -a stats + zstat -A stats +mtime -- todo.txt 2>/dev/null + if [ ! -v _cprompts_todo ] || [ $_cprompts_todo[4] -ne $stats[1] ]; then + local IFS=$'\n' + local todofi=($(< todo.txt)) + local t_nf=0 + local t_f=0 + local colors=(red yellow green) + for i in $todofi; do + [ ${i:0:1} = "-" ] && ((t_nf++)) + [ ${i:0:1} = "+" ] && ((t_f++)) + done + local t_tot=$(($t_f+$t_nf)) + [ $t_tot -gt 0 ] || return + typeset -g _cprompts_todo=($t_f $t_tot ${colors[$(( 1+int( $t_f / $t_tot.0 * 2 ) ))]} $stats[1]) + fi + p10k segment -b ${_cprompts_todo[3]:-white} -i '' -t "${_cprompts_todo[1]:-unknown} / ${_cprompts_todo[2]:-unknown}" +} diff --git a/powerlevel-config/misc.zsh b/powerlevel-config/misc.zsh index e73e921..4722af8 100644 --- a/powerlevel-config/misc.zsh +++ b/powerlevel-config/misc.zsh @@ -1,6 +1,6 @@ typeset -g POWERLEVEL9K_DISABLE_HOT_RELOAD=true typeset -g POWERLEVEL9K_MODE=nerdfont-complete typeset -g POWERLEVEL9K_ICON_PADDING=none -typeset -g POWERLEVEL9K_TRANSIENT_PROMPT=same-dir +typeset -g POWERLEVEL9K_TRANSIENT_PROMPT=always typeset -g POWERLEVEL9K_INSTANT_PROMPT=quiet typeset -g POWERLEVEL9K_USE_CACHE=true diff --git a/powerlevel-config/prompt-elements.zsh b/powerlevel-config/prompt-elements.zsh index e1aeff6..9765ace 100644 --- a/powerlevel-config/prompt-elements.zsh +++ b/powerlevel-config/prompt-elements.zsh @@ -12,19 +12,18 @@ typeset -g POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=( dir dir_writable ) -typeset -g POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=( -) +typeset -g POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=() if [ ! -v SSH_CONNECTION ]; then POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS+=( - mpv_mpris - new_mail -# youtube - weather - covid_19 + c_mpv_mpris + c_todo + c_new_mail +# c_youtube + c_weather + c_covid_19 ) fi POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS+=( - public_ip newline command_execution_time background_jobs