diff --git a/.config/calcurse/conf b/.config/calcurse/conf index bf38e7e..9312851 100644 --- a/.config/calcurse/conf +++ b/.config/calcurse/conf @@ -8,7 +8,7 @@ appearance.dayseparator=yes appearance.emptyline=yes appearance.notifybar=yes appearance.sidebarwidth=0 -appearance.theme=default on default +appearance.theme=blue on black appearance.todoview=hide-completed appearance.headingpos=right-justified daemon.enable=yes diff --git a/.local/bin/tools/matrix_decrypt.py b/.local/bin/tools/matrix_decrypt.py index 6adc8b1..c04eb78 100755 --- a/.local/bin/tools/matrix_decrypt.py +++ b/.local/bin/tools/matrix_decrypt.py @@ -44,6 +44,7 @@ def main(): description='Download and decrypt matrix attachments' ) parser.add_argument('url', help='the url of the attachment') + parser.add_argument('file', nargs='?', help='save attachment to ') parser.add_argument('--plumber', help='program that gets called with the ' 'dowloaded file') @@ -68,11 +69,19 @@ def main(): print("Error downloading file") return -2 - plumber = args.plumber or "/usr/bin/rifle" + plumber = args.plumber plaintext = decrypt_attachment(request.content, key, hash, iv) - file_name = save_file(plaintext) - subprocess.run([plumber, "{file}".format(file=file_name)]) + if args.file is None: + file_name = save_file(plaintext) + if plumber is None: + plumber = "xdg-open" + else: + file_name = args.file + open(file_name, "wb").write(plaintext) + + if plumber is not None: + subprocess.run([plumber, file_name]) return 0 diff --git a/.local/bin/weechatlinks b/.local/bin/weechatlinks new file mode 100755 index 0000000..181db71 --- /dev/null +++ b/.local/bin/weechatlinks @@ -0,0 +1,28 @@ +#!/bin/sh +all="$(perl -pe 's/[^│]*([^│]*?)│/\1/' | + perl -pe 's/^.*?\| //' | + sed 's/ │.*//' | + head -n-3 | tr -d '\n'| + grep -aEo '(<[^]]*>|\[[^ ]*\])')" + +filenames="$( echo "$all" | grep -E '^<[^>]*>' | tr -d '<>')" +links="$( echo "$all" | grep -E '^\[' | tr -d [])" +choice="$(printf 'most recent\nall\n%s' "$filenames" | dmenu -i -p 'open which file?' -l 10)" +case "$choice" in + "most recent") link="$(echo "$links" | tail -n1)";; + "all") link="$links";; + *) #TODO: implement dmenu multiline support + linenr="$(echo "$filenames" | awk "/$choice/ {print NR}")" + [ "$(echo "$linenr" | wc -l)" -gt 1 ] && notify-send "weechatdls" "multiple files with that name, not yet supported" + link="$(echo "$links" | awk "NR==$linenr")";; +esac +if [ "$(echo "$link" | wc -l)" -eq 1 ]; then + if echo "$link" | grep -qE '^emxc'; then + matrix_decrypt.py "$link" + else + curl -L "$link" -o "/tmp/$choice" + rifle "/tmp/$choice" + fi + else + notify-send "weechatdls" "multi-link downloads not yet supported" +fi