commit ae9d2ac2cdddf4494c993cd1569fedbe41b09f52
parent 52d10969b3d5799bd14aea3412bd7e1e33979a5e
Author: Oscar Benedito <oscar@oscarbenedito.com>
Date:   Thu,  9 Dec 2021 00:47:12 +0100

Multiple changes to multiple files

Diffstat:
M.config/git/config | 2++
M.config/nvim/autoload/plug.vim | 3++-
M.config/zsh/.zshenv | 1+
M.config/zsh/aliases | 14++++++++++++--
M.local/bin/dwmblocks/dwmb-torrents | 3++-
M.local/bin/dwmblocks/dwmb-volume | 187+++++++------------------------------------------------------------------------
M.local/bin/session-dmenu | 5++---
7 files changed, 37 insertions(+), 178 deletions(-)

diff --git a/.config/git/config b/.config/git/config @@ -31,3 +31,5 @@ smtpserverport = 587 [commit] gpgsign = true +[init] + defaultBranch = main diff --git a/.config/nvim/autoload/plug.vim b/.config/nvim/autoload/plug.vim @@ -1208,7 +1208,8 @@ function! s:update_impl(pull, force, args) abort normal! 2G silent! redraw - let s:clone_opt = [] + " Set remote name, overriding a possible user git config's clone.defaultRemoteName + let s:clone_opt = ['--origin', 'origin'] if get(g:, 'plug_shallow', 1) call extend(s:clone_opt, ['--depth', '1']) if s:git_version_requirement(1, 7, 10) diff --git a/.config/zsh/.zshenv b/.config/zsh/.zshenv @@ -30,6 +30,7 @@ export PAGER="less" export TERMINAL="alacritty" export SUDO_ASKPASS="$HOME/.local/bin/sudoaskpass-dmenu" export GPG_TTY="$(tty)" +export PASSWORD_STORE_GENERATED_LENGTH=16 # Go bin to path [ -d "$GOPATH/bin" ] && export PATH="$PATH:$GOPATH/bin" diff --git a/.config/zsh/aliases b/.config/zsh/aliases @@ -37,6 +37,7 @@ alias ca="cal -m -3" # frequent files and directories alias cfa="$EDITOR $XDG_CONFIG_HOME/zsh/aliases" +alias cfe="$EDITOR $XDG_CONFIG_HOME/zsh/.zshenv" alias cfg="$EDITOR $XDG_CONFIG_HOME/git/config" alias cfp="$EDITOR $HOME/.profile" alias cfv="$EDITOR $XDG_CONFIG_HOME/nvim/init.vim" @@ -52,7 +53,7 @@ alias dw="cd $HOME/Downloads && ls" # dotfiles' repository metafiles c-clean() { - rm README.md COPYING + rm $HOME/README.md $HOME/COPYING c update-index --skip-worktree README.md COPYING } @@ -74,11 +75,20 @@ unite-pdf() { restart-wifi-daemon() { while true; do curl -Is http://oscarbenedito.com > /dev/null || \ - { printf "Restarting wifi..."; nmcli radio wifi off; sleep 1; nmcli radio wifi on; printf " done\n"; } + { printf "Restarting wifi..."; restart-wifi; printf " done at "; date +"%a %d %b, %H:%M"; printf "\n"; } sleep 30 done } +restart-wifi() { + printf "Restarting wifi..."; + nmcli radio wifi off; + sleep 1; + nmcli radio wifi on; + printf " done: "; + date +"%a %d %b, %H:%M"; +} + mount-banc() { sudo mkdir -p /run/media/oscar/banc || return sudo chown oscar:oscar /run/media/oscar/banc diff --git a/.local/bin/dwmblocks/dwmb-torrents b/.local/bin/dwmblocks/dwmb-torrents @@ -8,5 +8,6 @@ transmission-remote -l | grep "%\|n/a" | s/.*Uploading.*/E /; s/.*Seeding.*/F /; s/.*100%.*/G /; - s/.*%.*/A /" | + s/.*%.*/A /; + s/.*Downloading.*/A /" | sort -h | uniq -c | awk '{print $3, $1}' | paste -sd ' ' - diff --git a/.local/bin/dwmblocks/dwmb-volume b/.local/bin/dwmblocks/dwmb-volume @@ -1,182 +1,27 @@ #!/usr/bin/env bash # Displays the default device, volume, and mute status for i3blocks -set -a -AUDIO_HIGH_SYMBOL=${AUDIO_HIGH_SYMBOL:-""} +AUDIO_HIGH_SYMBOL="" +AUDIO_MED_SYMBOL="" +AUDIO_LOW_SYMBOL="" +AUDIO_MUTED_SYMBOL="" -AUDIO_MED_THRESH=${AUDIO_MED_THRESH:-50} -AUDIO_MED_SYMBOL=${AUDIO_MED_SYMBOL:-""} +AMIXER=$(amixer get Master | tail -n 1) # get last line of amixer output -AUDIO_LOW_THRESH=${AUDIO_LOW_THRESH:-0} -AUDIO_LOW_SYMBOL=${AUDIO_LOW_SYMBOL:-""} +# show either volume or mute +if [[ $AMIXER =~ "[on]" ]]; then # check if channel is muted by checking if line contains the word "on" + IFS=' ' read -ra args <<< "$AMIXER" # split string -AUDIO_MUTED_SYMBOL=${AUDIO_MUTED_SYMBOL:-""} + VOL="${args[4]:1:-2}" # get 4th argument (the volume) from the string we just split and remove the first and last argument (square brackets) and the % at the end -AUDIO_DELTA=${AUDIO_DELTA:-5} - -DEFAULT_COLOR=${DEFAULT_COLOR:-"#ffffff"} -MUTED_COLOR=${MUTED_COLOR:-"#a0a0a0"} - -LONG_FORMAT=${LONG_FORMAT:-'${SYMB} ${VOL}%'} -SHORT_FORMAT=${SHORT_FORMAT:-'${SYMB} ${VOL}% [${INDEX}]'} -MUTED_FORMAT=${MUTED_FORMAT:-'${SYMB}'} -USE_ALSA_NAME=${USE_ALSA_NAME:-0} -USE_DESCRIPTION=${USE_DESCRIPTION:-0} - -SUBSCRIBE=${SUBSCRIBE:-0} - -MIXER=${MIXER:-""} -SCONTROL=${SCONTROL:-""} - -while getopts F:Sf:adH:M:L:X:T:t:C:c:i:m:s:h opt; do - case "$opt" in - S) SUBSCRIBE=1 ;; - F) LONG_FORMAT="$OPTARG" ;; - f) SHORT_FORMAT="$OPTARG" ;; - a) USE_ALSA_NAME=1 ;; - d) USE_DESCRIPTION=1 ;; - H) AUDIO_HIGH_SYMBOL="$OPTARG" ;; - M) AUDIO_MED_SYMBOL="$OPTARG" ;; - L) AUDIO_LOW_SYMBOL="$OPTARG" ;; - X) AUDIO_MUTED_SYMBOL="$OPTARG" ;; - T) AUDIO_MED_THRESH="$OPTARG" ;; - t) AUDIO_LOW_THRESH="$OPTARG" ;; - C) DEFAULT_COLOR="$OPTARG" ;; - c) MUTED_COLOR="$OPTARG" ;; - i) AUDIO_INTERVAL="$OPTARG" ;; - m) MIXER="$OPTARG" ;; - s) SCONTROL="$OPTARG" ;; - h) printf \ -"Usage: volume-pulseaudio [-S] [-F format] [-f format] [-p] [-a|-d] [-H symb] [-M symb] - [-L symb] [-X symb] [-T thresh] [-t thresh] [-C color] [-c color] [-i inter] - [-m mixer] [-s scontrol] [-h] -Options: --F, -f\tOutput format (-F long format, -f short format) to use, with exposed variables: -\${SYMB}, \${VOL}, \${INDEX}, \${NAME} --S\tSubscribe to volume events (requires persistent block, always uses long format) --a\tUse ALSA name if possible --d\tUse device description instead of name if possible --H\tSymbol to use when audio level is high. Default: '$AUDIO_HIGH_SYMBOL' --M\tSymbol to use when audio level is medium. Default: '$AUDIO_MED_SYMBOL' --L\tSymbol to use when audio level is low. Default: '$AUDIO_LOW_SYMBOL' --X\tSymbol to use when audio is muted. Default: '$AUDIO_MUTED_SYMBOL' --T\tThreshold for medium audio level. Default: $AUDIO_MED_THRESH --t\tThreshold for low audio level. Default: $AUDIO_LOW_THRESH --C\tColor for non-muted audio. Default: $DEFAULT_COLOR --c\tColor for muted audio. Default: $MUTED_COLOR --i\tInterval size of volume increase/decrease. Default: $AUDIO_DELTA --m\tUse the given mixer. --s\tUse the given scontrol. --h\tShow this help text -" && exit 0;; - esac -done - -if [[ -z "$MIXER" ]] ; then - MIXER="default" - if amixer -D pulse info >/dev/null 2>&1 ; then - MIXER="pulse" - fi -fi - -if [[ -z "$SCONTROL" ]] ; then - SCONTROL=$(amixer -D "$MIXER" scontrols | sed -n "s/Simple mixer control '\([^']*\)',0/\1/p" | head -n1) -fi - -CAPABILITY=$(amixer -D $MIXER get $SCONTROL | sed -n "s/ Capabilities:.*cvolume.*/Capture/p") - - -function move_sinks_to_new_default { - DEFAULT_SINK=$1 - pacmd list-sink-inputs | grep index: | grep -o '[0-9]\+' | while read SINK - do - pacmd move-sink-input $SINK $DEFAULT_SINK - done -} - -function set_default_playback_device_next { - inc=${1:-1} - num_devices=$(pacmd list-sinks | grep -c index:) - sink_arr=($(pacmd list-sinks | grep index: | grep -o '[0-9]\+')) - default_sink_index=$(( $(pacmd list-sinks | grep index: | grep -no '*' | grep -o '^[0-9]\+') - 1 )) - default_sink_index=$(( ($default_sink_index + $num_devices + $inc) % $num_devices )) - default_sink=${sink_arr[$default_sink_index]} - pacmd set-default-sink $default_sink - move_sinks_to_new_default $default_sink -} - -case "$BLOCK_BUTTON" in - 1) set_default_playback_device_next ;; - 2) amixer -q -D $MIXER sset $SCONTROL $CAPABILITY toggle ;; - 3) set_default_playback_device_next -1 ;; - 4) amixer -q -D $MIXER sset $SCONTROL $CAPABILITY $AUDIO_DELTA%+ ;; - 5) amixer -q -D $MIXER sset $SCONTROL $CAPABILITY $AUDIO_DELTA%- ;; -esac - -function print_format { - echo "$1" | envsubst '${SYMB}${VOL}${INDEX}${NAME}' -} - -function print_block { - ACTIVE=$(pacmd list-sinks | grep "state\: RUNNING" -B4 -A7 | grep "index:\|name:\|volume: \(front\|mono\)\|muted:") - [ -z "$ACTIVE" ] && ACTIVE=$(pacmd list-sinks | grep "index:\|name:\|volume: \(front\|mono\)\|muted:" | grep -A3 '*') - for name in INDEX NAME VOL MUTED; do - read $name - done < <(echo "$ACTIVE") - INDEX=$(echo "$INDEX" | grep -o '[0-9]\+') - VOL=$(echo "$VOL" | grep -o "[0-9]*%" | head -1 ) - VOL="${VOL%?}" - - NAME=$(echo "$NAME" | sed \ -'s/.*<.*\.\(.*\)>.*/\1/; t;'\ -'s/.*<\(.*\)>.*/\1/; t;'\ -'s/.*/unknown/') - - if [[ $USE_ALSA_NAME == 1 ]] ; then - ALSA_NAME=$(pacmd list-sinks |\ -awk '/^\s*\*/{f=1}/^\s*index:/{f=0}f' |\ -grep "alsa.name\|alsa.mixer_name" |\ -head -n1 |\ -sed 's/.*= "\(.*\)".*/\1/') - NAME=${ALSA_NAME:-$NAME} - elif [[ $USE_DESCRIPTION == 1 ]] ; then - DESCRIPTION=$(pacmd list-sinks |\ -awk '/^\s*\*/{f=1}/^\s*index:/{f=0}f' |\ -grep "device.description" |\ -head -n1 |\ -sed 's/.*= "\(.*\)".*/\1/') - NAME=${DESCRIPTION:-$NAME} - fi - - if [[ $MUTED =~ "no" ]] ; then - SYMB=$AUDIO_HIGH_SYMBOL - [[ $VOL -le $AUDIO_MED_THRESH ]] && SYMB=$AUDIO_MED_SYMBOL - [[ $VOL -le $AUDIO_LOW_THRESH ]] && SYMB=$AUDIO_LOW_SYMBOL - COLOR=$DEFAULT_COLOR - else - SYMB=$AUDIO_MUTED_SYMBOL - #COLOR=$MUTED_COLOR - COLOR=$DEFAULT_COLOR - fi - - if [[ $SUBSCRIBE == 1 ]] ; then - print_format "$LONG_FORMAT" + if [ "$VOL" -le "0" ]; then + echo "$AUDIO_LOW_SYMBOL" + elif [ "$VOL" -le "50" ]; then + echo "$AUDIO_MED_SYMBOL $VOL%" else - if [[ $MUTED =~ "no" ]] && [ $VOL != $AUDIO_LOW_THRESH ]; then - print_format "$LONG_FORMAT" - print_format "$SHORT_FORMAT" - else - print_format "$MUTED_FORMAT" - print_format "$MUTED_FORMAT" - fi -# echo "$COLOR" + echo "$AUDIO_HIGH_SYMBOL $VOL%" fi -} - -print_block -if [[ $SUBSCRIBE == 1 ]] ; then - while read -r EVENT; do - print_block - done < <(pactl subscribe | stdbuf -oL grep change) +else + echo "$AUDIO_MUTED_SYMBOL" fi diff --git a/.local/bin/session-dmenu b/.local/bin/session-dmenu @@ -3,9 +3,8 @@ cmds="\ lock | slock exit | kill -TERM $(pidof -s dwm) -hibernate | sudo -A systemctl suspend-then-hibernate -reboot | sudo -A reboot -shutdown | sudo -A shutdown now" +reboot | reboot +shutdown | shutdown now" choice="$(echo "$cmds" | sed "s/ *|/|/g" | cut -d'|' -f 1 | dmenu)" || exit 1