From d5714c0ca28d944d0fce52ddaab20b5ec78037e6 Mon Sep 17 00:00:00 2001 From: David JULIEN Date: Wed, 19 Oct 2022 23:22:00 +0200 Subject: [PATCH 01/11] [git] fix: gitignore path in ~/.local --- .gitignore | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 3ef6e1e..648d53d 100644 --- a/.gitignore +++ b/.gitignore @@ -4,22 +4,28 @@ !/.xprofile !/.zshenv +!/.local !/.local/bin/ -!/local/src/ -!/.local/state/ +!/.local/src/ +/.local/lib/ +/.local/include/ +/.local/share/ +/.local/state/ !/.config/ /.config/dconf/ /.config/font-manager/ /.config/fontconfig/ -/.config/gnupg/ +/.config/gnupg/* !/.config/gnupg/gpg-agent.conf /.config/libreoffice/ -/.config/mpd/ +/.config/mpd/* !/.config/mpd/mpd.conf /.config/mutt/.mailsynclastrun /.config/nvim/plugin/ /.config/pulse/ +/.config/transmission-daemon/* +/.config/transmission-daemon/settings.json /.config/zsh/.zcompdump /**/*.log From 5cce96f8ada846c4cdd9f7b839e507896500ca30 Mon Sep 17 00:00:00 2001 From: David JULIEN Date: Wed, 19 Oct 2022 23:27:18 +0200 Subject: [PATCH 02/11] [mail] fix: globbing for subdirectories --- .local/bin/mailsync | 4 ++-- .local/bin/statusbar/sb-mailbox | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.local/bin/mailsync b/.local/bin/mailsync index c8fd4f9..aa37703 100755 --- a/.local/bin/mailsync +++ b/.local/bin/mailsync @@ -40,7 +40,7 @@ messageinfo() { syncandnotify() { acc="$(echo "$account" | sed "s/.*\///")" mbsync "$acc" - new="$(find "${XDG_DATA_HOME:-$HOME/.local/share}"/mail/$acc/*/new/ -type f -newer "${XDG_CONFIG_HOME:-$HOME/.config}/mutt/.mailsynclastrun" | grep -iv "trash" 2>/dev/null)" + new="$(find "${XDG_DATA_HOME:-$HOME/.local/share}"/mail/$acc -path */new/* -type f -newer "${XDG_STATE_HOME:-$HOME/.local/state}/mailsynclastrun" | grep -iv "trash" 2>/dev/null)" newcount=$(echo "$new" | sed '/^\s*$/d' | wc -l) if [ "$newcount" -gt "0" ]; then for file in $new; do @@ -66,4 +66,4 @@ wait notmuch new 2>/dev/null #Create a touch file that indicates the time of the last run of mailsync -touch "${XDG_CONFIG_HOME:-$HOME/.config}/mutt/.mailsynclastrun" +touch "${XDG_STATE_HOME:-$HOME/.local/state}/mailsynclastrun" diff --git a/.local/bin/statusbar/sb-mailbox b/.local/bin/statusbar/sb-mailbox index 32fe024..2aaee38 100755 --- a/.local/bin/statusbar/sb-mailbox +++ b/.local/bin/statusbar/sb-mailbox @@ -13,7 +13,7 @@ unread="" for acc in $(ls "${XDG_DATA_HOME:-$HOME/.local/share}"/mail/) do - new="$(find "${XDG_DATA_HOME:-$HOME/.local/share}"/mail/$acc/*/new/ -type f | grep -iv "trash" | wc -l 2>/dev/null)" + new="$(find "${XDG_DATA_HOME:-$HOME/.local/share}"/mail/$acc -path */new/* -type f | grep -iv "trash" | wc -l 2>/dev/null)" if [ $new -gt 0 ]; then box="" [ -n "$(echo "$acc" | sed -n '/@centrale/p')" ] && box="" @@ -23,6 +23,6 @@ do unread="$unread/$box$new" fi done -[ -n "$unread" ] && unread="($(echo "$unread" | cut -c 2-))" || exit +[ -n "$unread" ] && unread="$(echo "$unread" | cut -c 2-)" || exit printf "  %s%s " "$unread" "$icon" From 13efea3df40651d96ce8aa0d77519ad4e4096113 Mon Sep 17 00:00:00 2001 From: David JULIEN Date: Wed, 19 Oct 2022 23:27:36 +0200 Subject: [PATCH 03/11] [nvim.cmp] fix: deprecated function --- .config/nvim/lua/plugin/lsp/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.config/nvim/lua/plugin/lsp/init.lua b/.config/nvim/lua/plugin/lsp/init.lua index 88be39c..4a22120 100644 --- a/.config/nvim/lua/plugin/lsp/init.lua +++ b/.config/nvim/lua/plugin/lsp/init.lua @@ -55,7 +55,7 @@ end -- nvim-cmp supports additional completion capabilities local capabilities = vim.lsp.protocol.make_client_capabilities() -capabilities = require("cmp_nvim_lsp").update_capabilities(capabilities) +capabilities = require("cmp_nvim_lsp").default_capabilities(capabilities) local servers = { "clangd", "sumneko_lua", "texlab" } lsp_installer.setup { From 89c68124906b194dae697e5ed9a4794e40b89b8d Mon Sep 17 00:00:00 2001 From: David JULIEN Date: Tue, 25 Oct 2022 12:00:07 +0200 Subject: [PATCH 04/11] [mail] fix: use XDG_DIRECTORIES variables for mailcap --- .config/mutt/neomutt.muttrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.config/mutt/neomutt.muttrc b/.config/mutt/neomutt.muttrc index a000907..8191acd 100644 --- a/.config/mutt/neomutt.muttrc +++ b/.config/mutt/neomutt.muttrc @@ -3,7 +3,7 @@ # More information : https://github.com/LukeSmithxyz/mutt-wizard -set mailcap_path = /home/swytch/.config/mutt/mailcap:$mailcap_path +set mailcap_path = $XDG_CONFIG_HOME/mutt/mailcap:$mailcap_path set mime_type_query_command = "file --mime-type -b %s" set date_format="%d/%m/%y %I:%M%p" set index_format="%2C %Z %?X?A& ? %D %-15.15F %s (%-4.4c)" From 6614e219e9bd2ab22ce139dfa2a87faf816fce37 Mon Sep 17 00:00:00 2001 From: David JULIEN Date: Tue, 25 Oct 2022 12:00:54 +0200 Subject: [PATCH 05/11] [mail] feat: use a PGP key as default key, not just for signing --- .config/mutt/accounts/1-david.julien@posteo.net.muttrc | 3 ++- .config/mutt/accounts/2-david.julien@ens-lyon.fr.muttrc | 3 ++- .config/mutt/accounts/2-david.julien@univ-nantes.fr.muttrc | 3 ++- .config/mutt/accounts/3-david.julien@mailo.com.muttrc | 3 ++- .../mutt/accounts/4-david.julien@centrale-marseille.fr.muttrc | 3 ++- 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.config/mutt/accounts/1-david.julien@posteo.net.muttrc b/.config/mutt/accounts/1-david.julien@posteo.net.muttrc index ac52906..c81d1a9 100644 --- a/.config/mutt/accounts/1-david.julien@posteo.net.muttrc +++ b/.config/mutt/accounts/1-david.julien@posteo.net.muttrc @@ -10,7 +10,8 @@ set message_cachedir = "$XDG_CACHE_HOME/mutt/david.julien@posteo.net/bodies" set mbox_type = Maildir set crypt_autosign = yes -set pgp_sign_as = "0x7F03EA9BEFFCB97F" +set pgp_self_encrypt = yes +set pgp_default_key = "0x7F03EA9BEFFCB97F" bind index,pager gg noop bind index,pager g noop diff --git a/.config/mutt/accounts/2-david.julien@ens-lyon.fr.muttrc b/.config/mutt/accounts/2-david.julien@ens-lyon.fr.muttrc index 9fea223..7c00a8f 100644 --- a/.config/mutt/accounts/2-david.julien@ens-lyon.fr.muttrc +++ b/.config/mutt/accounts/2-david.julien@ens-lyon.fr.muttrc @@ -10,7 +10,8 @@ set message_cachedir = "$XDG_CACHE_HOME/mutt/david.julien@ens-lyon.fr/bodies" set mbox_type = Maildir set crypt_autosign = yes -set pgp_sign_as = "0x9D5279329BB80FA0" +set pgp_self_encrypt = yes +set pgp_default_key = "0x9D5279329BB80FA0" bind index,pager gg noop bind index,pager g noop diff --git a/.config/mutt/accounts/2-david.julien@univ-nantes.fr.muttrc b/.config/mutt/accounts/2-david.julien@univ-nantes.fr.muttrc index 2e15aad..d237efe 100644 --- a/.config/mutt/accounts/2-david.julien@univ-nantes.fr.muttrc +++ b/.config/mutt/accounts/2-david.julien@univ-nantes.fr.muttrc @@ -10,7 +10,8 @@ set message_cachedir = "$XDG_CACHE_HOME/mutt/david.julien@univ-nantes.fr/bodies" set mbox_type = Maildir set crypt_autosign = yes -set pgp_sign_as = "0x1DD6B2BA6DD78810" +set pgp_self_encrypt = yes +set pgp_default_key = "0x1DD6B2BA6DD78810" bind index,pager gg noop bind index,pager g noop diff --git a/.config/mutt/accounts/3-david.julien@mailo.com.muttrc b/.config/mutt/accounts/3-david.julien@mailo.com.muttrc index f9497d2..779517e 100644 --- a/.config/mutt/accounts/3-david.julien@mailo.com.muttrc +++ b/.config/mutt/accounts/3-david.julien@mailo.com.muttrc @@ -10,7 +10,8 @@ set message_cachedir = "$XDG_CACHE_HOME/mutt/david.julien@mailo.com/bodies" set mbox_type = Maildir set crypt_autosign = yes -set pgp_sign_as = "0x86C2FBBE4A4F0F7F" +set pgp_self_encrypt = yes +set pgp_default_key = "0x86C2FBBE4A4F0F7F" bind index,pager gg noop bind index,pager g noop diff --git a/.config/mutt/accounts/4-david.julien@centrale-marseille.fr.muttrc b/.config/mutt/accounts/4-david.julien@centrale-marseille.fr.muttrc index 7e6fcb1..a521c78 100644 --- a/.config/mutt/accounts/4-david.julien@centrale-marseille.fr.muttrc +++ b/.config/mutt/accounts/4-david.julien@centrale-marseille.fr.muttrc @@ -10,7 +10,8 @@ set message_cachedir = "$XDG_CACHE_HOME/mutt/david.julien@centrale-marseille.fr/ set mbox_type = Maildir set crypt_autosign = no -set pgp_sign_as = "0x9F46CD164AE1E813" +set pgp_self_encrypt = yes +set pgp_default_key = "0x9F46CD164AE1E813" bind index,pager gg noop bind index,pager g noop From 069ac13a3b1923bd8e3e68f4c8a4597116815795 Mon Sep 17 00:00:00 2001 From: David JULIEN Date: Tue, 25 Oct 2022 12:01:23 +0200 Subject: [PATCH 06/11] [mail] feat: add keybindings to univ-nantes --- .../accounts/2-david.julien@univ-nantes.fr.muttrc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.config/mutt/accounts/2-david.julien@univ-nantes.fr.muttrc b/.config/mutt/accounts/2-david.julien@univ-nantes.fr.muttrc index d237efe..cc03a40 100644 --- a/.config/mutt/accounts/2-david.julien@univ-nantes.fr.muttrc +++ b/.config/mutt/accounts/2-david.julien@univ-nantes.fr.muttrc @@ -24,7 +24,7 @@ set signature="$XDG_CONFIG_HOME/mutt/accounts/nantes.signature" unmacro index o macro index o "mailsync" "run mbsync to sync david.julien@univ-nantes.fr" -mailboxes "=Sent" "=Drafts" "=Trash" "=INBOX" "=thesis" "=admin" "=login" "=teaching" "=teaching/X11I020" "=teaching/X11I040" +mailboxes "=Sent" "=Drafts" "=Trash" "=INBOX" "=thesis" "=admin" "=login" "=publications" "=teaching" "=teaching/X11I020" "=teaching/X11I040" set record = "+Sent" macro index,pager gs "=Sent" "go to sent" macro index,pager Ms ";=Sent" "move mail to sent" @@ -50,3 +50,12 @@ macro index,pager Ca ";=admin" "copy mail to admin" macro index,pager gl "=login" "go to login" macro index,pager Ml ";=login" "move mail to login" macro index,pager Cl ";=login" "copy mail to login" +macro index,pager gp "=publications" "go to publications" +macro index,pager Mp ";=publications" "move mail to publications" +macro index,pager Cp ";=publications" "copy mail to publications" +macro index,pager gc2 "=teaching/X11I020" "go to teaching/X11I020" +macro index,pager Mc2 ";=teaching/X11I020" "move mail to teaching/X11I020" +macro index,pager Cc2 ";=teaching/X11I020" "copy mail to teaching/X11I020" +macro index,pager gc4 "=teaching/X11I040" "go to teaching/X11I040" +macro index,pager Mc4 ";=teaching/X11I040" "move mail to teaching/X11I040" +macro index,pager Cc4 ";=teaching/X11I040" "copy mail to teaching/X11I040" From 1249c0099bdfdfcf7fd0c2982611c96eedbaa1c8 Mon Sep 17 00:00:00 2001 From: David JULIEN Date: Tue, 25 Oct 2022 12:02:17 +0200 Subject: [PATCH 07/11] [mail] fix: do not display drafts count in statusbar --- .local/bin/statusbar/sb-mailbox | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.local/bin/statusbar/sb-mailbox b/.local/bin/statusbar/sb-mailbox index 2aaee38..fb8df42 100755 --- a/.local/bin/statusbar/sb-mailbox +++ b/.local/bin/statusbar/sb-mailbox @@ -13,7 +13,7 @@ unread="" for acc in $(ls "${XDG_DATA_HOME:-$HOME/.local/share}"/mail/) do - new="$(find "${XDG_DATA_HOME:-$HOME/.local/share}"/mail/$acc -path */new/* -type f | grep -iv "trash" | wc -l 2>/dev/null)" + new="$(find "${XDG_DATA_HOME:-$HOME/.local/share}"/mail/$acc -path */new/* -type f | grep -iv -e "trash" -e "drafts" | wc -l 2>/dev/null)" if [ $new -gt 0 ]; then box="" [ -n "$(echo "$acc" | sed -n '/@centrale/p')" ] && box="" From 9b6842e073a2d287698684ef133bd4a28ee7b15c Mon Sep 17 00:00:00 2001 From: David JULIEN Date: Tue, 25 Oct 2022 12:02:47 +0200 Subject: [PATCH 08/11] [mail] cleanup: notify only the maount of mails no need to get loads of infos, just to know you get a mail --- .local/bin/mailsync | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/.local/bin/mailsync b/.local/bin/mailsync index aa37703..112e199 100755 --- a/.local/bin/mailsync +++ b/.local/bin/mailsync @@ -32,25 +32,16 @@ export GPG_TTY=$TTY notify() { notify-send "neomutt" " $2 new mail(s) in \`$1\` account." } -messageinfo() { - notify-send " $from:" "$subject" -} # Check account for new mail. Notify if there is new content. syncandnotify() { acc="$(echo "$account" | sed "s/.*\///")" mbsync "$acc" - new="$(find "${XDG_DATA_HOME:-$HOME/.local/share}"/mail/$acc -path */new/* -type f -newer "${XDG_STATE_HOME:-$HOME/.local/state}/mailsynclastrun" | grep -iv "trash" 2>/dev/null)" + new="$(find "${XDG_DATA_HOME:-$HOME/.local/share}"/mail/$acc -path */new/* -type f | grep -iv -e "trash" -e "drafts" 2>/dev/null)" newcount=$(echo "$new" | sed '/^\s*$/d' | wc -l) if [ "$newcount" -gt "0" ]; then - for file in $new; do - # Extract subject and sender from mail. - from=$(awk '/^From: / && ++n ==1,/^\<.*\>:/' "$file" | perl -CS -MEncode -ne 'print decode("MIME-Header", $_)' | awk '{ $1=""; if (NF>=3)$NF=""; print $0 }' | sed 's/^[[:blank:]]*[\"'\''\<]*//;s/[\"'\''\>]*[[:blank:]]*$//') - subject=$(awk '/^Subject: / && ++n == 1,/^\<.*\>: / && ++i == 2' "$file" | head -n 1 | perl -CS -MEncode -ne 'print decode("MIME-Header", $_)' | sed 's/^Subject: //' | sed 's/^{[[:blank:]]*[\"'\''\<]*//;s/[\"'\''\>]*[[:blank:]]*$//' | tr -d '\n') - messageinfo & - done - notify "$acc" "$newcount" & - [ -n "$(pidof dwmblocks)" ] && kill -40 $(pidof dwmblocks) + notify "$acc" "$newcount" & + [ -n "$(pidof dwmblocks)" ] && kill -40 $(pidof dwmblocks) fi } From 49a299d91b26617bacf86f6b88c5ab3bf262a6d8 Mon Sep 17 00:00:00 2001 From: David JULIEN Date: Tue, 25 Oct 2022 12:06:01 +0200 Subject: [PATCH 09/11] [nvim] feat: prefix Telescope maps with t --- .config/nvim/lua/maps.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.config/nvim/lua/maps.lua b/.config/nvim/lua/maps.lua index 5ee5ec4..545e9a7 100644 --- a/.config/nvim/lua/maps.lua +++ b/.config/nvim/lua/maps.lua @@ -18,11 +18,11 @@ vim.keymap.set("n", "", "w! | !compiler %") vim.keymap.set("n", "u", function() require("packer").sync() end) -- telescope -vim.keymap.set("n", "ff", +vim.keymap.set("n", "tf", function() require("telescope.builtin").find_files() end) -vim.keymap.set("n", "fb", +vim.keymap.set("n", "tb", function() require("telescope.builtin").buffers() end) -vim.keymap.set("n", "fl", +vim.keymap.set("n", "tl", function() require("telescope.builtin").live_grep() end) -- colorscheme From e29723ec26d94758df0567c8f27f9011fa43a677 Mon Sep 17 00:00:00 2001 From: David JULIEN Date: Tue, 25 Oct 2022 12:26:14 +0200 Subject: [PATCH 10/11] [nvim] feat: add a Telescope mapping to grep under cursor --- .config/nvim/lua/maps.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.config/nvim/lua/maps.lua b/.config/nvim/lua/maps.lua index 545e9a7..e675aee 100644 --- a/.config/nvim/lua/maps.lua +++ b/.config/nvim/lua/maps.lua @@ -22,6 +22,8 @@ vim.keymap.set("n", "tf", function() require("telescope.builtin").find_files() end) vim.keymap.set("n", "tb", function() require("telescope.builtin").buffers() end) +vim.keymap.set("n", "tg", + function() require("telescope.builtin").grep_string() end) vim.keymap.set("n", "tl", function() require("telescope.builtin").live_grep() end) From a17e7fc1348378ff4867d8a215b9dc59203d92b1 Mon Sep 17 00:00:00 2001 From: David JULIEN Date: Tue, 25 Oct 2022 19:51:42 +0200 Subject: [PATCH 11/11] [mail] fix: check new-ness against $timestamp --- .local/bin/mailsync | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.local/bin/mailsync b/.local/bin/mailsync index 112e199..7cb2231 100755 --- a/.local/bin/mailsync +++ b/.local/bin/mailsync @@ -13,6 +13,8 @@ # and the GPG home. This is done by searching common profile files for variable # assignments. +timestamp="${XDG_STATE_HOME:-$HOME/.local/state}/mailsynclastrun" + eval "$(grep -h -- \ "^\s*\(export \)\?\(XDG_CACHE_HOME\|XDG_CONFIG_HOME\|XDG_DATA_HOME\)=" \ "$HOME/.zshenv" 2>/dev/null)" @@ -37,7 +39,7 @@ notify() { syncandnotify() { acc="$(echo "$account" | sed "s/.*\///")" mbsync "$acc" - new="$(find "${XDG_DATA_HOME:-$HOME/.local/share}"/mail/$acc -path */new/* -type f | grep -iv -e "trash" -e "drafts" 2>/dev/null)" + new="$(find "${XDG_DATA_HOME:-$HOME/.local/share}"/mail/$acc -path */new/* -type f -newer "$timestamp" | grep -iv -e "trash" -e "drafts" 2>/dev/null)" newcount=$(echo "$new" | sed '/^\s*$/d' | wc -l) if [ "$newcount" -gt "0" ]; then notify "$acc" "$newcount" & @@ -57,4 +59,4 @@ wait notmuch new 2>/dev/null #Create a touch file that indicates the time of the last run of mailsync -touch "${XDG_STATE_HOME:-$HOME/.local/state}/mailsynclastrun" +touch $timestamp