dotfiles

Dotfiles for my OpenBSD environment.
Log | Files | Refs

commit 975e7dbd21c4b894c12516fd7a456ca85773aed1
parent 2894e612333d8c2981aaf2a3a23f35e4d1430eae
Author: Matsuda Kenji <contact2655@matsudakenji.xyz>
Date:   Wed, 15 Jun 2022 17:32:00 +0900

update config

Diffstat:
M.config/X11/xinitrc | 2+-
M.config/fontconfig/fonts.conf | 2+-
M.config/mutt/conf.d/sakura | 3++-
M.config/mutt/muttrc | 3++-
M.config/mutt/passwd/gmail.gpg | 0
A.config/mutt/passwd/sakura.rsa | 0
A.profile | 35+++++++++++++++++++++++++++++++++++
M.shrc | 1+
Mbin/dwm_blocks_battery.sh | 12++----------
Mbin/dwm_blocks_volume.sh | 2+-
Mbin/dwm_blocks_wifi.sh | 4++--
Mbin/pass | 105++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------
Mpasswords.gpg | 0
13 files changed, 143 insertions(+), 26 deletions(-)

diff --git a/.config/X11/xinitrc b/.config/X11/xinitrc @@ -30,7 +30,7 @@ export LESSHISTFILE=- export BROWSER="firefox" export TERMINAL="st" -export EDITOR=vim +export EDITOR="nvi" export PATH="$PATH:$HOME/bin:/usr/local/heirloom-doctools/bin:$HOME/.local/src/kotoriotoko/BIN" export LC_CTYPE=en_US.UTF-8 diff --git a/.config/fontconfig/fonts.conf b/.config/fontconfig/fonts.conf @@ -25,7 +25,7 @@ <alias> <family>monospace</family> <prefer> - <family>Liberation Mono</family> + <family>DejaVu Sans Mono</family> <family>Noto Emoji</family> <family>Noto Serif CJK JP</family> </prefer> diff --git a/.config/mutt/conf.d/sakura b/.config/mutt/conf.d/sakura @@ -1,4 +1,4 @@ -source "gpg -d ~/.config/mutt/passwd/sakura.gpg |" +source "openssl rsautl -decrypt -inkey ~/rsa/key -in ~/.config/mutt/passwd/sakura.rsa |" set hostname = "matsudakenji.xyz" set from = "contact2655@matsudakenji.xyz" @@ -17,6 +17,7 @@ named-mailboxes \ s_inbox =INBOX \ KBUG =KBUG \ KUAC =KUAC \ + Chikyumori =Chikyumori \ s_draft =Drafts \ s_sent =Sent \ s_trash =Trash diff --git a/.config/mutt/muttrc b/.config/mutt/muttrc @@ -16,7 +16,7 @@ set ssl_starttls = yes set ssl_force_tls = yes # basic -set editor = "vim" +set editor = "nim" set charset = "utf-8" set certificate_file = "./certificates" set mailcap_path = "~/.config/mutt/mailcap" @@ -26,6 +26,7 @@ set pager = less unset prompt_after set sort = reverse-date bind index <Esc>r group-chat-reply +set message_cachedir = "~/.cache/mutt" #sidebar set sidebar_visible diff --git a/.config/mutt/passwd/gmail.gpg b/.config/mutt/passwd/gmail.gpg Binary files differ. diff --git a/.config/mutt/passwd/sakura.rsa b/.config/mutt/passwd/sakura.rsa Binary files differ. diff --git a/.profile b/.profile @@ -0,0 +1,35 @@ +#!/bin/sh + +export ENV=$HOME/.shrc + +# ~/ clean up: +export XDG_CONFIG_HOME="$HOME/.config" +export XDG_CACHE_HOME="$HOME/.cache" +export XDG_DATA_HOME="$HOME/.local/share" +export XDG_RUNTIME_DIR="/tmp/xdg_runtime_dir_$USER" +export VIMINIT=":source $XDG_CONFIG_HOME"/vim/vimrc +export VIM="$XDG_CONFIG_HOME/vim" +[ ! -d $XDG_CONFIG_HOME ] && mkdir -p $XDG_CONFIG_HOME +[ ! -d $XDG_CACHE_HOME ] && mkdir -p $XDG_CACHE_HOME +[ ! -d $XDG_DATA_HOME ] && mkdir -p $XDG_DATA_HOME +[ ! -d $XDG_RUNTIME_DIR ] && mkdir -p $XDG_RUNTIME_DIR + +export HISTFILE="$XDG_CACHE_HOME/sh_history" + +export X11HOME="$XDG_CONFIG_HOME/X11" +export XINITRC="$X11HOME/xinitrc" +#export XAUTHORITY="$XDG_CACHE_HOME/X11/Xauthority" +[ ! -d $X11HOME ] && mkdir -p $X11HOME +[ ! -d $XDG_CACHE_HOME/X11 ] && mkdir -p $XDG_CACHE_HOME/X11 +#gnupg + +export GNUPGHOME="$XDG_CONFIG_HOME/gnupg" + +# less +export LESSHISTFILE=- + +export BROWSER="firefox" +export TERMINAL="st" +export EDITOR="nvi" +export PATH="$PATH:$HOME/bin:/usr/local/heirloom-doctools/bin:$HOME/.local/src/kotoriotoko/BIN" +export LC_CTYPE=en_US.UTF-8 diff --git a/.shrc b/.shrc @@ -4,5 +4,6 @@ PS1='[\u@\h \W]\$ ' alias w3m='w3m -o keymap_file=~/.config/w3m/keymap' alias tmux='tmux -f /home/kenji/.config/tmux/tmux.conf' +alias ls='ls -1' set -o vi -o posix export GPG_TTY=$(tty) diff --git a/bin/dwm_blocks_battery.sh b/bin/dwm_blocks_battery.sh @@ -4,17 +4,9 @@ online=$(apm -a) capacity=$(apm -l) if [ "$online" = "1" ]; then - state= -elif [ "$capacity" -gt 90 ]; then - state= -elif [ "$capacity" -gt 63 ]; then - state= -elif [ "$capacity" -gt 38 ]; then - state= -elif [ "$capacity" -gt 10 ]; then - state= + state="AC" else - state= + state="BAT" fi echo "$state ${capacity}" diff --git a/bin/dwm_blocks_volume.sh b/bin/dwm_blocks_volume.sh @@ -1,6 +1,6 @@ #!/bin/sh mute=$(sndioctl -n output.mute) -[ "$mute" = 1 ] && state= || state= +[ "$mute" = 1 ] && state="MUTE" || state="VOL" volume=$(printf '%.0f' $(echo $(sndioctl -n output.level) '*' 100 | bc)) echo "$state ${volume}" diff --git a/bin/dwm_blocks_wifi.sh b/bin/dwm_blocks_wifi.sh @@ -1,4 +1,4 @@ #!/bin/sh -ifconfig em0 | awk '/active/{printf ""}' -ifconfig iwn0 | awk '/active/{printf ""}/no network/{printf " down\n"}/join/{printf "%s\n", $3}' +ifconfig em0 | awk '/active/{printf "ETH "}' +ifconfig iwn0 | awk '/active/{printf "WIFI "}/no network/{printf "down\n"}/join/{printf "%s\n", $3}' diff --git a/bin/pass b/bin/pass @@ -1,11 +1,98 @@ -#!/bin/sh +#!/bin/sh +basedir="$HOME/passwords" +private_key="$HOME/rsa/key" +public_key="$HOME/rsa/key.pub" -passwords=~/.local/dotfiles/passwords.gpg +fail() { echo "$1"; exit 1; } +should_exist() { if [ ! -f "$1" ]; then fail "Can't find $1."; fi; } +should_not_exist() { if [ -f "$1" ]; then fail "$1 already exists."; fi; } +should_be_dir() { if [ ! -d "$1" ]; then fail "$1 is not a directory."; fi; } +should_be_defined() { if [ ! "$1" ]; then fail "$2 should be defined."; fi; } -p=$(gpg -d "$passwords") -item=$(echo "$p" | awk '{print $1, $3}' | dmenu -i -l 5 ) -[ -n "$item" ] || exit -echo "$item" | awk '{print $2}' -name=$(echo "$item" | awk '{print $1}') -id=$(echo "$item" | awk '{print $2}') -echo "$p" | awk -v name=$name -v id=$id '$1==name&&$3==id' | sed 's/.* //' | xclip -r -selection clip +keygen() { + should_not_exist "$private_key" + should_be_dir "$(dirname "$private_key")" + should_not_exist "$public_key" + should_be_dir "$(dirname "$public_key")" + + printf 'New pass phrase: '; stty -echo; read -r pass; stty echo; printf '\n' + if [ ! "$pass" ]; then fail 'The pass phrase cannot be empty.'; fi + printf 'Confirm: '; stty -echo; read -r pass_confirm; stty echo; printf '\n' + + if [ "$pass" = "$pass_confirm" ]; then + openssl genrsa 2048 | + openssl pkcs8 -topk8 -inform pem -outform pem -out "$private_key" -v2 aes256 -passout "pass:$pass" + chmod 0400 "$private_key" + openssl rsa -in "$private_key" -out "$public_key" -outform pem -pubout -passin "pass:$pass" + chmod 0600 "$public_key" + else + fail 'Pass phrase mismatch.' + fi +} + +encrypt(){ + enc_file="$1" + data="$2" + should_be_defined "$enc_file" "Target file path" + should_be_defined "$data" "Input data" + file_dir="$(dirname "$enc_file")" + mkdir -p "$file_dir"; chmod 0700 "$file_dir" + should_be_dir "$file_dir" + should_exist "$public_key" + should_not_exist "$enc_file" + + + echo "$data" | + openssl rsautl -encrypt -pubin -inkey "$public_key" -out "$enc_file" + chmod 0600 "$enc_file" +} + +decrypt(){ + enc_file="$basedir/$1" + if [ "$2" ]; then pass="$2"; fi + should_be_defined "$enc_file" "Target file path" + should_exist "$private_key" + should_exist "$enc_file" + + if [ "$pass" ]; then + openssl rsautl -decrypt -inkey "$private_key" -in "$enc_file" -passin "pass:$pass" + else + openssl rsautl -decrypt -inkey "$private_key" -in "$enc_file" + fi +} + +if [ "$2" ]; then ID="$2"; fi +if [ "$3" ]; then pass="$3"; fi + +case "$1" in +init) + mkdir -p "$basedir"; chmod 0700 "$basedir" + keygen + ;; +export) + should_be_defined "$ID" "ID" + decrypt "$ID" "$pass" + ;; +add) + read "site?site: " + read "url?url: " + read "user?user: " + stty -echo; read "pass?pass: "; stty echo; printf '\n' + target="$basedir/$site/$user" + data=$(printf "$url\n$pass") + encrypt "$target" "$data" + ;; +ls) + cd "$basedir" + find . -type f ! -name *.key* | cut -f2,3 -d'/' | sort + ;; +dmenu) + ID=$("$0" ls | dmenu -l 5) + pass=$(dmenu -P -p "Password:") + "$0" export "$ID" "$pass" | tail -n1 | xclip -r -selection clip + + ;; +*) + echo 'usage: '"$0"' [init|add|export|ls|dmenu]' + ;; +esac diff --git a/passwords.gpg b/passwords.gpg Binary files differ.