@ -0,0 +1,3 @@ | |||
#!/bin/bash | |||
~/.local/bin/firefox-sync |
@ -1,163 +0,0 @@ | |||
#!/usr/bin/perl | |||
# | |||
# "Beautify" quoted message and make it "ready-to-reply" by Michael Velten | |||
use utf8; | |||
# keep quotes nested up to 3rd level | |||
my $ind_max = 4; | |||
my $name = '[[:alpha:]]+([\'`-][[:alpha:]]+|[.])*'; | |||
my $fullname = '\b(' . $name . '[,]?\s+)*' . $name . '\b'; | |||
# Possible reply greetings (regexes) (note that '> ' will be prefixed) | |||
my @greetings = ( | |||
'Dear\s+' . $fullname . '([,.]|\s*!)?', | |||
'[Hh](ello|i|ey)' . '(\s+' . $fullname . ')?' . '([,.]|\s*!)?', | |||
'Sehr geehrter?\s+' . $fullname . '([,.]|\s*!)?', | |||
'Lieber?\s+' . $fullname . '([,.]|\s*!)?', | |||
'Guten Tag' . '(\s+' . $fullname . ')?' . '([,.]|\s*!)?', | |||
'[Hh]allo' . '(\s+' . $fullname . ')?' . '([,.]|\s*!)?', | |||
'[Mm]oin' . '(\s+' . $fullname . ')?' . '([,.]|\s*!)?', | |||
'[Mm]esdames(,| et) [Mm]essieurs([,.]|\s*!)?', | |||
'M(adame)\s+' . $fullname . '([,.]|\s*!)?', | |||
'M(onsieur)\s+' . $fullname . '([,.]|\s*!)?', | |||
'[Cc]her\s+' . $fullname . '([,.]|\s*!)?', | |||
'[Cc]h[eè]re\s+' . $fullname . '([,.]|\s*!)?', | |||
'[Bb]onjour' . '(\s+' . $fullname . ')?' . '([,.]|\s*!)?', | |||
'[Ss]alut' . '(\s+' . $fullname . ')?' . '([,.]|\s*!)?', | |||
'Senhor(ita|a)?' . '(\s+' . $fullname . ')?' . '([,.]|\s*!)?', | |||
'Sra?\.?' . '(\s+' . $fullname . ')?' . '([,.]|\s*!)?', | |||
'Car([ií]ssim)?[ao]s?' . '(\s+' . $fullname . ')?' . '([,.]|\s*!)?', | |||
'Prezad([ií]ssim)?[ao]s?' . '(\s+' . $fullname . ')?' . '([,.]|\s*!)?', | |||
'Estimad([ií]ssim)?[ao]s?' . '(\s+' . $fullname . ')?' . '([,.]|\s*!)?', | |||
'[Bb]om [Dd]ia' . '(\s+' . $fullname . ')?' . '([,.]|\s*!)?', | |||
'[Bb]oa ([Tt]arde|[Nn]oite)' . '(\s+' . $fullname . ')?' . '([,.]|\s*!)?', | |||
'[Oo](i|l[aá])' . '(\s+' . $fullname . ')?' . '([,.]|\s*!)?', | |||
'[Aa]l[ôo]' . '(\s+' . $fullname . ')?' . '([,.]|\s*!)?', | |||
'[Hh]ola' . '(\s+' . $fullname . ')?' . '([,.]|\s*!)?', | |||
'Se[nñ]or(ita|a)?' . '(\s+' . $fullname . ')?' . '([,.]|\s*!)?', | |||
); | |||
# Possible reply "greetouts" (regexes) (note that '> ' will be prefixed) | |||
my @greetouts = ( | |||
'([Ww]ith )?(([Kk]ind|[Bb]est|[Ww]arm) )?([Rr]egards|[Ww]ishes)([,.]|\s*!)?', | |||
'[Bb]est([,.]|\s*!)?', | |||
'[Cc]heers([,.]|\s*!)?', | |||
'[Mm]it ([Vv]iel|[Bb]est|[Ll]ieb|[Ff]reundlich)en [Gg]r([ü]|ue)([ß]|ss)en([,.]|\s*!)?', | |||
'(([Vv]iel|[Bb]est|[Ll]ieb|[Ff]reundlich)e )?[Gg]r([ü]|ue)([ß]|ss)e([,.]|\s*!)?', | |||
'(([[Bb]est|[Ll]ieb|[Ff]reundlich)e[rn] )?[Gg]ru([ß]|ss)([,.]|\s*!)?', | |||
'[Mm]it (([[Bb]est|[Ll]ieb|[Ff]reundlich)em )?[Gg]ru([ß]|ss)([,.]|\s*!)?', | |||
'([LV]|MF)G([,.]|\s*!)?', | |||
'(([Tt]r[eè]s|[Bb]ien) )?([Cc]ordi|[Aa]mic)alement([,.]|\s*!)?', | |||
'[Aa]miti[eé]s?([,.]|\s*!)?', | |||
'[Aa]tenciosamente([,.]|\s*!)?', | |||
'[Aa]tt([,.]|\s*!)?', | |||
'[Aa]bra[cç]os?([,.]|\s*!)?', | |||
'[Aa]tentamente([,.]|\s*!)?', | |||
'[Cc]ordialmente([,.]|\s*!)?', | |||
); | |||
my $word = '[[:alpha:]]+([\'`-][[:alpha:]]+)*'; | |||
# my $saw_greeting = 0; | |||
# my $saw_greetout = 0; | |||
my $saw_own_sig = 0; | |||
my $saw_blank_line = 0; | |||
my $inds_other_sig = 0; | |||
my $quote_header = 0; | |||
my $extra_pref = ''; | |||
my (@mail, @purged_mail); | |||
my $msg = shift; | |||
die "Usage: $0 MAIL" unless $msg; | |||
open(MAIL, "+<:encoding(UTF-8)", $msg) or die "$0: Can't open $msg: $!"; | |||
push(@mail, $_) while <MAIL>; # Read whole mail | |||
# Process whole mail | |||
LINE: | |||
foreach my $line (@mail) { | |||
# Treat non-quoted lines as is | |||
if ($line !~ /^>/) { | |||
push(@purged_mail, $line); | |||
next LINE; | |||
} | |||
# Keep all lines after my own signature unmodified | |||
if ($line =~ /^--\s?$/ || $saw_own_sig) { | |||
$saw_own_sig = 1; | |||
push(@purged_mail, $line); | |||
next LINE; | |||
} | |||
# $line =~ tr/\xA0/ /; | |||
# tighten "> > " to ">> " | |||
my ($pref, $suff) = $line =~ /^([>[:space:]]+)(.*)$/; | |||
$pref =~ s/(>\s*(?!$))/>/g; | |||
# reduce multiple pre- and post-blanks to one post-blank | |||
$pref =~ s/^\s*(>+)\s*/$1 /; | |||
$line = $pref . $suff . "\n"; | |||
# prepend additional '>' for each Outlook quote header | |||
if ($line =~ /^>+ [-_=]{3,}\s*$word(\s+$word)*\s*[-_=]{3,}$/) { | |||
$quote_header = 1; | |||
next LINE; | |||
} | |||
# first line after Outlook quote header that does not start with ...: | |||
if ($quote_header == 1 && $line !~ /^>+ ([-*]\s*)?$word(\s+$word)*\s*:\s+/) { | |||
$extra_pref = '>' . $extra_pref; | |||
$quote_header = 0; | |||
} | |||
$pref = $extra_pref . $pref; | |||
$line = $pref . $suff . "\n"; | |||
# skip line if number of '>'s is greater than $ind_max | |||
my $inds = $pref =~ tr/>//; | |||
next LINE if $inds > $ind_max; | |||
# Remove other signatures | |||
if ($line =~ /^>+ --\s?$/) { | |||
$inds_other_sig = $inds; | |||
} | |||
if ($inds == $inds_other_sig) { | |||
next LINE; | |||
} else { | |||
$inds_other_sig = 0; | |||
} | |||
# Remove quoted greeting | |||
# unless ($saw_greeting) { | |||
foreach my $greeting (@greetings) { | |||
if ($line =~ /^>+ $greeting$/) { | |||
# $saw_greeting = 1; | |||
next LINE; | |||
} | |||
} | |||
# } | |||
# Remove quoted "greetout" | |||
# unless ($saw_greetout) { | |||
foreach my $greetout (@greetouts) { | |||
if ($line =~ /^>+ $greetout$/) { | |||
# $saw_greetout = 1; | |||
next LINE; | |||
} | |||
} | |||
# } | |||
# Remove quoted filler lines | |||
if ($line =~ /^>+ \s*(-*|_*|=*|\+*|#*|\**)$/) { | |||
next LINE; | |||
} | |||
# Save purged line | |||
push(@purged_mail, $line); | |||
} | |||
# Overwrite original mail with purged mail | |||
truncate(MAIL, 0); | |||
seek(MAIL, 0, 0); | |||
print MAIL @purged_mail; | |||
close(MAIL); |
@ -1,239 +0,0 @@ | |||
#!/usr/bin/env python3 | |||
# Original Source: https://github.com/oblitum/dotfiles/blob/ArchLinux/.local/bin/MIMEmbellish | |||
import re | |||
import sys | |||
import email | |||
import shlex | |||
import mimetypes | |||
import subprocess | |||
from copy import copy | |||
from hashlib import md5 | |||
from email import charset | |||
from email import encoders | |||
from email.mime.text import MIMEText | |||
from email.mime.multipart import MIMEMultipart | |||
from email.mime.nonmultipart import MIMENonMultipart | |||
from os.path import basename, splitext, expanduser | |||
charset.add_charset('utf-8', charset.SHORTEST, '8bit') | |||
def pandoc(from_format, to_format='markdown', plain='markdown', title=None): | |||
markdown = ('markdown' | |||
'-blank_before_blockquote') | |||
if from_format == 'plain': | |||
from_format = plain | |||
if from_format == 'markdown': | |||
from_format = markdown | |||
if to_format == 'markdown': | |||
to_format = markdown | |||
command = 'pandoc -f {} -t {} --standalone --highlight-style=tango' | |||
if to_format in ('html', 'html5'): | |||
if title is not None: | |||
command += ' --variable=pagetitle:{}'.format(shlex.quote(title)) | |||
command += ' --webtex --template={}'.format( | |||
expanduser('~/.pandoc/templates/email.html')) | |||
return command.format(from_format, to_format) | |||
def gmailfy(payload): | |||
return payload.replace('<blockquote>', | |||
'<blockquote class="gmail_quote" style="' | |||
'padding: 0 7px 0 7px;' | |||
'border-left: 2px solid #cccccc;' | |||
'font-style: italic;' | |||
'margin: 0 0 7px 3px;' | |||
'">') | |||
def make_alternative(message, part): | |||
alternative = convert(part, 'html', | |||
pandoc(part.get_content_subtype(), | |||
to_format='html', | |||
title=message.get('Subject'))) | |||
alternative.set_payload(gmailfy(alternative.get_payload())) | |||
return alternative | |||
def make_replacement(message, part): | |||
return convert(part, 'plain', pandoc(part.get_content_subtype())) | |||
def convert(part, to_subtype, command): | |||
payload = part.get_payload() | |||
if isinstance(payload, str): | |||
payload = payload.encode('utf-8') | |||
else: | |||
payload = part.get_payload(None, True) | |||
if not isinstance(payload, bytes): | |||
payload = payload.encode('utf-8') | |||
process = subprocess.run( | |||
shlex.split(command), | |||
input=payload, stdout=subprocess.PIPE, check=True) | |||
return MIMEText(process.stdout, to_subtype, 'utf-8') | |||
def with_alternative(parent, part, from_signed, | |||
make_alternative=make_alternative, | |||
make_replacement=None): | |||
try: | |||
alternative = make_alternative(parent or part, from_signed or part) | |||
replacement = (make_replacement(parent or part, part) | |||
if from_signed is None and make_replacement is not None | |||
else part) | |||
except: | |||
return parent or part | |||
envelope = MIMEMultipart('alternative') | |||
if parent is None: | |||
for k, v in part.items(): | |||
if (k.lower() != 'mime-version' | |||
and not k.lower().startswith('content-')): | |||
envelope.add_header(k, v) | |||
del part[k] | |||
envelope.attach(replacement) | |||
envelope.attach(alternative) | |||
if parent is None: | |||
return envelope | |||
payload = parent.get_payload() | |||
payload[payload.index(part)] = envelope | |||
return parent | |||
def tag_attachments(message): | |||
if message.get_content_type() == 'multipart/mixed': | |||
for part in message.get_payload(): | |||
if (part.get_content_maintype() in ['image'] | |||
and 'Content-ID' not in part): | |||
filename = part.get_param('filename', | |||
header='Content-Disposition') | |||
if isinstance(filename, tuple): | |||
filename = str(filename[2], filename[0] or 'us-ascii') | |||
if filename: | |||
filename = splitext(basename(filename))[0] | |||
if filename: | |||
part.add_header('Content-ID', '<{}>'.format(filename)) | |||
return message | |||
def attachment_from_file_path(attachment_path): | |||
try: | |||
mime, encoding = mimetypes.guess_type(attachment_path, strict=False) | |||
maintype, subtype = mime.split('/') | |||
with open(attachment_path, 'rb') as payload: | |||
attachment = MIMENonMultipart(maintype, subtype) | |||
attachment.set_payload(payload.read()) | |||
encoders.encode_base64(attachment) | |||
if encoding: | |||
attachment.add_header('Content-Encoding', encoding) | |||
return attachment | |||
except: | |||
return None | |||
attachment_path_pattern = re.compile(r'\]\s*\(\s*file://(/[^)]*\S)\s*\)|' | |||
r'\]\s*:\s*file://(/.*\S)\s*$', | |||
re.MULTILINE) | |||
def link_attachments(payload): | |||
attached = [] | |||
attachments = [] | |||
def on_match(match): | |||
if match.group(1): | |||
attachment_path = match.group(1) | |||
cid_fmt = '](cid:{})' | |||
else: | |||
attachment_path = match.group(2) | |||
cid_fmt = ']: cid:{}' | |||
attachment_id = md5(attachment_path.encode()).hexdigest() | |||
if attachment_id in attached: | |||
return cid_fmt.format(attachment_id) | |||
attachment = attachment_from_file_path(attachment_path) | |||
if attachment: | |||
attachment.add_header('Content-ID', '<{}>'.format(attachment_id)) | |||
attachments.append(attachment) | |||
attached.append(attachment_id) | |||
return cid_fmt.format(attachment_id) | |||
return match.group() | |||
return attachments, attachment_path_pattern.sub(on_match, payload) | |||
def with_local_attachments(parent, part, from_signed, | |||
link_attachments=link_attachments): | |||
if from_signed is None: | |||
attachments, payload = link_attachments(part.get_payload()) | |||
part.set_payload(payload) | |||
else: | |||
attachments, payload = link_attachments(from_signed.get_payload()) | |||
from_signed = copy(from_signed) | |||
from_signed.set_payload(payload) | |||
if not attachments: | |||
return parent, part, from_signed | |||
if parent is None: | |||
parent = MIMEMultipart('mixed') | |||
for k, v in part.items(): | |||
if (k.lower() != 'mime-version' | |||
and not k.lower().startswith('content-')): | |||
parent.add_header(k, v) | |||
del part[k] | |||
parent.attach(part) | |||
for attachment in attachments: | |||
parent.attach(attachment) | |||
return parent, part, from_signed | |||
def is_target(part, target_subtypes): | |||
return (part.get('Content-Disposition', 'inline') == 'inline' | |||
and part.get_content_maintype() == 'text' | |||
and part.get_content_subtype() in target_subtypes) | |||
def pick_from_signed(part, target_subtypes): | |||
for from_signed in part.get_payload(): | |||
if is_target(from_signed, target_subtypes): | |||
return from_signed | |||
def seek_target(message, target_subtypes=['plain', 'markdown']): | |||
if message.is_multipart(): | |||
if message.get_content_type() == 'multipart/signed': | |||
part = pick_from_signed(message, target_subtypes) | |||
if part is not None: | |||
return None, message, part | |||
elif message.get_content_type() == 'multipart/mixed': | |||
for part in message.get_payload(): | |||
if part.is_multipart(): | |||
if part.get_content_type() == 'multipart/signed': | |||
from_signed = pick_from_signed(part, target_subtypes) | |||
if from_signed is not None: | |||
return message, part, from_signed | |||
elif is_target(part, target_subtypes): | |||
return message, part, None | |||
else: | |||
if is_target(message, target_subtypes): | |||
return None, message, None | |||
return None, None, None | |||
def main(): | |||
try: | |||
message = email.message_from_file(sys.stdin) | |||
parent, part, from_signed = seek_target(message) | |||
if (parent, part, from_signed) == (None, None, None): | |||
print(message) | |||
return | |||
tag_attachments(message) | |||
print(with_alternative( | |||
*with_local_attachments(parent, part, from_signed))) | |||
except (BrokenPipeError, KeyboardInterrupt): | |||
pass | |||
if __name__ == '__main__': | |||
main() |
@ -1,10 +0,0 @@ | |||
#!/bin/sh | |||
if [ ! -f "$HOME/.cache/neofetch" ]; then | |||
mkdir -p "$HOME/.cache" | |||
touch "$HOME/.cache/neofetch" | |||
neofetch --ascii ~/.config/neofetch/ascii.txt > "$HOME/.cache/neofetch" | |||
fi | |||
cat "$HOME/.cache/neofetch" | |||
@ -0,0 +1,33 @@ | |||
#!/bin/bash | |||
if [ ! "$BROWSER" = "firefox" ]; then | |||
echo "Default browser is not firefox, exiting..." | |||
exit 0 | |||
fi | |||
source $HOME/.config.env | |||
static=static-$FIREFOX_PROFILE | |||
link=$FIREFOX_PROFILE | |||
volatile=/dev/shm/firefox-$FIREFOX_PROFILE-$USER | |||
IFS= | |||
set -efu | |||
cd ~/.mozilla/firefox | |||
if [ ! -r $volatile ]; then | |||
mkdir -m0700 $volatile | |||
fi | |||
if [ "$(readlink $link)" != "$volatile" ]; then | |||
mv $link $static | |||
ln -s $volatile $link | |||
fi | |||
if [ -e $link/.unpacked ]; then | |||
rsync -av --delete --exclude .unpacked ./$link/ ./$static/ | |||
else | |||
rsync -av ./$static/ ./$link/ | |||
touch $link/.unpacked | |||
fi |
@ -1,26 +0,0 @@ | |||
#!/bin/python | |||
import sys | |||
from base64 import b64decode | |||
from hashlib import sha256 | |||
from urllib.parse import quote | |||
message = b64decode(sys.argv[1]).decode() | |||
userid = "1" | |||
key = "Rwb3pUUG8fQAZUs3Q3qwdHH25Fdq8dyJyzUQqERzrCfxavKExfSExQbr8dZXho57abGvTZGdBmSbyXdVM59jDVi4L5ien9xoVHskMdx4FxNXyq7uBPYaAeA62JXzMZT9" | |||
domain = "https://hermes.yigitcolakoglu.com/read" | |||
subject = "NIL" | |||
recipient = "NIL" | |||
for i in message.split("\n"): | |||
if i.split(" ")[0] == "Subject:": | |||
subject = i[9:] | |||
elif i.split(" ")[0] == "To:": | |||
recipient = i[4:] | |||
identifier = subject + recipient + userid + key | |||
identifier_hash = sha256(identifier.encode("utf-8")).hexdigest() | |||
url = "{}/{}/{}/{}/{}".format(domain,userid,quote(subject),quote(recipient),identifier_hash) | |||
print('![Hermes]({})'.format(url)) |
@ -1,8 +0,0 @@ | |||
#!/bin/sh | |||
curl 'http://yeetclock/setcolor?R=2000&G=10&B=000&O=0' & | |||
/home/yigit/.local/bin/pacontrol.sh open-mute | |||
/home/yigit/.local/bin/dunst_toggle.sh -s | |||
slock | |||
/home/yigit/.local/bin/dunst_toggle.sh -e | |||
/home/yigit/.local/bin/pacontrol.sh toggle-mute | |||
curl 'http://yeetclock/setcolor?R=136&G=192&B=208' & |
@ -1,28 +0,0 @@ | |||
#!/bin/sh | |||
# Put the message, send to stdin, in a variable | |||
m="$(cat -)" | |||
m64="$(echo -e "$m" | base64)" | |||
echo "$m64" > /tmp/test2 | |||
tracking_url=$(/home/yigit/.local/bin/gen_tracking_url "$m64" 2> /tmp/testerr) | |||
echo $tracking_url > /tmp/test3 | |||
# Look at the first argument, | |||
# Use it to determine the account to use | |||
# If not set, assume work | |||
# All remaining arguments should be recipient addresses which should be passed to msmtp | |||
account="$1" | |||
shift 1 | |||
cleanHeaders(){ | |||
# In the headers, delete any lines starting with markdown | |||
cat - | sed '0,/^$/{/^markdown/Id;}' | |||
} | |||
echo "$@" | |||
echo "$message" | cleanHeaders > /tmp/headers | |||
echo "msmtp -a $account $@" | |||
echo "$message" | sed '/^$/q' | grep -q -i 'markdown: true' \ | |||
&& msg=$(echo "$message \n$tracking_url" | cleanHeaders | /home/yigit/.local/bin/convertToHtmlMultipart && echo 1 >> /tmp/state) || msg=$(echo "$message" | cleanHeaders) | |||
echo "$msg" > /tmp/test | |||
echo "$msg" | notmuch insert --folder="$account/sent" +sent -inbox | |||
echo "$msg" | msmtp -a $account $@ |
@ -1,23 +0,0 @@ | |||
#!/bin/sh | |||
format="-f34" # leave empty for default | |||
player="mpv --quiet --geometry=50%:50% --idx --keep-open" | |||
tmpdir="/tmp" | |||
url="$1" | |||
echo $url | |||
echo $format | |||
mpv $url | |||
exit 0 | |||
filepath="$tmpdir/$(youtube-dl --id --get-filename $format $url)" | |||
youtube-dl -c -o $filepath $format $url & | |||
echo $! > $filepath.$$.pid | |||
while [ ! -r $filepath ] && [ ! -r $filepath.part ]; do | |||
echo "Waiting for youtube-dl..." | |||
sleep 3 | |||
done | |||
[ -r $filepath.part ] && $player $filepath.part || $player $filepath | |||
kill $(cat $filepath.$$.pid) | |||
rm $filepath.$$.pid |
@ -1,3 +0,0 @@ | |||
#!/bin/sh | |||
st -e weechat |
@ -0,0 +1,9 @@ | |||
## Notes on firefox | |||
Here are some `about:config` variables that you might want to set: | |||
| Variable | Value | | |||
-------------------- | |||
| services.sync.prefs.sync.browser.uiCustomization.state | true | | |||
| extensions.pocket.enabled | false | | |||
| browser.cache.disk.parent_directory | /run/user/*UID*/firefox | |