diff options
| -rw-r--r-- | dot.config-i3-config | 4 | ||||
| -rw-r--r-- | dot.config-polybar-config | 14 | ||||
| -rw-r--r-- | dot.emacs.d/init.el | 19 | ||||
| -rw-r--r-- | dot.hgrc | 8 | ||||
| -rwxr-xr-x | dot.local-bin-nm--tagger | 140 | ||||
| -rwxr-xr-x | dot.local-bin-sm | 9 | ||||
| -rw-r--r-- | dot.xprofile | 7 | ||||
| -rw-r--r-- | dot.zshrc.local | 13 |
8 files changed, 176 insertions, 38 deletions
diff --git a/dot.config-i3-config b/dot.config-i3-config index 8434292..dd524d8 100644 --- a/dot.config-i3-config +++ b/dot.config-i3-config @@ -163,3 +163,7 @@ bindsym $mod+Shift+F1 exec setxkbmap de bindsym $mod+F2 exec setxkbmap de ru bindsym $mod+F3 exec setxkbmap gr bindsym $mod+F4 exec setxkbmap us + +# Local Variables: +# mode: conf +# End: diff --git a/dot.config-polybar-config b/dot.config-polybar-config index 53d85ec..1f06286 100644 --- a/dot.config-polybar-config +++ b/dot.config-polybar-config @@ -1,8 +1,10 @@ +# -*- conf -*- [colors] background = #222 background-alt = #444 foreground = #dfdfdf -foreground-alt = #555 +#foreground-alt = #555 +foreground-alt = #00ff00 primary = #ffb52a secondary = #e60053 alert = #bd2c40 @@ -27,7 +29,7 @@ border-size = 4 border-color = #00000000 padding-left = 0 -padding-right = 2 +padding-right = 1 module-margin-left = 0 module-margin-right = 1 @@ -179,11 +181,11 @@ format-disconnected = type = internal/date interval = 1 -date = -date-alt = " %Y-%m-%d" +date-alt = +date = " %Y-%m-%d" -time = %H:%M -time-alt = %H:%M:%S +time-alt = %H:%M +time = %H:%M:%S format-prefix = format-prefix-foreground = ${colors.foreground-alt} diff --git a/dot.emacs.d/init.el b/dot.emacs.d/init.el index 5130c5a..102bbe0 100644 --- a/dot.emacs.d/init.el +++ b/dot.emacs.d/init.el @@ -54,21 +54,14 @@ :init (exec-path-from-shell-initialize)) (setenv "LANG" "de_DE.UTF-8")) -(use-package projectile - :config (projectile-mode 1) - :bind-keymap ("C-c p" . projectile-command-map) - :defer nil) - (use-package company :bind (:map company-mode-map ([remap completion-at-point] . #'company-complete)) :config - (global-company-mode) (setq company-tooltip-align-annotations t company-minimum-prefix-length 1)) (use-package company-math :config - (add-to-list 'company-backends 'company-math-symbols-unicode) (add-hook 'TeX-mode-hook (defun qsx-TeX-mode-hook-company () (setq-local company-backends (append '((company-math-symbols-latex company-latex-commands)) @@ -86,7 +79,6 @@ :config (add-to-list 'company-backends 'company-ansible)) (use-package company-shell :config (add-to-list 'company-backends '(company-shell company-shell-env))) -(use-package company-lsp) (semantic-mode 1) (use-package srefactor @@ -100,11 +92,13 @@ (advice-add 'python-mode :before 'elpy-enable)) (use-package lsp-mode - :commands lsp - :config (require 'lsp-clients)) + :commands lsp) (use-package lsp-ui) +(use-package company-lsp + :hook (company-mode . yas-minor-mode)) + (use-package mercurial :ensure nil :bind-keymap ("C-c H" . hg-global-map)) @@ -147,11 +141,6 @@ helm-recentf-fuzzy-match t helm-ff-file-name-history-use-recentf t helm-echo-input-in-header-line t)) -(use-package helm-projectile - :config - (setq projectile-completion-system 'helm) - (helm-projectile-on) - :after (projectile helm)) (use-package helm-rg :after helm) @@ -3,6 +3,7 @@ [ui] username = Thomas Schneider <qsx@chaotikum.eu> +tweakdefaults = true [email] method = sendmail @@ -11,20 +12,13 @@ method = sendmail gpg = histedit = mq = -pager = patchbomb = -progress = purge = rebase = -record = remotenames = strip = zeroconf = -[diff] -git = true -showfunc = true - [alias] describe = log -r . --template '{latesttag}-{latesttagdistance}-{node|short}\n' glog = log -G diff --git a/dot.local-bin-nm--tagger b/dot.local-bin-nm--tagger new file mode 100755 index 0000000..f2de0d2 --- /dev/null +++ b/dot.local-bin-nm--tagger @@ -0,0 +1,140 @@ +#!/usr/bin/env python3.7 +"""Tagging script based on mail folder names for Notmuch + +This scripts iterates through all messages with ``tag:new``, and replaces that +by tags based on the name of the maildir folder(s) the message is in. By +default, it takes the first and last component to form the name. This suits my +personal pre-Notmuch mail setup, with hierarchical IMAP folders, where the tuple +(account, last_folder) is unique for almost all folders. + +My maildirs have the account name as first component and the IMAP part as the +rest. So, for example, ``.maildir/Chaotikum/INBOX/Notmuch`` gets the tags +``Chaotikum`` and ``Notmuch``. + +Additionally, folder names can be mapped to other tag names. This can come in +handy when you need to use Exchange and its default names, yet want to keep all +sent messages—whether they are in ``.maildir/Acc/Sent`` or in +``.maildir/Exchange/Sent Messages``—under ``tag:sent``. + +See :py:func:`read_config` for configuration details. + +""" + +import json +import logging as log +from pathlib import Path +import notmuch + +DEFAULT_CONFIG = { + "folder_separator": ".", + "keep": [], + "transforms": { + "Drafts": "draft", + "INBOX": "inbox", + "Junk": "spam", + "Sent": "sent", + }, +} +"""Default config, overridden with the user-provided one""" + + +def read_config(): + """Returns the user’s config, with ``DEFAULT_CONFIG`` as base. + + The config is read from ``$XDG_CONFIG_HOME/nm-tagger/config.json`` and shall + contain three keys: + + ``folder_separator`` + The character that separates logical folder names, or + the special value ``#FILESYSTEM#``. + + For example, ``.`` means that the Maildir directories are named like + ``.maildir/This.INBOX.is.deeply.nested``. + + The value ``#FILESYSTEM#`` means to use the file system directories (on + most systems, this has the same effect as ``/``). + + ``keep`` + A list of folder names that are assigned as tags, even if they are + neither at the begin nor end. + + ``transforms`` + A dictionary mapping folder names to tags. + + """ + try: + from xdg import BaseDirectory + + config_path_base = Path(BaseDirectory.load_first_config("nm-tagger")) + except ImportError: + from os import environ + + config_path_base = environ["XDG_CONFIG_HOME"] + if config_path_base != "": + config_path_base = Path(config_path_base) + else: + config_path_base = Path.home() / ".config" / "nm-tagger" + except KeyError: + config_path_base = Path.home() / ".config" / "nm-tagger" + + config_path = config_path_base / "config.json" + + try: + with open(config_path) as fp: + config = json.load(fp) + log.info("Loaded config from %s", config_path) + log.debug("Config: %s", config) + except FileNotFoundError: + log.warn("Config file %s not found!", config_path) + config = {} + return {**DEFAULT_CONFIG, **config} + + +def main(): + """Entry point""" + log.basicConfig(format="%(asctime)s %(levelname)s: %(message)s", level=log.DEBUG) + + config = read_config() + + with notmuch.Database(mode=notmuch.Database.MODE.READ_WRITE) as db: + top = Path(db.get_path()) + log.info("Opened notmuch db at %s", top) + new_messages_query = notmuch.Query(db, "tag:new") + log.info("Found %d messages to process", new_messages_query.count_messages()) + new_messages = set(new_messages_query.search_messages()) + + db.begin_atomic() + + for m in new_messages: + mid = m.get_message_id() + _paths = {Path(p).relative_to(top) for p in m.get_filenames()} + if config["folder_separator"] == "#FILESYSTEM#": + paths = {p.parts[:-2] for p in _paths} + else: + paths = { + p.parent.parent.as_posix().split(config["folder_separator"]) + for p in _paths + } + log.debug("paths of %s: (%d) %s", mid, len(paths), str(paths)) + tags = set() + for _p in paths: + p = tuple(map(lambda c: config["transforms"].get(c, c), _p)) + tags.add(p[0]) + tags.add(p[-1]) + for c in p[1:-1]: + if c in config["keep"]: + tags.add(c) + log.debug("tags for %s: %s", mid, str(tags)) + try: + m.freeze() + for t in tags: + m.add_tag(t) + m.remove_tag("new") + finally: + m.thaw() + + db.end_atomic() + + +if __name__ == "__main__": + main() diff --git a/dot.local-bin-sm b/dot.local-bin-sm index af0edde..618392e 100755 --- a/dot.local-bin-sm +++ b/dot.local-bin-sm @@ -3,10 +3,13 @@ set -e set -x mbsync -a || true notmuch new +[ -d ~/.maildir/GMail ] && (cd ~/.maildir/GMail && gmi sync) new=$(notmuch search --output=messages tag:new | xargs) [ -z "$new" ] && exit -afew -tnvv +notmuch config set query.new "$new" +notmuch tag -new -- tag:new and folder:GMail/mail +nm-tagger export MAILSEQ="${MBLAZE:-$HOME/.mblaze}/seq.sm" export MBLAZE_PAGER="" -msearch -- --exclude=false $new | mthread | mseq -S | mscan -f '%u%r %3n %10d %17f %20F %t %i%S' -type mu 2> /dev/null && mu index || true +msearch -- --exclude=false query:new | mthread | mseq -S | mscan -f '%u%r %3n %10d %17f %20F %t %i%S' +type mu > /dev/null && mu index || true diff --git a/dot.xprofile b/dot.xprofile index 0f46d27..9735b4e 100644 --- a/dot.xprofile +++ b/dot.xprofile @@ -1,12 +1,11 @@ +# -*- shell-script -*- if [ "$XPROFILE_RUN" != "yes" ]; then export XPROFILE_RUN=yes - #export GDK_SCALE=2 - #xrandr --dpi 192 export TERMINAL=kitty-1 [ -f ~/.fehbg ] && ~/.fehbg - xss-lock -- i3lock -c 555555 -f & + xss-lock -- ~/.local/bin/i3lock-wrapper & owncloud & - #nm-applet & + type nm-applet >/dev/null && nm-applet & (while ! pidof i3; do sleep 1; done; exec polybar -r top) & fi export XPROFILE_RUN=yes diff --git a/dot.zshrc.local b/dot.zshrc.local index a1a4456..8dd9652 100644 --- a/dot.zshrc.local +++ b/dot.zshrc.local @@ -1,14 +1,21 @@ # -*- shell-script -*- +zstyle :prompt:grml:right:setup use-rprompt false . ~/.zshrc.from_grml (( $+commands[bsdtar] )) && alias tar=bsdtar -(( $+commands[chg] )) && alias hg=chg (( $+commands[nvim] )) && alias vim=nvim alias g=git alias ec="emacsclient -n" alias et="emacsclient -t" alias hl="highlight -O ansi" -zstyle :prompt:grml:left:items:percent pre ' -' +if (( $+commands[exa] )); then + alias ls="exa" + alias l="exa -g -l --git" + alias la="exa -g -la --git" +fi +if (( $+commands[rsync] )); then + alias rs="rsync -vahPi" +fi +zstyle :prompt:grml:left:items:percent pre $'\n' gpg-connect-agent /bye ssh-add -l function countdown { |
