Compare commits

...

9 commits

13 changed files with 175 additions and 12 deletions

View file

@ -5,6 +5,7 @@
# Detect if we have GNU coreutils or BSD
if date --version > /dev/null 2>&1 ;then
alias ls='ls --classify --tabsize=0 --literal --color=auto --show-control-chars -h'
alias lh='ls -trhgGN --color=always | cut -d" " -f3-' # List files in chronological order
alias diff='diff --color'
alias less='less --quiet'
alias grep="grep --color"

View file

@ -19,7 +19,7 @@ else
clip="$(wl-paste)"
fi
urls="$(echo $clip | grep -o 'https\?://[a-zA-Z0-9~#%&_+=,.?/-]\+')"
urls="$(echo $clip | grep -o 'https\?://[a-zA-Z0-9~#%&_+=,.?@/-]\+')"
# Check the requirements for every option
opts="fav|rot13"
@ -33,6 +33,7 @@ if [ -n "$urls" ] && check_exists "yt-dlp"; then
check_exists "lncrawl" && opts="crawl|$opts"
else
check_exists "mpv" && opts="play|low-play|$opts"
check_exists "mpc" && opts="queue|$opts"
opts="download|$opts"
fi
fi
@ -74,6 +75,10 @@ case "$choice" in
"low-play")
playvideo -l "$clip"
;;
"queue")
out="$(mpdurlqueue "$urls" 2>&1)" && notify-send "cliplumber" "stream queued"
printf "%s" "$out" | grep "ERROR:" | notify_err
;;
"audio-search")
"$TERM_EMU" --single-instance mpv --ytdl-format=bestaudio ytdl://ytsearch:"$clip"
;;

61
bin/mpdurlqueue Executable file
View file

@ -0,0 +1,61 @@
#!/usr/bin/env python3
"""
A simple script to pipe URIs through yt-dlp and mpd
Credit: https://gist.github.com/phaer/86bdcc3fb59cd3fcd9534bfe84d9fe5f
"""
import sys
import mpd
import yt_dlp
mpd_host = ('localhost', 6600)
ydl_opts = {
'format': 'bestaudio/audio',
'quiet': True,
}
if __name__ == '__main__':
if len(sys.argv) != 2:
print("usage: {} <url>".format(sys.argv[0]), file=sys.stderr)
sys.exit(1)
source_url = sys.argv[1]
client = mpd.MPDClient()
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
try:
info = ydl.extract_info(source_url, process=False, download=False)
except yt_dlp.utils.DownloadError:
# Don't print anything, yt-dlp is already on it
sys.exit(1)
if info.get("_type") is not None and info.get("_type") == "playlist":
print("Queuing playlists not supported yet.", file=sys.stderr)
sys.exit(1)
info = ydl.process_ie_result(info, download=False)
url = info.get('url')
title = info.get('title')
source = info.get('extractor_key')
# This info is only available for songs
# that have been tagged as such on youtube
artist = info.get('artist')
if not (url and title and source):
print("youtube-dl error.", file=sys.stderr)
sys.exit(1)
client.connect(*mpd_host)
# Get current playing song index and then append the stream just after
# This is analogous to `mpc insert <song>`
pos = int(client.status()["song"])
song_id = client.addid(url, pos + 1)
client.addtagid(song_id, 'title', title)
client.addtagid(song_id, 'album', source)
if artist is not None:
client.addtagid(song_id, 'artist', artist)
client.disconnect()

View file

@ -6,5 +6,6 @@ set trash = "+$my_account/Trash"
macro index,pager gs "<shell-escape>mbsync $my_mbsync_conf $my_account<enter>" "IMAP sync account"
macro index,pager gi "<shell-escape>mbsync $my_mbsync_conf $my_account:INBOX<enter>" "IMAP sync Inbox"
macro index,pager gf "<shell-escape>fdm fetch -a $my_account<enter>" "fdm filter mailbox"
# vim: syntax=neomuttrc

42
config/neomutt/extract-reply.sh Executable file
View file

@ -0,0 +1,42 @@
#!/bin/sh
set -euo pipefail
text="$(cat)"
# Extract only the text/html part of the multipart email
# TODO parse actual encoding instead of defaulting to iso-8859-1
mailto="$(printf "%s" "$text" \
| awk '
boundary {
if ($0 ~ boundary) {
boundary = "";
next
}
print $0
}
/Content-Type: text\/html;/ {
boundary=line
}
{
line=$0
}' \
| qprint -d \
| iconv -f iso-8859-1 -t utf-8 \
| grep -Eo '<a href="mailto:.*?</a>')"
to="$(printf "%s" "$mailto" | sed -En 's/.*mailto:(.*?)\?subject=.*/\1/p')"
subject="$(printf "%s" "$mailto" | sed -En 's/.*\?subject=(.*?)" .*/\1/p')"
# TODO extract original To: to emulate use_envelope_from
datadir="${XDG_DATA_HOME:-"$HOME/.local/share"}/neomutt"
mkdir -p "$datadir"
format_str="unmy_hdr To: Subject:
my_hdr To: \"%s\"
my_hdr Subject: \"%s\"
echo \`rm \"%s\"\`"
printf "$format_str" "$to" "$subject" "$datadir/info.rc" > "$datadir/info.rc"

View file

@ -55,6 +55,13 @@ bind pager gh display-toggle-weed
bind pager ge extract-keys
macro pager gu "<pipe-message> urlscan <enter>"
# Answer emails with a reply address in the body
# https://unix.stackexchange.com/a/586010/248368
macro pager gr "<pipe-message> ~/.config/neomutt/extract-reply.sh <enter>\
<enter-command>source ~/.local/share/neomutt/info.rc <enter>\
<mail><enter><enter><enter>"
# Use a hook to reset sender and subject just after creating the reply
send-hook . 'unmy_hdr To: Subject:'
##########
# ATTACH #

View file

@ -4,10 +4,3 @@ set folder = "~/mail"
set my_msmtp_conf = "" # Leave empty for default
set my_mbsync_conf = "" # Leave empty for default
source common.rc
# Override sidebar_new_mail_only
# Move back to sidebar.rc once the issue is resolved
# https://github.com/neomutt/neomutt/issues/2208
sidebar_whitelist `find $folder -mindepth 1 -maxdepth 1 -type d ! -name cur ! -name tmp ! -name new ! -name .notmuch -printf '"%f"\0' | xargs -0`
sidebar_whitelist `find $folder -mindepth 1 -maxdepth 1 -type d ! -name cur ! -name tmp ! -name new ! -name .notmuch -printf '"%p"\0' | xargs -0`
sidebar_whitelist `find ~/mail -mindepth 1 -type d -iname inbox -printf '"%p"\0' | xargs -0`

View file

@ -13,4 +13,9 @@ unset sidebar_next_new_wrap # wrap <sidebar-{next,prev}-new> to beginnin
unset sidebar_on_right # keep bar on the left
set sidebar_sort_method = 'path' # sort by mailbox path alphabetically
# Override sidebar_new_mail_only
sidebar_whitelist `find $folder -mindepth 1 -maxdepth 1 -type d ! -name cur ! -name tmp ! -name new ! -name .notmuch -printf '"%f"\0' | xargs -0`
sidebar_whitelist `find $folder -mindepth 1 -maxdepth 1 -type d ! -name cur ! -name tmp ! -name new ! -name .notmuch -printf '"%p"\0' | xargs -0`
sidebar_whitelist `find $folder -mindepth 1 -type d -iname inbox -printf '"%p"\0' | xargs -0`
# vim: syntax=neomuttrc

View file

@ -1,11 +1,12 @@
#!/usr/bin/perl
# CLI Pipe Viewer 0.1.5 - configuration file
# CLI Pipe Viewer 0.2.1 - configuration file
our $CONFIG = {
api_host => "auto",
auto_captions => 0,
autoplay_mode => 0,
bypass_age_gate_with_proxy => 0,
cache_dir => "$ENV{HOME}/.cache/pipe-viewer",
colors => 1,
comments_order => "top",
@ -44,6 +45,7 @@ our $CONFIG = {
debug => 0,
download_and_play => 0,
download_with_wget => 1,
download_with_ytdl => 1,
downloads_dir => ".",
env_proxy => 1,
fat32safe => 0,
@ -63,6 +65,7 @@ our $CONFIG = {
ignored_projections => [],
interactive => 1,
keep_original_video => 0,
local_playlist_limit => -1,
maxResults => 20,
merge_into_mkv => 1,
merge_into_mkv_args => "-loglevel warning -c:s srt -c:v copy -c:a copy -disposition:s forced",
@ -76,12 +79,14 @@ our $CONFIG = {
region => undef,
remove_played_file => 0,
resolution => "720p",
saved_channels_file => "$ENV{HOME}/.config/pipe-viewer/users.txt",
show_video_info => 1,
skip_if_exists => 1,
skip_watched => 0,
split_videos => 1,
srt_languages => ["en", "fr"],
subscribed_channels_file => "$ENV{HOME}/.config/pipe-viewer/subscribed_channels.txt",
subscriptions_lifetime => 600,
subscriptions_limit => 10000,
thousand_separator => ",",
timeout => undef,
@ -112,10 +117,12 @@ our $CONFIG = {
videoDuration => undef,
videoLicense => undef,
watch_history => 1,
watched_file => "$ENV{HOME}/.config/pipe-viewer/watched.txt",
watch_history_file => "$ENV{HOME}/.config/pipe-viewer/watched.txt",
wget_cmd => "/usr/bin/wget",
youtube_users_file => "$ENV{HOME}/.config/pipe-viewer/users.txt",
youtube_video_url => "https://www.youtube.com/watch?v=%s",
ytdl => 1,
ytdl_cmd => "/usr/bin/yt-dlp",
ytdlp_comments => 0,
ytdlp_max_comments => 10,
ytdlp_max_replies => 3,
}

View file

@ -5,6 +5,8 @@ from local import GPG_KEY, NOTIF_GRANTS
c = c # noqa: F821 pylint: disable=E0602,C0103
config = config # noqa: F821 pylint: disable=E0602,C0103
config.load_autoconfig(False)
########
# Misc #
########
@ -50,6 +52,7 @@ config.set("content.notifications.enabled", False, "*://*.reddit.com/*")
# Hinting
config.bind("F", "hint all tab-bg")
config.bind(";p", "hint links spawn cliplumber {hint-url}")
config.bind(";v", "hint links spawn playvideo {hint-url}")
config.bind(";i", "hint images download")

View file

@ -11,5 +11,5 @@
(function () {
'use strict';
top.location.hostname = "nitter.pussthecat.org";
top.location.hostname = "nitter.fdn.fr";
})();

37
mailcap
View file

@ -1,3 +1,40 @@
text/html; unshare -n -r w3m -I %{charset} -T text/html; copiousoutput;
image/*; mutt_bgrun /usr/bin/feh -. %s; test=test -n "$DISPLAY"
application/pdf; mutt_bgrun /usr/bin/zathura %s; test=test -n "$DISPLAY"
# Fichiers LibreOffice, Word, Excel et PowerPoint
application/vnd.openxmlformats-officedocument.wordprocessingml.document; mutt_bgrun libreoffice --nologo '%s'; test=test -n "$DISPLAY"
application/vnd.openxmlformats-officedocument.wordprocessingml.template; mutt_bgrun libreoffice --nologo '%s'; test=test -n "$DISPLAY"
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet; mutt_bgrun libreoffice --nologo '%s'; test=test -n "$DISPLAY"
application/vnd.openxmlformats-officedocument.spreadsheetml.template; mutt_bgrun libreoffice --nologo '%s'; test=test -n "$DISPLAY"
application/vnd.openxmlformats-officedocument.presentationml.presentation; mutt_bgrun libreoffice --nologo '%s'; test=test -n "$DISPLAY"
application/msword; mutt_bgrun libreoffice --nologo '%s'; test=test -n "$DISPLAY"
application/vnd.msword; mutt_bgrun libreoffice --nologo '%s'; test=test -n "$DISPLAY"
application/excel; mutt_bgrun libreoffice --nologo '%s'; test=test -n "$DISPLAY"
application/msexcel; mutt_bgrun libreoffice --nologo '%s'; test=test -n "$DISPLAY"
application/x-excel; mutt_bgrun libreoffice --nologo '%s'; test=test -n "$DISPLAY"
application/x-msexcel; mutt_bgrun libreoffice --nologo '%s'; test=test -n "$DISPLAY"
application/vnd.ms-excel; mutt_bgrun libreoffice --nologo '%s'; test=test -n "$DISPLAY"
application/ms-Excel; mutt_bgrun libreoffice --nologo '%s'; test=test -n "$DISPLAY"
application/vnd.ms-powerpoint; mutt_bgrun libreoffice --nologo '%s'; test=test -n "$DISPLAY"
application/x-mspowerpoint; mutt_bgrun libreoffice --nologo '%s'; test=test -n "$DISPLAY"
application/ppt; mutt_bgrun libreoffice --nologo '%s'; test=test -n "$DISPLAY"
application/rtf; mutt_bgrun libreoffice --nologo '%s'; test=test -n "$DISPLAY"
# # MS documents to txt
# application/msword; tika -t %s | less;
# application/vnd.msword; tika -t %s | less;
# application/excel; tika %s | less;
# application/msexcel; tika %s | less;
# application/x-excel; tika %s | less;
# application/x-msexcel; tika %s | less;
# application/vnd.ms-excel; tika %s | less;
# application/ms-Excel; tika %s | less;
# application/vnd.ms-powerpoint; tika %s | w3m -dump -T text/html | less;
# application/x-mspowerpoint; tika %s | w3m -dump -T text/html | less;
# application/ppt; tika %s | w3m -dump -T text/html | less;
# application/rtf; tika %s | w3m -dump -T text/html | less;

1
vimrc
View file

@ -58,6 +58,7 @@ if has("unix") || has("mac")
Plugin 'tikhomirov/vim-glsl'
Plugin 'jamessan/vim-gnupg'
Plugin 'https://git.sr.ht/~sircmpwn/hare.vim'
Plugin 'romainl/vim-cool'
Plugin 'machakann/vim-highlightedyank'
let g:highlightedyank_highlight_duration = 200