diff options
| -rw-r--r-- | mutt/.config/mutt/binds | 4 | ||||
| -rw-r--r-- | mutt/.config/mutt/muttrc | 2 | ||||
| -rw-r--r-- | nvim/.config/nvim/init.vim | 44 | ||||
| -rwxr-xr-x | scripts/.local/bin/emailclient | 7 | ||||
| -rwxr-xr-x | scripts/.local/bin/mailclient | 6 | ||||
| -rwxr-xr-x | scripts/.local/bin/mailsync | 119 | ||||
| -rwxr-xr-x | scripts/.local/bin/sb-cpubars | 4 | ||||
| -rwxr-xr-x | scripts/.local/bin/sb-kbselect | 16 | ||||
| -rwxr-xr-x | scripts/.local/bin/sb-mailbox | 9 | ||||
| -rwxr-xr-x | scripts/.local/bin/sb-mpdup | 12 | ||||
| -rwxr-xr-x | scripts/.local/bin/sb-volume | 14 | ||||
| -rw-r--r-- | tmux/.config/tmux/tmux.conf | 10 | ||||
| -rw-r--r-- | x11/.xprofile | 20 |
13 files changed, 202 insertions, 65 deletions
diff --git a/mutt/.config/mutt/binds b/mutt/.config/mutt/binds index 291b594..771e859 100644 --- a/mutt/.config/mutt/binds +++ b/mutt/.config/mutt/binds @@ -20,7 +20,8 @@ bind generic,index k previous-entry bind generic,index j next-entry bind generic,index,pager <PageUp> previous-page bind generic,index,pager <PageDown> next-page - +bind generic,index,pager \Cd half-down +bind generic,index,pager \Cu half-up # Other odds and ends bind generic,index,pager / search @@ -64,6 +65,7 @@ bind index D delete-thread #macro index j s=Trash\n "Move to trash" bind index tc collapse-thread +bind index tac collapse-all bind index,pager H display-toggle-weed diff --git a/mutt/.config/mutt/muttrc b/mutt/.config/mutt/muttrc index cd590ab..c4c3873 100644 --- a/mutt/.config/mutt/muttrc +++ b/mutt/.config/mutt/muttrc @@ -55,3 +55,5 @@ set index_format="%4C %Z %s %* %-30.30F %d" #set query_command = "abook --mutt-query '%s'" set query_command="khard email --parsable '%s'" +# give more space to emails and names (French names can be rather long!) +set query_format="%4c %t %-55.55a %-35.35n %?e?(%e)?" diff --git a/nvim/.config/nvim/init.vim b/nvim/.config/nvim/init.vim index 5cef7f0..2eac7d8 100644 --- a/nvim/.config/nvim/init.vim +++ b/nvim/.config/nvim/init.vim @@ -64,6 +64,8 @@ call minpac#add('ivan-boikov/friendly-snippets') call minpac#add('lervag/vimtex') call minpac#add('vimwiki/vimwiki') +call minpac#add('voldikss/vim-translator') + "call minpac#add('') if empty(glob("~/.config/nvim/pack/minpac/start/friendly-snippets")) @@ -273,9 +275,9 @@ require'nvim-treesitter.configs'.setup { EOF -lua << EOF - require'lspconfig'.julials.setup{} -EOF +" lua << EOF +" require'lspconfig'.julials.setup{} +" EOF nmap <leader>ld :lua vim.lsp.buf.declaration()<CR> nmap <leader><leader> :lua vim.lsp.buf.hover()<CR> nmap <leader>ll :lua vim.lsp.util.show_line_diagnostics()<CR> @@ -353,7 +355,7 @@ lua <<EOF ['<C-Space>'] = cmp.mapping.complete(), ['<C-e>'] = cmp.mapping.abort(), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. - ['<CR>'] = cmp.mapping.confirm({ select = true }), + ['<CR>'] = cmp.mapping.confirm({ select = false }), ["<Tab>"] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_next_item() @@ -424,9 +426,9 @@ lua <<EOF require('lspconfig')['cmake'].setup { capabilities = capabilities } - require('lspconfig')['julials'].setup { - capabilities = capabilities - } + -- require('lspconfig')['julials'].setup { + -- capabilities = capabilities + -- } require'cmp'.setup { sources = { @@ -465,3 +467,31 @@ hi link juliaComma Comment hi link juliaParDelim Comment hi link juliaSemicolon Comment hi link juliaFunctionCall Function + + + + +" learning French with vim-translator! + +function! LearnFrenchMode() + " Echo translation in the cmdline + nmap <silent> <Leader>t :Translate<CR> + vmap <silent> <Leader>t :TranslateV<CR> + " Display translation in a window + nmap <silent> <Leader>w :TranslateW<CR> + vmap <silent> <Leader>w :TranslateWV<CR> + " Translate the text in clipboard + nmap <silent> <Leader>x :TranslateX<CR> + " Replace the text with translation + "nmap <silent> <Leader>e :TranslateR<CR> \| :let g:translator_target_lang='fr'<CR> + "nmap <silent> <Leader>f :TranslateR<CR> \| :let g:translator_target_lang='en'<CR> + + nmap <silent> <Leader>e <S-y> \| :pu<CR> \| :let g:translator_target_lang='en'<CR> \| <S-v> \| :TranslateR<CR>:sleep 1500m<CR> + "\| <S-i> \| <Tab> \| <Esc> + nmap <silent> <Leader>r <S-y> \| :pu<CR> \| :let g:translator_target_lang='fr'<CR> \| <S-v> \| :TranslateR<CR>:sleep 1500m<CR> + + nmap <silent> <Leader>f 0<Leader>eI<Tab><esc><Esc><Leader>rI<Tab><esc>o<backspace><Esc> + + set spl=fr +endfunction +au BufEnter,BufNew *.french :call LearnFrenchMode() diff --git a/scripts/.local/bin/emailclient b/scripts/.local/bin/emailclient deleted file mode 100755 index 23d2fce..0000000 --- a/scripts/.local/bin/emailclient +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh - -for file in $XDG_CONFIG_HOME/mutt/accounts/*; do - title="mutt: $(grep "set my_email" $file | cut -d'=' -f2 | xargs)" - "$TERMINAL" -T "$title" mutt -F "$file" & -done - diff --git a/scripts/.local/bin/mailclient b/scripts/.local/bin/mailclient new file mode 100755 index 0000000..a7bb0f0 --- /dev/null +++ b/scripts/.local/bin/mailclient @@ -0,0 +1,6 @@ +#!/bin/sh + +for file in "$XDG_CONFIG_HOME/mutt/accounts"/*; do + title="mutt: $(grep "set my_email" "$file" | cut -d'=' -f2 | xargs)" + "$TERMINAL" -T "$title" mutt -F "$file" & +done diff --git a/scripts/.local/bin/mailsync b/scripts/.local/bin/mailsync index cb00bb7..9805a54 100755 --- a/scripts/.local/bin/mailsync +++ b/scripts/.local/bin/mailsync @@ -1,13 +1,118 @@ #!/bin/sh -MBSYNC=$(pgrep mbsync) +# - Syncs mail for all accounts, or a single account given as an argument. +# - Displays a notification showing the number of new mails. +# - Displays a notification for each new mail with its subject displayed. +# - Runs notmuch to index new mail. +# - This script can be set up as a cron job for automated mail syncing. -if [ -n "$MBSYNC" ]; then - echo "Already running one instance of mbsync or notmuch. Exiting..." - exit 0 +# There are many arbitrary and ugly features in this script because it is +# inherently difficult to pass environmental variables to cronjobs and other +# issues. It also should at least be compatible with Linux (and maybe BSD) with +# Xorg and MacOS as well. + +# Run only if not already running in other instance +pgrep mbsync >/dev/null && { echo "mbsync is already running."; exit ;} + +# First, we have to get the right variables for the mbsync file, the pass +# archive, notmuch and the GPG home. This is done by searching common profile +# files for variable assignments. This is ugly, but there are few options that +# will work on the maximum number of machines. +eval "$(grep -h -- \ + "^\s*\(export \)\?\(MBSYNCRC\|MPOPRC\|PASSWORD_STORE_DIR\|PASSWORD_STORE_GPG_OPTS\|NOTMUCH_CONFIG\|GNUPGHOME\|MAILSYNC_MUTE\|XDG_CONFIG_HOME\|XDG_DATA_HOME\)=" \ + "$HOME/.profile" "$HOME/.bash_profile" "$HOME/.zprofile" "$HOME/.config/zsh/.zprofile" "$HOME/.zshenv" \ + "$HOME/.config/zsh/.zshenv" "$HOME/.bashrc" "$HOME/.zshrc" "$HOME/.config/zsh/.zshrc" \ + "$HOME/.pam_environment" 2>/dev/null)" + +# For non-interactive shell (e.g. cron job) run only when the GPG key is unlocked +tty -s || (echo "dummy" | gpg --sign --batch --pinentry-mode error -o /dev/null > /dev/null 2>&1) || exit + +export GPG_TTY="$(tty)" + +[ -n "$MBSYNCRC" ] && alias mbsync="mbsync -c $MBSYNCRC" || MBSYNCRC="$HOME/.mbsyncrc" +[ -n "$MPOPRC" ] || MPOPRC="$HOME/.config/mpop/config" + +lastrun="${XDG_CACHE_HOME:-$HOME/.cache}/.mailsynclastrun" + +# Settings are different for MacOS (Darwin) systems. +case "$(uname)" in + Darwin) notify() { osascript -e "display notification \"$2\" with title \"$1\"" ;} ;; + *) + case "$(readlink -f /sbin/init)" in + *systemd*|*openrc*) export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u)/bus ;; + esac + # remember if a display server is running since `ps` doesn't always contain a display + pgrepoutput="$(pgrep -ax X\(\|org\|wayland\))" + displays="$(echo "$pgrepoutput" | grep -wo "[0-9]*:[0-9]\+" | sort -u)" + [ -z "$displays" ] && [ -d /tmp/.X11-unix ] && displays=$(cd /tmp/.X11-unix && for x in X*; do echo ":${x#X}"; done) + + notify() { [ -n "$pgrepoutput" ] && for x in ${displays:-:0}; do + export DISPLAY="$x" + notify-send --app-name="mutt-wizard" "$1" "$2" + done ;} + ;; +esac + +# Check account for new mail. Notify if there is new content. +syncandnotify() { + case "$1" in + imap) mbsync -q "$2" ;; + pop) mpop -q "$2" ;; + esac + new=$(find\ + "$HOME/.local/share/mail/$2/"[Ii][Nn][Bb][Oo][Xx]/new/ \ + "$HOME/.local/share/mail/$2/"[Ii][Nn][Bb][Oo][Xx]/cur/ \ + -type f -newer "$lastrun" 2> /dev/null) + newcount=$(echo "$new" | sed '/^\s*$/d' | wc -l) + case 1 in + $((newcount > 5)) ) + # this echo will end up in the local spool + #echo "$newcount new mail for $2." + [ -z "$MAILSYNC_MUTE" ] && notify "$newcount new mail(s) in \`$2\` account." + ;; + $((newcount > 0)) ) + # this echo will end up in the local spool + #echo "$newcount new mail for $2." + [ -z "$MAILSYNC_MUTE" ] && + for file in $new; do + # Extract and decode subject and sender from mail. + subject="$(sed -n "/^Subject:/ s|Subject: *|| p" "$file" | + perl -CS -MEncode -ne 'print decode("MIME-Header", $_)')" + from="$(sed -n "/^From:/ s|From: *|| p" "$file" | + perl -CS -MEncode -ne 'print decode("MIME-Header", $_)')" + from="${from% *}" ; from="${from%\"}" ; from="${from#\"}" + notify "Email from $from:" "$subject" + done + ;; + # this echo will end up in the local spool + #*) echo "No new mail for $2." ;; +esac +} + +allaccounts="$(grep -hs "^\(Channel\|account\)" "$MBSYNCRC" "$MPOPRC")" + +# Get accounts to sync. All if no argument. Prefix with `error` if non-existent. +IFS=' +' +if [ -z "$1" ]; then + tosync="$allaccounts" +else + tosync="$(for arg in "$@"; do for availacc in $allaccounts; do + [ "$arg" = "${availacc##* }" ] && echo "$availacc" && break + done || echo "error $arg"; done)" fi -mbsync -c "$XDG_CONFIG_HOME/mbsync/config" -a +for account in $tosync; do + case $account in + Channel*) syncandnotify imap "${account##* }" & ;; + account*) syncandnotify pop "${account##* }" & ;; + error*) echo "ERROR: Account ${account##* } not found." ;; + esac +done + +wait + +# notmuch new --quiet -printf "%s " "Press enter to continue" -read +#Create a touch file that indicates the time of the last run of mailsync +touch "$lastrun" diff --git a/scripts/.local/bin/sb-cpubars b/scripts/.local/bin/sb-cpubars index 64cf8b0..82567a3 100755 --- a/scripts/.local/bin/sb-cpubars +++ b/scripts/.local/bin/sb-cpubars @@ -5,7 +5,7 @@ cache="$XDG_CACHE_HOME/cpubarscache" # id total idle stats=$(awk '/cpu[0-9]+/ {printf "%d %d %d\n", substr($1,4), ($2 + $3 + $4 + $5), $5 }' /proc/stat) -[ ! -f $cache ] && echo "$stats" > "$cache" +[ ! -f "$cache" ] && echo "$stats" > "$cache" old=$(cat "$cache") printf "" echo "$stats" | while read -r row; do @@ -18,6 +18,7 @@ echo "$stats" | while read -r row; do printf "%d\n", (1 - (idle - $3) / (total - $2))*100 /12.5}' \ id="$id" total="$total" idle="$idle")" in + # these are called "block elements" "0") printf "▁";; "1") printf "▂";; "2") printf "▃";; @@ -27,6 +28,7 @@ echo "$stats" | while read -r row; do "6") printf "▇";; "7") printf "█";; "8") printf "█";; + *) printf " ";; esac done; printf "\\n" echo "$stats" > "$cache" diff --git a/scripts/.local/bin/sb-kbselect b/scripts/.local/bin/sb-kbselect deleted file mode 100755 index f0c923f..0000000 --- a/scripts/.local/bin/sb-kbselect +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/sh -# works on any init system -# requirements: dmenu, xorg-setxkbmap -kb="$(setxkbmap -query | grep -oP 'layout:\s*\K\w+')" || exit 1 - -case $BLOCK_BUTTON in - 1) kb_choice="$(awk '/! layout/{flag=1; next} /! variant/{flag=0} flag {print $2, "- " $1}' /usr/share/X11/xkb/rules/base.lst | dmenu -l 15)" - kb="$(echo "$kb_choice" | awk '{print $3}')" - setxkbmap "$kb" - pkill -RTMIN+30 "${STATUSBAR:-dwmblocks}";; - 3) notify-send "⌨ Keyboard/language module" "$(printf "%s" "\- Current layout: $(setxkbmap -query | grep -oP 'layout:\s*\K\w+')") -- Left click to change keyboard.";; - 6) "$TERMINAL" -e "$EDITOR" "$0" ;; -esac - -echo "$kb" diff --git a/scripts/.local/bin/sb-mailbox b/scripts/.local/bin/sb-mailbox index 451c129..243987a 100755 --- a/scripts/.local/bin/sb-mailbox +++ b/scripts/.local/bin/sb-mailbox @@ -1,10 +1,15 @@ #!/bin/sh # Displays number of unread mail and an loading icon if updating. -# When clicked, brings up `neomutt`. unread="$(find "${XDG_DATA_HOME:-$HOME/.local/share}"/mail/*/[Ii][Nn][Bb][Oo][Xx]/new/* -type f | wc -l 2>/dev/null)" pidof mbsync >/dev/null 2>&1 && icon="U" -[ "$unread" = "0" ] && [ "$icon" = "" ] || echo "$unread$icon" +if [ $(pgrep gpg) ]; then + emailicon="" +else + emailicon="" +fi + +[ "$unread" = "0" ] && [ "$icon" = "" ] || echo "$emailicon$unread$icon" diff --git a/scripts/.local/bin/sb-mpdup b/scripts/.local/bin/sb-mpdup index af81a7d..25f80f4 100755 --- a/scripts/.local/bin/sb-mpdup +++ b/scripts/.local/bin/sb-mpdup @@ -1,8 +1,14 @@ #!/bin/sh -# This loop will update the mpd statusbar module whenever a command changes the -# music player's status. mpd must be running on X's start for this to work. +# when a command changes MPD state, print it to file for slstatus to pick up + +[ $(pgrep -cu "$(whoami)" "$(basename "$0")") -gt 1 ] && exit while : ; do - mpc idle >/dev/null && kill -45 "$(pidof "${STATUSBAR:-dwmblocks}")" || break + if mpc idle > /dev/null; then + #kill -45 "$(pidof "${STATUSBAR:-dwmblocks}")" + mpc status > "/tmp/mpd.playing" + else + break + fi done diff --git a/scripts/.local/bin/sb-volume b/scripts/.local/bin/sb-volume index be07c93..d9387b1 100755 --- a/scripts/.local/bin/sb-volume +++ b/scripts/.local/bin/sb-volume @@ -2,14 +2,14 @@ # Prints the current volume or MUT if muted. -[ $(pamixer --get-mute) = true ] && echo "MUT" && exit - -vol="$(pamixer --get-volume)" - -if [ "$vol" -gt "0" ]; then - icon="" +if [ "$(pamixer --get-mute)" = true ]; then + vol="MUT" else - echo "MUT" && exit + vol="$(pamixer --get-volume)" fi +# for slstatus +printf "%s" "$vol" > /tmp/volume + +# for dwmblocks printf "%3d" $vol diff --git a/tmux/.config/tmux/tmux.conf b/tmux/.config/tmux/tmux.conf index 8f687ba..92eb393 100644 --- a/tmux/.config/tmux/tmux.conf +++ b/tmux/.config/tmux/tmux.conf @@ -9,7 +9,9 @@ bind r source-file "$XDG_CONFIG_HOME/tmux/tmux.conf" # split panes using | and - unbind '"' unbind % +bind h split-window -h bind | split-window -h +bind v split-window -v bind - split-window -v # DWM-like pane switching with awareness of Vim splits @@ -35,10 +37,10 @@ unbind -n C-Right unbind -n C-Up unbind -n C-Down -bind -n C-Left resize-pane -L -bind -n C-Right resize-pane -R -bind -n C-Up select-pane -U -bind -n C-Down select-pane -D +bind -n C-M-Left resize-pane -L +bind -n C-M-Right resize-pane -R +bind -n C-M-Up resize-pane -U +bind -n C-M-Down resize-pane -D unbind -T copy-mode-vi 'C-h' unbind -T copy-mode-vi 'C-j' diff --git a/x11/.xprofile b/x11/.xprofile index f00b576..1fdd791 100644 --- a/x11/.xprofile +++ b/x11/.xprofile @@ -3,25 +3,25 @@ # This file runs when a DM logs you into a graphical session. # If you use startx/xinit this file will also be sourced. -xrdb $HOME/.Xresources +xrdb "$HOME/.Xresources" xrdbpid=$! # Ensure that xrdb has finished running [ -n "$xrdbpid" ] && wait "$xrdbpid" # HiDPI scaling -if [ $(xdpyinfo | awk '/dimensions/ {print $2}') == '3840x2160' ]; then +if [ "$(xdpyinfo | awk '/dimensions/ {print $2}')" == '3840x2160' ]; then xrdb -merge <<< "Xft.dpi: 192" - xrdb -merge <<< "*.font: monospace:size=12" + xrdb -merge <<< "*.font: monospace:pixelsize=12" fi # generate configs with colors from .Xresources -mkdir -pv $HOME/.config/zathura && $HOME/.local/bin/genzathurarc > $HOME/.config/zathura/zathurarc -mkdir -pv $HOME/.config/dunst && $HOME/.local/bin/gendunstrc > $HOME/.config/dunst/dunstrc +mkdir -pv "$HOME/.config/zathura" && "$HOME/.local/bin/genzathurarc" > "$HOME/.config/zathura/zathurarc" +mkdir -pv "$HOME/.config/dunst" && "$HOME/.local/bin/gendunstrc" > "$HOME/.config/dunst/dunstrc" -$HOME/.local/bin/setbg +"$HOME/.local/bin/setbg" -$HOME/.local/bin/remaps +"$HOME/.local/bin/remaps" autostart=( "xcompmgr" @@ -34,10 +34,10 @@ autostart=( ) for program in "${autostart[@]}" ; do - pidof -s "${program%% *}" || setsid -f $program -done >$XDG_CACHE_HOME/xprofile.errors 2>&1 + pidof -s "${program%% *}" || setsid -f "$program" +done >"$XDG_CACHE_HOME/xprofile.errors" 2>&1 -$HOME/.local/bin/startxautolock +"$HOME/.local/bin/startxautolock" gentoo-pipewire-launcher restart & |
