dotfiles

My collection of dotfiles
git clone git://git.noxz.tech/dotfiles
Log | Files | Refs

commit bb84cc7c9830075bb0040a45ae3aa133e330f6cd
parent 193775e37f0cd807abe78002977be61e30ed0800
Author: Chris Noxz <chris@noxz.tech>
Date:   Sun, 29 Mar 2020 18:18:33 +0200

[bin] change indent to tabs

Diffstat:
Mbin/.local/bin/alias/backup | 48+++++++++++++++++++++++-------------------------
Mbin/.local/bin/alias/calcurse | 7++++---
Mbin/.local/bin/alias/fd | 2+-
Mbin/.local/bin/alias/fdr | 4++--
Mbin/.local/bin/alias/fe | 2+-
Mbin/.local/bin/alias/isopen | 28++++++++++++++--------------
Mbin/.local/bin/alias/make | 8++++----
Mbin/.local/bin/alias/ssh | 2+-
Mbin/.local/bin/alias/vimb-tabbed | 6+++---
Mbin/.local/bin/auto-open | 30+++++++++++++++---------------
Mbin/.local/bin/borg-stat | 15+++++++--------
Mbin/.local/bin/clipd | 80++++++++++++++++++++++++++++++++++++++++----------------------------------------
Dbin/.local/bin/colors-256 | 93-------------------------------------------------------------------------------
Mbin/.local/bin/compile | 92++++++++++++++++++++++++++++++++++++++++----------------------------------------
Mbin/.local/bin/dmenu_bookmarks | 10+++++-----
Mbin/.local/bin/dmenu_confirm | 4++--
Mbin/.local/bin/dmenu_layouts | 12++++++------
Mbin/.local/bin/dmenu_main | 82+++++++++++++++++++++++++++++++++++++++----------------------------------------
Mbin/.local/bin/dmenu_man | 6+++---
Mbin/.local/bin/dmenu_mount | 38+++++++++++++++++++-------------------
Mbin/.local/bin/dmenu_passmenu | 14+++++++-------
Mbin/.local/bin/dmenu_power | 22+++++++++++-----------
Mbin/.local/bin/dmenu_radio | 21++++++++++++---------
Mbin/.local/bin/dmenu_sscw | 8++++----
Mbin/.local/bin/dmenu_themes | 4++--
Mbin/.local/bin/dmenu_todo | 44++++++++++++++++++++++----------------------
Mbin/.local/bin/dmenu_umount | 38+++++++++++++++++++-------------------
Mbin/.local/bin/dmenu_url_extract | 10+++++-----
Mbin/.local/bin/dmenu_vtc | 110++++++++++++++++++++++++++++++++++++++++----------------------------------------
Mbin/.local/bin/dmenu_yt_search | 58+++++++++++++++++++++++++++++-----------------------------
Mbin/.local/bin/dwm-run | 2+-
Mbin/.local/bin/fetch-icals | 116++++++++++++++++++++++++++++++++++++++-----------------------------------------
Mbin/.local/bin/fix-home-permissions | 18+++++++++---------
Mbin/.local/bin/fzf-history.tmux | 8++++----
Mbin/.local/bin/fzf-move-to.tmux | 16++++++++--------
Mbin/.local/bin/fzf-url.tmux | 38+++++++++++++++++++-------------------
Mbin/.local/bin/gen-adblock | 14+++++++-------
Mbin/.local/bin/generate-mutt-alias | 10+++++-----
Mbin/.local/bin/lbry2rss | 72++++++++++++++++++++++++++++++++++++------------------------------------
Mbin/.local/bin/listen-new-mail | 14+++++++-------
Mbin/.local/bin/listen-new-pkg | 6+++---
Mbin/.local/bin/mbsync-stdin | 10+++++-----
Mbin/.local/bin/mkthemes | 34+++++++++++++++++-----------------
Mbin/.local/bin/mnt | 82++++++++++++++++++++++++++++++++++++++++----------------------------------------
Mbin/.local/bin/monitor | 82++++++++++++++++++++++++++++++++++++++++----------------------------------------
Mbin/.local/bin/msmtp-tpl | 10+++++-----
Mbin/.local/bin/nrowgrid.tmux | 153++++++++++++++++++++++++++++++++++++++-----------------------------------------
Mbin/.local/bin/operations | 72++++++++++++++++++++++++++++++++++++------------------------------------
Mbin/.local/bin/print-sxhkd | 40++++++++++++++++++++--------------------
Mbin/.local/bin/proxify | 78+++++++++++++++++++++++++++++++++++++++---------------------------------------
Mbin/.local/bin/repo-graph | 510++++++++++++++++++++++++++++++++++++++++----------------------------------------
Mbin/.local/bin/screenrec | 10+++++-----
Mbin/.local/bin/set-wallpaper | 16++++++++--------
Mbin/.local/bin/ssh-add-pass | 12++++++------
Mbin/.local/bin/ssh-agent-init | 14+++++++-------
Mbin/.local/bin/status.tmux | 30+++++++++++++++---------------
Mbin/.local/bin/timer | 24++++++++++++------------
Mbin/.local/bin/tmstat | 14+++++++-------
Mbin/.local/bin/vifmimg | 114++++++++++++++++++++++++++++++++++++++++----------------------------------------
Mbin/.local/bin/vifmrun | 4++--
Mbin/.local/bin/web-report | 48++++++++++++++++++++++++------------------------
61 files changed, 1233 insertions(+), 1336 deletions(-)

diff --git a/bin/.local/bin/alias/backup b/bin/.local/bin/alias/backup @@ -5,29 +5,27 @@ read answer && [ "$answer" = "${answer#[Yy]}" ] && return select _repo in local remote do - case "$_repo" in - local) - borg create \ - --stats \ - --progress \ - --compression lz4 \ - --exclude "$HOME/mnt" \ - --exclude "$HOME/downloads" \ - --exclude "$HOME/.cache" \ - ::{user}-{now} "$HOME" - return ;; - remote) - borg create \ - --stats \ - --progress \ - --compression lz4 \ - --exclude "$HOME/mnt" \ - --exclude "$HOME/downloads" \ - --exclude "$HOME/.cache" \ - backup:void42::{user}-{now} "$HOME" - return ;; - *) - echo "select a valid option" - ;; - esac + case "$_repo" in + local) + borg create \ + --stats \ + --progress \ + --compression lz4 \ + --exclude "$HOME/mnt" \ + --exclude "$HOME/downloads" \ + --exclude "$HOME/.cache" \ + ::{user}-{now} "$HOME" + return ;; + remote) + borg create \ + --stats \ + --progress \ + --compression lz4 \ + --exclude "$HOME/mnt" \ + --exclude "$HOME/downloads" \ + --exclude "$HOME/.cache" \ + backup:void42::{user}-{now} "$HOME" + return ;; + *) echo "select a valid option" ;; + esac done diff --git a/bin/.local/bin/alias/calcurse b/bin/.local/bin/alias/calcurse @@ -1,6 +1,7 @@ #!/bin/sh /bin/calcurse \ - -C "$XDG_CONFIG_HOME/calcurse" \ - -D "$XDG_DATA_HOME/calcurse" \ - -c "$XDG_DATA_HOME/calcurse/cals"/$(ls "$XDG_DATA_HOME/calcurse/cals" | fzf) "$@" + -C "$XDG_CONFIG_HOME/calcurse" \ + -D "$XDG_DATA_HOME/calcurse" \ + -c "$XDG_DATA_HOME/calcurse/cals"/$( + ls "$XDG_DATA_HOME/calcurse/cals" | fzf) "$@" diff --git a/bin/.local/bin/alias/fd b/bin/.local/bin/alias/fd @@ -1,5 +1,5 @@ #!/bin/sh _dir="$(find ${1:-.} -type d 2>/dev/null | fzf-tmux +m --select-1 --exit-0)"\ - && cd "$_dir" + && cd "$_dir" unset _dir diff --git a/bin/.local/bin/alias/fdr b/bin/.local/bin/alias/fdr @@ -4,8 +4,8 @@ _dir="$(realpath "${1:-$PWD}")" _dirs="$_dir" while [ -d "$_dir" ]; do - [ "$_dir" != '/' ] && _dir="$(dirname "$_dir")" || break - _dirs="$_dir\n$_dirs" + [ "$_dir" != '/' ] && _dir="$(dirname "$_dir")" || break + _dirs="$_dir\n$_dirs" done cd "$(echo "$_dirs" | fzf-tmux --tac)" diff --git a/bin/.local/bin/alias/fe b/bin/.local/bin/alias/fe @@ -1,5 +1,5 @@ #!/bin/sh _file="$(find ${1:-.} -type f 2>/dev/null | fzf-tmux +m --select-1 --exit-0)"\ - && ${EDITOR:-vim} "$_file" + && ${EDITOR:-vim} "$_file" unset _file diff --git a/bin/.local/bin/alias/isopen b/bin/.local/bin/alias/isopen @@ -1,19 +1,19 @@ #!/bin/sh if [ -n "$1" ] && [ "$1" != "" ] && [ -n "$2" ] && [ "$2" != "" ]; then - case "$2" in - ''|*[!0-9]*) echo "PORT is not a number" ;; - *) - case $(( - ($2 <= 0) * 1 + - ($2 > 65535) * 2 - )) in - (1) echo "PORT must be greater than 0" ;; - (2) echo "PORT must be lower than or equal to 65535" ;; - (0) nc -vzw 1 "$1" "$2" ;; - esac - ;; - esac + case "$2" in + ''|*[!0-9]*) echo "PORT is not a number" ;; + *) + case $(( + ($2 <= 0) * 1 + + ($2 > 65535) * 2 + )) in + (1) echo "PORT must be greater than 0" ;; + (2) echo "PORT must be lower than or equal to 65535" ;; + (0) nc -vzw 1 "$1" "$2" ;; + esac + ;; + esac else - echo "usage: isopen ADDRESS PORT" + echo "usage: isopen ADDRESS PORT" fi diff --git a/bin/.local/bin/alias/make b/bin/.local/bin/alias/make @@ -2,10 +2,10 @@ exec 4>&1 ( sed \ - -e "s/^\(.*warning.*\)$/$(tput setaf 3; tput bold)\1$(tput sgr0)/g" \ - -e "s/^\(.*error.*\)$/$(tput setaf 1; tput bold)\1$(tput sgr0)/g" \ - -e "s/^\(\s\{5,\}\)\(.*\)$/\1$(tput setaf 15; tput sitm)\2$(tput sgr0)/g"\ - >&4 |& + -e "s/^\(.*warning.*\)$/$(tput setaf 3; tput bold)\1$(tput sgr0)/g" \ + -e "s/^\(.*error.*\)$/$(tput setaf 1; tput bold)\1$(tput sgr0)/g" \ + -e "s/^\(\s\{5,\}\)\(.*\)$/\1$(tput setaf 15; tput sitm)\2$(tput sgr0)/g"\ + >&4 |& exec >&p /usr/bin/make "$@" 2>&1 ) ec=$? diff --git a/bin/.local/bin/alias/ssh b/bin/.local/bin/alias/ssh @@ -2,7 +2,7 @@ if [ ! -f "$HOME/.tmp/.ssh-agent-init-done" ] then - ssh-agent-init + ssh-agent-init fi /bin/ssh "$@" diff --git a/bin/.local/bin/alias/vimb-tabbed b/bin/.local/bin/alias/vimb-tabbed @@ -1,6 +1,6 @@ #!/bin/sh tabbed \ - -n vimb \ - -c vimb "$@" \ - -e + -n vimb \ + -c vimb "$@" \ + -e diff --git a/bin/.local/bin/auto-open b/bin/.local/bin/auto-open @@ -1,23 +1,23 @@ #!/bin/sh case "$1" in - # images - *.jpg |\ - *.jpeg |\ - *.gif |\ - *.bmp |\ - *.png |\ - *.ff |\ - *.ff.bz |\ - *.ff.xz |\ - *.ff.gz \ - ) (: "${IMG_VIEWER?}") 2>/dev/null && "$IMG_VIEWER" "$1" & exit;; - # pdfs - *.pdf \ - ) (: "${PDF_VIEWER?}") 2>/dev/null && "$PDF_VIEWER" "$1" & exit;; + # images + *.jpg |\ + *.jpeg |\ + *.gif |\ + *.bmp |\ + *.png |\ + *.ff |\ + *.ff.bz |\ + *.ff.xz |\ + *.ff.gz \ + ) (: "${IMG_VIEWER?}") 2>/dev/null && "$IMG_VIEWER" "$1" & exit;; + # pdfs + *.pdf \ + ) (: "${PDF_VIEWER?}") 2>/dev/null && "$PDF_VIEWER" "$1" & exit;; esac case "$(file -b --mime-type "$1")" in - image/*) (: "${IMG_VIEWER?}") 2>/dev/null && "$IMG_VIEWER" "$1" & exit;; + image/*) (: "${IMG_VIEWER?}") 2>/dev/null && "$IMG_VIEWER" "$1" & exit;; esac diff --git a/bin/.local/bin/borg-stat b/bin/.local/bin/borg-stat @@ -11,12 +11,11 @@ echo set -- $(ls ~/.local/share/pass/backup/borg/nas); for repo do - export BORG_REPO="backup:$repo" - export BORG_PASSCOMMAND="pass backup/borg/nas/$repo/passphrase" - - echo "status: $repo" - echo $LINE - /bin/borg info - /bin/borg list --last 6 - echo + export BORG_REPO="backup:$repo" + export BORG_PASSCOMMAND="pass backup/borg/nas/$repo/passphrase" + echo "status: $repo" + echo $LINE + /bin/borg info + /bin/borg list --last 6 + echo done diff --git a/bin/.local/bin/clipd b/bin/.local/bin/clipd @@ -6,33 +6,33 @@ CD_MAX_CLIP_THRESH=$((CD_MAX_CLIP + 100)) last_id="" die() { - echo "$@" - exit 1 + echo "$@" + exit 1 } empty() { - case "$1" in - *[![:blank:]]*) return 1;; - *) return 0;; - esac + case "$1" in + *[![:blank:]]*) return 1;; + *) return 0;; + esac } partof() { - [ -z "$1" ] && return 1; - [ -z "$2" ] && return 1; - case "$1" in - *"$2") return 0;; - "$2"*) return 0;; - esac - case "$2" in - *"$1") return 0;; - "$1"*) return 0;; - esac - return 1; + [ -z "$1" ] && return 1; + [ -z "$2" ] && return 1; + case "$1" in + *"$2") return 0;; + "$2"*) return 0;; + esac + case "$2" in + *"$1") return 0;; + "$1"*) return 0;; + esac + return 1; } getid() { - echo "$(echo "$@" | md5sum | cut -d' ' -f1)" + echo "$(echo "$@" | md5sum | cut -d' ' -f1)" } [ -z "$1" ] && die "selection is missing" @@ -46,35 +46,35 @@ command -v timeout >/dev/null 2>&1 || die "'timeout' program is missing" command -v xsel >/dev/null 2>&1 || die "'xsel' program is missing" case "$selection" in - primary|secondary|clipboard);; - *) die "'$selection' is not a valid selection"; + primary|secondary|clipboard);; + *) die "'$selection' is not a valid selection"; esac while clipnotify; do - data="$(timeout 1 xsel --logfile /dev/null -o --"$selection")" + data="$(timeout 1 xsel --logfile /dev/null -o --"$selection")" - # check if empty - empty "$data" && continue + # check if empty + empty "$data" && continue - # check if identical to last - [ "$data" = "$last_entry" ] && continue + # check if identical to last + [ "$data" = "$last_entry" ] && continue - # check if last or current are parts of each other, and delete last if so. - if partof "$data" "$last_entry"; then - rm -- "/tmp/.clipd/$USER/$last_id" - fi + # check if last or current are parts of each other, and delete last if so. + if partof "$data" "$last_entry"; then + rm -- "/tmp/.clipd/$USER/$last_id" + fi - last_id="$selection.$(getid "$data")" - last_entry="$data" + last_id="$selection.$(getid "$data")" + last_entry="$data" - mkdir -m0700 -p -- "/tmp/.clipd/$USER/" - echo "$data" > "/tmp/.clipd/$USER/$last_id" - chmod 600 -- "/tmp/.clipd/$USER/$last_id" + mkdir -m0700 -p -- "/tmp/.clipd/$USER/" + echo "$data" > "/tmp/.clipd/$USER/$last_id" + chmod 600 -- "/tmp/.clipd/$USER/$last_id" - # remove old entries if threshold is met - if [ ! -z "$CD_MAX_CLIP" ] && \ - [ "$(ls "/tmp/.clipd/$USER/" | wc -l)" -gt "$CD_MAX_CLIP_THRESH" ]; then - ls -dt "/tmp/.clipd/$USER/"* | sed -e "1,${CD_MAX_CLIP}d" \ - | xargs -d '\n' rm - fi + # remove old entries if threshold is met + if [ ! -z "$CD_MAX_CLIP" ] && \ + [ "$(ls "/tmp/.clipd/$USER/" | wc -l)" -gt "$CD_MAX_CLIP_THRESH" ]; then + ls -dt "/tmp/.clipd/$USER/"* | sed -e "1,${CD_MAX_CLIP}d" \ + | xargs -d '\n' rm + fi done diff --git a/bin/.local/bin/colors-256 b/bin/.local/bin/colors-256 @@ -1,93 +0,0 @@ -#!/usr/bin/env bash -# -# (c) 2016 Shudmanul Chowdhury -# -# A simple script to test and get escape sequences for 256 terminal colors. -# -NAME="${0##*/}" -UNDER="\e[4m" -RESET="\e[0m" -TCOLS=$(tput cols) -# prints foreground escape sequence -fgc() { -echo "\e[38;5;${1}m" -} -# prints background escape sequence -bgc() { -echo "\e[48;5;${1}m" -} -usage() { -while IFS= read -r line; do -echo -e "$line" -done << EOF -Usage: $NAME [-a] [-b num] [-f num] - -a display all colors - -b display the background color escape sequence for ${UNDER}num${RESET} - -f display the foreground color escape sequence for ${UNDER}num${RESET} - ${UNDER}num${RESET} should be a value from 0 to 255. -EOF -exit 1 -} -# displays all 256 colors -disp() { -local c # color code -# print basic colors -echo "Basic (0 to 15):" -for c in {0..15}; do -# set the background color to its respective color code -echo -en "$(bgc $c) $RESET" -done -printf "\n\n" -# print greyscale -echo "Greyscale (232 to 255):" -for c in {232..255}; do -# set the background color to its respective color code -echo -en "$(bgc $c) $RESET" -done -printf "\n\n" -# show a chart of six 6x6 color palettes -echo "6x6x6 Cubic Palette (16 to 231): " -local colc=0 # column counter -local sixs=$(($TCOLS / 30)) # number of 6x6 palettes across screen -local cols=$(($sixs * 6)) # number of color columns (5 characters wide) - c=16 # starting color code -while [[ $c -lt 232 ]]; do # 16 to 231 -# set the background color to its respective color code -printf "$(bgc $c) %03d $RESET" "$c" -# increment the color code and the -((c++)) -((colc++)) -# enter a new line if the terminal width has been reached -if [[ $colc -eq $cols ]]; then -# go back to the first set of 6x6 colors on this line if any left -if [[ $((($c - 16) % 36)) -ne 0 ]]; then - c=$(($c - ($sixs - 1) * 36)) -fi - colc=0 # go back to the first column -echo # new line -# go to the next set of 6x6 colors -elif [[ $(($colc % 6)) -eq 0 ]] && [[ $(($c + 30)) -lt 232 ]]; then -((c+=30)) -fi -done -echo -e $RESET -} -# process only one option -if getopts ab:f: OPT; then -case "$OPT" in - a) # display all colors - disp - ;; - b|f)# display escape sequence - if [[ $OPTARG =~ ^[0-9]+$ && $OPTARG -ge 0 ]]; then - [[ $OPT == "b" ]] && bgc $OPTARG - [[ $OPT == "f" ]] && fgc $OPTARG - exit 0 - else - usage - fi - ;; - esac -else - usage -fi diff --git a/bin/.local/bin/compile b/bin/.local/bin/compile @@ -10,52 +10,52 @@ cd "$_DIR" || return case "$_FILE" in *\.ps.ms) preconv "$_FILE" \ - | refer \ - | tapas \ - | grap \ - | pic -Tps \ - | tbl -Tps \ - | eqn -Tps \ - | groff -k -ms $_ARGS -dpaper=a4 -P-pa4 -Tps \ - | ps2pdf - \ - | gs \ - -q \ - -dNOPAUSE \ - -dBATCH \ - -dPDFSETTINGS=/prepress \ - -sDEVICE=pdfwrite \ - -dPrinted=false \ - -sOutputFile="$_BASE.compiled.pdf" - - ;; + | refer \ + | tapas \ + | grap \ + | pic -Tps \ + | tbl -Tps \ + | eqn -Tps \ + | groff -k -ms $_ARGS -dpaper=a4 -P-pa4 -Tps \ + | ps2pdf - \ + | gs \ + -q \ + -dNOPAUSE \ + -dBATCH \ + -dPDFSETTINGS=/prepress \ + -sDEVICE=pdfwrite \ + -dPrinted=false \ + -sOutputFile="$_BASE.compiled.pdf" - + ;; *\.ms) preconv "$_FILE" \ - | refer \ - | tapas \ - | grap \ - | pic -Tpdf \ - | tbl -Tpdf \ - | eqn -Tpdf \ - | groff -k -ms $_ARGS -dpaper=a4 -P-pa4 -P-e -Tpdf \ - | gs \ - -q \ - -dNOPAUSE \ - -dBATCH \ - -dPDFSETTINGS=/prepress \ - -sDEVICE=pdfwrite \ - -dPrinted=false \ - -sOutputFile="$_BASE.compiled.pdf" - - ;; + | refer \ + | tapas \ + | grap \ + | pic -Tpdf \ + | tbl -Tpdf \ + | eqn -Tpdf \ + | groff -k -ms $_ARGS -dpaper=a4 -P-pa4 -P-e -Tpdf \ + | gs \ + -q \ + -dNOPAUSE \ + -dBATCH \ + -dPDFSETTINGS=/prepress \ + -sDEVICE=pdfwrite \ + -dPrinted=false \ + -sOutputFile="$_BASE.compiled.pdf" - + ;; *\.md) lowdown -s -Tms "$_FILE" \ - | sed -e 's/\.nr PS 10/\.nr PS 12\n\.nr VS 18/g' \ - | preconv \ - | tbl -Tpdf \ - | groff -k -ms $_ARGS -dpaper=a4 -P-pa4 -P-e -Tpdf \ - | gs \ - -q \ - -dNOPAUSE \ - -dBATCH \ - -dPDFSETTINGS=/prepress \ - -sDEVICE=pdfwrite \ - -dPrinted=false \ - -sOutputFile="$_BASE.compiled.pdf" - - ;; + | sed -e 's/\.nr PS 10/\.nr PS 12\n\.nr VS 18/g' \ + | preconv \ + | tbl -Tpdf \ + | groff -k -ms $_ARGS -dpaper=a4 -P-pa4 -P-e -Tpdf \ + | gs \ + -q \ + -dNOPAUSE \ + -dBATCH \ + -dPDFSETTINGS=/prepress \ + -sDEVICE=pdfwrite \ + -dPrinted=false \ + -sOutputFile="$_BASE.compiled.pdf" - + ;; esac diff --git a/bin/.local/bin/dmenu_bookmarks b/bin/.local/bin/dmenu_bookmarks @@ -11,11 +11,11 @@ args=" $@" # for each line, remove url (after last space) and append value to options # (while trimming the last blankspace of the value) while read -r line; do - if [ "${line#\#}" = "${line}" ] && [ "$line" != "" ]; then - data="$data$line\n" - text="${line%%${line##*\ }}" - options="$options${text%?}\n" - fi + if [ "${line#\#}" = "${line}" ] && [ "$line" != "" ]; then + data="$data$line\n" + text="${line%%${line##*\ }}" + options="$options${text%?}\n" + fi done < "$filename" # get url based on choice diff --git a/bin/.local/bin/dmenu_confirm b/bin/.local/bin/dmenu_confirm @@ -4,7 +4,7 @@ prompt="$1"; shift if [ "$(echo no\\nyes | dmenu_vtc $@ -p "$prompt")" = "yes" ]; then - exit 0 + exit 0 else - exit 1 + exit 1 fi diff --git a/bin/.local/bin/dmenu_layouts b/bin/.local/bin/dmenu_layouts @@ -2,10 +2,10 @@ args=" -p layouts: -l 20" options=" - floating - grid - monocle - tiled + floating + grid + monocle + tiled " layout="$(printf "$options" \ @@ -13,6 +13,6 @@ layout="$(printf "$options" \ | sort \ | dmenu_vtc${args})" case "$layout" in - grid|tiled|floating|monocle) - echo "set layout $layout" > "/tmp/dwm.fifo";; +grid|tiled|floating|monocle) + echo "set layout $layout" > "/tmp/dwm.fifo";; esac diff --git a/bin/.local/bin/dmenu_main b/bin/.local/bin/dmenu_main @@ -2,52 +2,50 @@ args=" -p main: -l 20" options=" - bookmarks - radio - man - operations - pass - power - soundcloud - todo - youtube + bookmarks + radio + man + operations + pass + power + soundcloud + todo + youtube " get_fm_key () { - local key_location="/tmp/.di.fm.key" - local key_pass="di.fm/listen-key" - - [ ! -f "$key_location" ] \ - && touch "$key_location" \ - && chmod 600 "$key_location" \ - && pass "$key_pass" > "$key_location" - - echo $(cat "$key_location") + local key_location="/tmp/.di.fm.key" + local key_pass="di.fm/listen-key" + [ ! -f "$key_location" ] \ + && touch "$key_location" \ + && chmod 600 "$key_location" \ + && pass "$key_pass" > "$key_location" + echo $(cat "$key_location") } while :; do - case "$(printf "$options" \ - | sed -e '/^$/d' -e 's/^[ \t]*//' \ - | sort \ - | dmenu_vtc${args})" in - bookmarks) - dmenu_bookmarks "$XDG_DATA_HOME/bookmarks" ${args} -i -p bookmark:;; - radio) - dmenu_radio "$(get_fm_key)" ${args} -i -p provider:;; - man) - dmenu_man${args} -i -p man:;; - operations) - operations dmenu${args} -i -p operations:;; - pass) - dmenu_passmenu ${args} -i -p pass:;; - power) - dmenu_power${args} -i;; - soundcloud) - dmenu_sscw${args} -i;; - todo) - dmenu_todo "$XDG_DATA_HOME/todo" ${args} -i -p todo:;; - youtube) - dmenu_yt_search${args} -i;; - *) break;; - esac + case "$(printf "$options" \ + | sed -e '/^$/d' -e 's/^[ \t]*//' \ + | sort \ + | dmenu_vtc${args})" in + bookmarks) + dmenu_bookmarks "$XDG_DATA_HOME/bookmarks" ${args} -i -p bookmark:;; + radio) + dmenu_radio "$(get_fm_key)" ${args} -i -p provider:;; + man) + dmenu_man${args} -i -p man:;; + operations) + operations dmenu${args} -i -p operations:;; + pass) + dmenu_passmenu ${args} -i -p pass:;; + power) + dmenu_power${args} -i;; + soundcloud) + dmenu_sscw${args} -i;; + todo) + dmenu_todo "$XDG_DATA_HOME/todo" ${args} -i -p todo:;; + youtube) + dmenu_yt_search${args} -i;; + *) break;; + esac done diff --git a/bin/.local/bin/dmenu_man b/bin/.local/bin/dmenu_man @@ -3,9 +3,9 @@ args=" -p man: -l 30 $@" man="$( - man -k . \ - | dmenu_vtc${args} \ - | grep -oe '^[^(]*' \ + man -k . \ + | dmenu_vtc${args} \ + | grep -oe '^[^(]*' \ )" [ "$man" = "" ] && exit 1 diff --git a/bin/.local/bin/dmenu_mount b/bin/.local/bin/dmenu_mount @@ -2,18 +2,18 @@ # get mountable partitions parts="$( - lsblk -lp \ - | grep "[0-9] part $" \ - | awk '{print $1, "(" $4 ")"}' \ + lsblk -lp \ + | grep "[0-9] part $" \ + | awk '{print $1, "(" $4 ")"}' \ )" [ "$parts" = "" ] && exit 1 # choose a partition to mount args=" -i -p partition:" part="$( - echo "$parts" \ - | dmenu_vtc${args} \ - | awk '{print $1}' \ + echo "$parts" \ + | dmenu_vtc${args} \ + | awk '{print $1}' \ )" [ "$part" = "" ] && exit 1 @@ -22,24 +22,24 @@ sudo mount "$part" 2>/dev/null && exit 0 # get available mount points dirs="$( - find \ - /mnt \ - /media \ - /mount \ - ~/mnt \ - ~/media \ - ~/mount \ - -maxdepth 2 \ - -type d \ - -empty \ - 2>/dev/null \ + find \ + /mnt \ + /media \ + /mount \ + ~/mnt \ + ~/media \ + ~/mount \ + -maxdepth 2 \ + -type d \ + -empty \ + 2>/dev/null \ )" # choose a mount point args=" -i -p directory:" mntpnt="$( - echo "$dirs" \ - | dmenu_vtc${args} \ + echo "$dirs" \ + | dmenu_vtc${args} \ )" [ "$mntpnt" = "" ] || [ ! -d "$mntpnt" ] && exit 1 diff --git a/bin/.local/bin/dmenu_passmenu b/bin/.local/bin/dmenu_passmenu @@ -2,23 +2,23 @@ typeit=0 if [ "$1" = "--type" ]; then - typeit=1; shift + typeit=1; shift fi args=" -l 20 -p pass: $@" prefix="$XDG_DATA_HOME/pass" password_files="$( - find "$prefix" -name "*.gpg" \ - | sed -e "s,$prefix/,,g" -e "s,.gpg,,g" + find "$prefix" -name "*.gpg" \ + | sed -e "s,$prefix/,,g" -e "s,.gpg,,g" )" password=$(echo "$password_files" | dmenu_vtc ${args}) [ "$password" = "" ] && return if [ $typeit -eq 0 ]; then - pass show -c "$password" 2>/dev/null + pass show -c "$password" 2>/dev/null else - pass show "$password" 2>/dev/null \ - | { read -r pass; printf %s "$pass"; } \ - | xdotool type --clearmodifiers --file - + pass show "$password" 2>/dev/null \ + | { read -r pass; printf %s "$pass"; } \ + | xdotool type --clearmodifiers --file - fi diff --git a/bin/.local/bin/dmenu_power b/bin/.local/bin/dmenu_power @@ -2,10 +2,10 @@ args=" -p power:" options=" - lock - logout - shutdown - reboot + lock + logout + shutdown + reboot " case "$(printf "$options" \ @@ -13,14 +13,14 @@ case "$(printf "$options" \ | sort \ | dmenu_vtc${args})" in lock) - /usr/local/bin/slock -m "locked at $(date "+%H:%M:%S"; - echo '------------------'; - fortune /usr/share/fortunes/off/black-humor)" - ;; + /usr/local/bin/slock -m "locked at $(date "+%H:%M:%S"; + echo '------------------'; + fortune /usr/share/fortunes/off/black-humor)" + ;; logout) - killall dwm-run;; + killall dwm-run;; shutdown) - sudo runit-init 0;; + sudo runit-init 0;; reboot) - sudo runit-init 6;; + sudo runit-init 6;; esac diff --git a/bin/.local/bin/dmenu_radio b/bin/.local/bin/dmenu_radio @@ -11,18 +11,21 @@ quality="premium_high" # premium_low, premium_medium, premium, premium_high [ "$key" = "" ] && exit 1 # choose provider -provider=$(printf "di.fm\nradiotunes.com\nrockradio.com\njazzradio.com" \ - | sort | dmenu_vtc${args}) +provider="$( \ + printf "di.fm\nradiotunes.com\nrockradio.com\njazzradio.com" \ + | sort \ + | dmenu_vtc${args} \ +)" # download list of available channels -data="$( - curl -s "http://listen.$provider/$quality/" \ - | grep -Po "http://listen.*?pls" \ +data="$( \ + curl -s "http://listen.$provider/$quality/" \ + | grep -Po "http://listen.*?pls" \ )" -options="$( - echo $data \ - | tr ' ' '\n' \ - | sed 's/^.*\/premium_high\/\(.*\).pls/\1/g' \ +options="$( \ + echo $data \ + | tr ' ' '\n' \ + | sed 's/^.*\/premium_high\/\(.*\).pls/\1/g' \ )" # get url based on choice diff --git a/bin/.local/bin/dmenu_sscw b/bin/.local/bin/dmenu_sscw @@ -11,11 +11,11 @@ term="$(echo -n | dmenu_vtc${args} -l 0)" options="$(printf "$term" | sscw-search -s)" [ "$options" = "" ] && exit 0 titles="$(echo "$options" | \ - cut -d "$(printf '\t')" -f 1,2 --output-delimiter=" - " | \ - awk '{ print FNR " " $0 }')" + cut -d "$(printf '\t')" -f 1,2 --output-delimiter=" - " | \ + awk '{ print FNR " " $0 }')" urls="$(echo "$options" | \ - cut -d "$(printf '\t')" -f 4 | \ - awk '{ print FNR " " $0 }')" + cut -d "$(printf '\t')" -f 4 | \ + awk '{ print FNR " " $0 }')" title="$(printf "$titles" | dmenu_vtc${args} -l 20 -p "soundcloud > $term:")" # get -p from input and append "\b > $term:" [ "$title" = "" ] && exit 0 diff --git a/bin/.local/bin/dmenu_themes b/bin/.local/bin/dmenu_themes @@ -4,5 +4,5 @@ args=" -p theme: -l 20" theme="$(ttyc list | dmenu_vtc${args})" sudo ttyc "$theme" \ - && echo $(killall -USR1 st 2>/dev/null) \ - && echo quit > /tmp/dwm.fifo + && echo $(killall -USR1 st 2>/dev/null) \ + && echo quit > /tmp/dwm.fifo diff --git a/bin/.local/bin/dmenu_todo b/bin/.local/bin/dmenu_todo @@ -9,30 +9,30 @@ options="" [ ! -f "$filename" ] && exit 1 while true; do - # get current todo with line numbering - options="$(awk '{print NR,$0}' "$filename")" + # get current todo with line numbering + options="$(awk '{print NR,$0}' "$filename")" - # get choice - choice="$(printf "$options" | dmenu_vtc${args})" + # get choice + choice="$(printf "$options" | dmenu_vtc${args})" - # check if choice was made - [ ! -n "$choice" ] && exit + # check if choice was made + [ ! -n "$choice" ] && exit - # get existing record - existing="$(printf "$options" | grep "^${choice}$")" + # get existing record + existing="$(printf "$options" | grep "^${choice}$")" - # check if existing or new - if [ "$existing" != "" ] && [ "${existing%%\ *}" -eq "${existing%%\ *}" ]; then - case "$(printf 'copy\ndelete' | dmenu_vtc${args})" in - copy) - printf "${existing#*\ }" | \ - xclip -i -sel p -f | \ - xclip -i -sel c - exit ;; - delete) - sed -i "${existing%%\ *}d" "$filename" ;; - esac - else - echo "${choice}" >> "$filename" - fi + # check if existing or new + if [ "$existing" != "" ] && [ "${existing%%\ *}" -eq "${existing%%\ *}" ]; then + case "$(printf 'copy\ndelete' | dmenu_vtc${args})" in + copy) + printf "${existing#*\ }" | \ + xclip -i -sel p -f | \ + xclip -i -sel c + exit ;; + delete) + sed -i "${existing%%\ *}d" "$filename" ;; + esac + else + echo "${choice}" >> "$filename" + fi done diff --git a/bin/.local/bin/dmenu_umount b/bin/.local/bin/dmenu_umount @@ -2,35 +2,35 @@ # get partitions mounted through fstab (exclude these) exclude="$( - sed -e '/^$/d' -e '/^#.*$/d' /etc/fstab \ - | awk ' - BEGIN { + sed -e '/^$/d' -e '/^#.*$/d' /etc/fstab \ + | awk ' + BEGIN { C = 0; printf "\\ \\(" - } END { - printf "\\)$" - } C++ > 1 { - printf "\\|" - } $2 ~ /^\/.*/ { - printf "%s",$2; - }' + } END { + printf "\\)$" + } C++ > 1 { + printf "\\|" + } $2 ~ /^\/.*/ { + printf "%s",$2; + }' )" # get mounted partitions -parts="$( - lsblk -lp \ - | grep "part /" \ - | grep -v "$exclude" \ - | awk '{print $1, "(" $4 ")", "on", $7}' \ +parts="$( \ + lsblk -lp \ + | grep "part /" \ + | grep -v "$exclude" \ + | awk '{print $1, "(" $4 ")", "on", $7}' \ )" [ "$parts" = "" ] && exit # choose a partition to unmount args=" -i -p unmount:" -part="$( - echo "$parts" \ - | dmenu_vtc${args} \ - | awk '{print $1}' \ +part="$( \ + echo "$parts" \ + | dmenu_vtc${args} \ + | awk '{print $1}' \ )" [ "$part" = "" ] && exit diff --git a/bin/.local/bin/dmenu_url_extract b/bin/.local/bin/dmenu_url_extract @@ -3,11 +3,11 @@ args=" -l 20 -w $WINDOWID" stdin=$(cat) url="" -urls="$(printf "$stdin" |\ - sed 's/\(\(https\|http\|sftp\|ftp\|telnet\)\:\/\/\)/\n\1/g' |\ - sed '/^\(http\|https\|ftp\|sftp\|telnet\)/!d' |\ - sed 's/\(^\(https\|http\|sftp\|ftp\|telnet\)\:\/\/[^ <]*\)\(.*\)/\1/g' |\ - sort -u)" +urls="$(printf "$stdin" \ + | sed 's/\(\(https\|http\|sftp\|ftp\|telnet\)\:\/\/\)/\n\1/g' \ + | sed '/^\(http\|https\|ftp\|sftp\|telnet\)/!d' \ + | sed 's/\(^\(https\|http\|sftp\|ftp\|telnet\)\:\/\/[^ <]*\)\(.*\)/\1/g'\ + | sort -u)" [ "$urls" = "" ] && exit diff --git a/bin/.local/bin/dmenu_vtc b/bin/.local/bin/dmenu_vtc @@ -23,79 +23,79 @@ SBCOLOR="$(readvtc 5)" WINDOW="" print_usage() { - echo "usage dmenu_vtc [-bfi] ..." + echo "usage dmenu_vtc [-bfi] ..." } handle_name() { - ARGNAME="" - case "$1" in - # flag arguments - -b) BOTTOM=true;; - -f) PREGRAB=true;; - -i) CASEINSSENSITIVE=true;; - # name/value arguments - -l | -h | -m | -p | -fn | -nb | -nf | -sb | -sf | -w) - ARGNAME="$1";; - esac + ARGNAME="" + case "$1" in + # flag arguments + -b) BOTTOM=true;; + -f) PREGRAB=true;; + -i) CASEINSSENSITIVE=true;; + # name/value arguments + -l | -h | -m | -p | -fn | -nb | -nf | -sb | -sf | -w) + ARGNAME="$1";; + esac } handle_value() { - case "$ARGNAME" in - -l) VERTICALLINES="$1";; - -h) HEIGHT="$1";; - -m) MONITOR="$1";; - -p) PROMPT="$1";; - -fn) FONT="$1";; - -nf) NFCOLOR="$1";; - -nb) NBCOLOR="$1";; - -sf) SFCOLOR="$1";; - -sb) SBCOLOR="$1";; - -w) WINDOW="$1";; - --) break;; - -*) echo "invalid option: $ARGNAME" 1>&2; exit 1;; - *) break;; - esac - ARGNAME="" + case "$ARGNAME" in + -l) VERTICALLINES="$1";; + -h) HEIGHT="$1";; + -m) MONITOR="$1";; + -p) PROMPT="$1";; + -fn) FONT="$1";; + -nf) NFCOLOR="$1";; + -nb) NBCOLOR="$1";; + -sf) SFCOLOR="$1";; + -sb) SBCOLOR="$1";; + -w) WINDOW="$1";; + --) break;; + -*) echo "invalid option: $ARGNAME" 1>&2; exit 1;; + *) break;; + esac + ARGNAME="" } # read arguments for var in "$@"; do - case "$var" in - --help) print_usage;; - -*) handle_name "$var";; - *) handle_value "$var";; - esac + case "$var" in + --help) print_usage;; + -*) handle_name "$var";; + *) handle_value "$var";; + esac done case $INX in 1) - pgrep -x dmenu && exit + pgrep -x dmenu && exit - ARGS=" \ - $([ "$BOTTOM" = true ] && echo "-b") \ - $([ "$PREGRAB" = true ] && echo "-f") \ - $([ "$CASEINSSENSITIVE" = true ] && echo "-i") \ - " + ARGS=" \ + $([ "$BOTTOM" = true ] && echo "-b") \ + $([ "$PREGRAB" = true ] && echo "-f") \ + $([ "$CASEINSSENSITIVE" = true ] && echo "-i") \ + " - dmenu $ARGS \ - -l "$VERTICALLINES" \ - -h "$HEIGHT" \ - -m "$MONITOR" \ - -p "$PROMPT" \ - -fn "$FONT" \ - -nf "$NFCOLOR" \ - -nb "$NBCOLOR" \ - -sf "$SFCOLOR" \ - -sb "$SBCOLOR" \ - -w "$WINDOW" + dmenu $ARGS \ + -l "$VERTICALLINES" \ + -h "$HEIGHT" \ + -m "$MONITOR" \ + -p "$PROMPT" \ + -fn "$FONT" \ + -nf "$NFCOLOR" \ + -nb "$NBCOLOR" \ + -sf "$SFCOLOR" \ + -sb "$SBCOLOR" \ + -w "$WINDOW" ;; 0) - # fix for 'cascading' fzfs - sleep 0.01 + # fix for 'cascading' fzfs + sleep 0.01 - fzf-tmux \ - --reverse \ - --select-1 \ - --exit-0 + fzf-tmux \ + --reverse \ + --select-1 \ + --exit-0 ;; esac diff --git a/bin/.local/bin/dmenu_yt_search b/bin/.local/bin/dmenu_yt_search @@ -2,17 +2,17 @@ args=" -i -l 20 -p ▶ -sb #ca0200 -sf #ffffff -nb #000000 -nf #ffffff" search_phrase="$(echo -n | dmenu_vtc${args} \ - | sed 's/\ /+/g' \ - | hexdump -v -e '/1 "%02x"' \ - | sed 's/\(..\)/%\1/g')" + | sed 's/\ /+/g' \ + | hexdump -v -e '/1 "%02x"' \ + | sed 's/\(..\)/%\1/g')" search_results="$(curl 2>/dev/null \ - "https://www.youtube.com/results?search_query=$search_phrase" \ - | sed 's/<a /\n<a /g')" + "https://www.youtube.com/results?search_query=$search_phrase" \ + | sed 's/<a /\n<a /g')" search_data="$(echo $search_results \ - | grep -o '<a href=\"/watch?v=[^>]*>' \ - | grep -v 'list=' \ - | sed -r "s/^<a(.*?)href=\"\/watch\?v=([^\"]+)\"(.*?)title=\"([^\"]+)\"(.*?)>/\2;\4/")" + | grep -o '<a href=\"/watch?v=[^>]*>' \ + | grep -v 'list=' \ + | sed -r "s/^<a(.*?)href=\"\/watch\?v=([^\"]+)\"(.*?)title=\"([^\"]+)\"(.*?)>/\2;\4/")" time="" line="" data="" @@ -25,29 +25,29 @@ name="" [ "$search_data" = "" ] && exit 0 while :; do - line="${search_data%% + line="${search_data%% *}" - i="$((i+1))" - nr="$(printf "%02d" "$i")" - id="${line%%;*}" - name="${line#*;}" - data="$data$nr $id\n" - time="$(echo "$search_results" | grep -B 1 -- "$id" 2>/dev/null \ - | grep "video-time" 2>/dev/null \ - | sed -r "s/<span[^>]*>([^<]*).*/\1/")" - - if [ "$time" = "" ]; then - time="LIVE!" - elif [ "$(echo "$time" | grep -o ':' | wc -l)" != "2" ]; then - time="$(date --date="00:$time" +"%M:%S")" - else - time="$(date --date="$time" +"%H:%M:%S")" - fi - - options="$options$nr [$time] "$(echo "$name" | recode html..unicode)"\n" - search_data="${search_data#* + i="$((i+1))" + nr="$(printf "%02d" "$i")" + id="${line%%;*}" + name="${line#*;}" + data="$data$nr $id\n" + time="$(echo "$search_results" | grep -B 1 -- "$id" 2>/dev/null \ + | grep "video-time" 2>/dev/null \ + | sed -r "s/<span[^>]*>([^<]*).*/\1/")" + + if [ "$time" = "" ]; then + time="LIVE!" + elif [ "$(echo "$time" | grep -o ':' | wc -l)" != "2" ]; then + time="$(date --date="00:$time" +"%M:%S")" + else + time="$(date --date="$time" +"%H:%M:%S")" + fi + + options="$options$nr [$time] "$(echo "$name" | recode html..unicode)"\n" + search_data="${search_data#* }" - if [ "$line" = "$search_data" ]; then break; fi + if [ "$line" = "$search_data" ]; then break; fi done choice="$(echo $options | sed '/^\s*$/d' | sort | dmenu_vtc${args})" diff --git a/bin/.local/bin/dwm-run b/bin/.local/bin/dwm-run @@ -1,4 +1,4 @@ #!/bin/sh while true; do - /usr/local/bin/dwm 2> "$XDG_CACHE_HOME/dwm/dwm.log" + /usr/local/bin/dwm 2> "$XDG_CACHE_HOME/dwm/dwm.log" done diff --git a/bin/.local/bin/fetch-icals b/bin/.local/bin/fetch-icals @@ -9,70 +9,70 @@ _e=0 set -- $(pass lists/icals | sed -e 's/ /__space__/g') for cal do - # reset placeholders for space - cal="$(echo $cal | sed -e 's/__space__/ /g')" - - # extract name and link from 'name::[authcmd]url' - _name="${cal%%::*}" - _link="${cal##*::}" - - # extract user and password command if existing - _user="$(echo "$_link" | grep -o '^\[[^]]*\]' | sed 's:^.\(.*\).$:\1:')" - - if [ "$_user" != "" ] - then - curl \ - --silent "${_link##*]}" \ - --user "$(eval "$_user")" \ - --location \ - | sed -e '1,/VEVENT/{/VEVENT/p;d}' -e '$d' >> $_tmp - else - curl \ - --silent "$_link" \ - --location \ - | sed -e '1,/VEVENT/{/VEVENT/p;d}' -e '$d' >> $_tmp - fi - - # download ical and strip header and footer - - # get current event count - _j=$(grep -o '^BEGIN:VEVENT' $_tmp | wc -l) - - # check if new events were added - if [ $_i -ne $_j ] - then - printf '[+] %sfetched %d new events: %s%s%s\n' \ - "$(tput setaf 10)" \ - "$((_j - _i))" \ - "$(tput setaf 15)" \ - "$_name" \ - "$(tput sgr0)" - else - printf '[-] %sfailed to fetch new events: %s%s%s\n' \ - "$(tput setaf 9)" \ - "$(tput setaf 15)" \ - "$_name" \ - "$(tput sgr0)" - _e=$((e + 1)) - fi - - # set new count - _i=$_j + # reset placeholders for space + cal="$(echo $cal | sed -e 's/__space__/ /g')" + + # extract name and link from 'name::[authcmd]url' + _name="${cal%%::*}" + _link="${cal##*::}" + + # extract user and password command if existing + _user="$(echo "$_link" | grep -o '^\[[^]]*\]' | sed 's:^.\(.*\).$:\1:')" + + if [ "$_user" != "" ] + then + curl \ + --silent "${_link##*]}" \ + --user "$(eval "$_user")" \ + --location \ + | sed -e '1,/VEVENT/{/VEVENT/p;d}' -e '$d' >> $_tmp + else + curl \ + --silent "$_link" \ + --location \ + | sed -e '1,/VEVENT/{/VEVENT/p;d}' -e '$d' >> $_tmp + fi + + # download ical and strip header and footer + + # get current event count + _j=$(grep -o '^BEGIN:VEVENT' $_tmp | wc -l) + + # check if new events were added + if [ $_i -ne $_j ] + then + printf '[+] %sfetched %d new events: %s%s%s\n' \ + "$(tput setaf 10)" \ + "$((_j - _i))" \ + "$(tput setaf 15)" \ + "$_name" \ + "$(tput sgr0)" + else + printf '[-] %sfailed to fetch new events: %s%s%s\n' \ + "$(tput setaf 9)" \ + "$(tput setaf 15)" \ + "$_name" \ + "$(tput sgr0)" + _e=$((e + 1)) + fi + + # set new count + _i=$_j done # add header and footer printf '%s\n%s\n%s\n%s' \ - "BEGIN:VCALENDAR" \ - "VERSION:2.0" \ - "$(cat $_tmp)" \ - "END:VCALENDAR" > $_tmp + "BEGIN:VCALENDAR" \ + "VERSION:2.0" \ + "$(cat $_tmp)" \ + "END:VCALENDAR" > $_tmp # ask to continue on error count > 0 if [ $_e -gt 0 ] then - printf '%d calendars failed to sync. Do you want to continue (y/N)? ' \ - "$_e" - read answer && [ "$answer" = "${answer#[Yy]}" ] && return + printf '%d calendars failed to sync. Do you want to continue (y/N)? ' \ + "$_e" + read answer && [ "$answer" = "${answer#[Yy]}" ] && return fi # clear calendar @@ -87,7 +87,3 @@ cat $_tmp > $_cal # clean up rm $_tmp - - - - diff --git a/bin/.local/bin/fix-home-permissions b/bin/.local/bin/fix-home-permissions @@ -1,20 +1,20 @@ #!/bin/sh mount | grep "[[:space:]]$HOME" 2>&1 >/dev/null && { - tput setaf 1 - echo "there is something mounted under '$HOME'" - tput sgr0 - exit 1 + tput setaf 1 + echo "there is something mounted under '$HOME'" + tput sgr0 + exit 1 } echo "All permissions are about to be changed." read -r -p "Are you sure? [y/N] " response case "$response" in - [yY][eE][sS]|[yY]) - # set a max of rwx --- --- for all files and directories (non symlinks) - find /home/* \! -type l -perm /g+rwx,o+rwx -print -exec chmod g-rwx,o-rwx '{}' + - ;; - *) exit 0 ;; + [yY][eE][sS]|[yY]) + # set a max of rwx --- --- for all files and directories (non symlinks) + find /home/* \! -type l -perm /g+rwx,o+rwx -print -exec chmod g-rwx,o-rwx '{}' + + ;; + *) exit 0 ;; esac diff --git a/bin/.local/bin/fzf-history.tmux b/bin/.local/bin/fzf-history.tmux @@ -10,14 +10,14 @@ _TTY=$(tmux display -p "#{pane_tty}" | sed "s=/dev/==") # make sure HISTFILE is set if [ ! -n "$HISTFILE" ] then - HISTFILE="$HOME_CACHE_HOME/ksh/history" + HISTFILE="$HOME_CACHE_HOME/ksh/history" fi # get command from history file _CMD="$(cat "$HISTFILE" \ - | sed -e 's/^[ \t]*//' -e 's/[ \t]*$//' -e '/^[[:space:]]*$/d' \ - | sort -u \ - | fzf-tmux)" + | sed -e 's/^[ \t]*//' -e 's/[ \t]*$//' -e '/^[[:space:]]*$/d' \ + | sort -u \ + | fzf-tmux)" # send keys to current session tmux send-keys "$_CMD" diff --git a/bin/.local/bin/fzf-move-to.tmux b/bin/.local/bin/fzf-move-to.tmux @@ -3,11 +3,11 @@ sessions="$(tmux list-sessions)" printf '%s\n' "$sessions" \ - | fzf-tmux \ - -d 35% \ - --exit-0 \ - --cycle \ - --reverse \ - --no-preview \ - | sed -r 's/^([^:]*:).*/\1/g' \ - | xargs -i sh -c 'tmux move-window -t {}99 && tmux move-window -r -t {}' + | fzf-tmux \ + -d 35% \ + --exit-0 \ + --cycle \ + --reverse \ + --no-preview \ + | sed -r 's/^([^:]*:).*/\1/g' \ + | xargs -i sh -c 'tmux move-window -t {}99 && tmux move-window -r -t {}' diff --git a/bin/.local/bin/fzf-url.tmux b/bin/.local/bin/fzf-url.tmux @@ -2,29 +2,29 @@ pane="$(tmux capture-pane -J -p)" urls=$( - echo "$pane" \ - | grep -oE '(https?|s?ftps?|telnet|file):/?//[-A-Za-z0-9+&@#/%?=~_|!:,.;]*[-A-Za-z0-9+&@#/%=~_|]' + echo "$pane" \ + | grep -oE '(https?|s?ftps?|telnet|file):/?//[-A-Za-z0-9+&@#/%?=~_|!:,.;]*[-A-Za-z0-9+&@#/%=~_|]' ) wwws=$( - echo "$pane" \ - | grep -oE 'www\.[a-zA-Z](-?[a-zA-Z0-9])+\.[a-zA-Z]{2,}(/\S+)*' \ - | sed 's/^\(.*\)$/http:\/\/\1/' + echo "$pane" \ + | grep -oE 'www\.[a-zA-Z](-?[a-zA-Z0-9])+\.[a-zA-Z]{2,}(/\S+)*' \ + | sed 's/^\(.*\)$/http:\/\/\1/' ) ips=$( - echo "$pane" \ - | grep -oE '(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}(:[0-9]{1,5})?(/\S+)*' \ - | sed 's/^\(.*\)$/http:\/\/\1/' + echo "$pane" \ + | grep -oE '(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}(:[0-9]{1,5})?(/\S+)*' \ + | sed 's/^\(.*\)$/http:\/\/\1/' ) printf '%s\n' "$urls" "$wwws" "$ips" \ - | sort -u \ - | sed -r '/^\s*$/d' \ - | nl -w3 -s ' ' \ - | fzf-tmux \ - -d 35% \ - --exit-0 \ - --cycle \ - --reverse \ - --no-preview \ - | awk '{print $2}' \ - | xargs -n1 -I {} dmenu_url_open {} &>/dev/null || true + | sort -u \ + | sed -r '/^\s*$/d' \ + | nl -w3 -s ' ' \ + | fzf-tmux \ + -d 35% \ + --exit-0 \ + --cycle \ + --reverse \ + --no-preview \ + | awk '{print $2}' \ + | xargs -n1 -I {} dmenu_url_open {} &>/dev/null || true diff --git a/bin/.local/bin/gen-adblock b/bin/.local/bin/gen-adblock @@ -20,13 +20,13 @@ printf '%s' \ ' http://www.malwaredomainlist.com/hostslist/hosts.txt' \ | sed -e 's/^$//g'); for x do - printf "Getting '%s' domain list...\n" "$(echo $x | cut -d / -f 3)" 1>&2 - curl -L -s "$x" \ - | sed -e 's/\r//' \ - | grep -v '#\|^::1\|[[:space:]]localhost$' \ - | tr '\t' ' ' \ - | sed -e '/^[\s]*$/d' -e 's/^[^\s]*\s//' \ - | sort >> $_TEMP_FILE + printf "Getting '%s' domain list...\n" "$(echo $x | cut -d / -f 3)" 1>&2 + curl -L -s "$x" \ + | sed -e 's/\r//' \ + | grep -v '#\|^::1\|[[:space:]]localhost$' \ + | tr '\t' ' ' \ + | sed -e '/^[\s]*$/d' -e 's/^[^\s]*\s//' \ + | sort >> $_TEMP_FILE done cat $_TEMP_FILE \ diff --git a/bin/.local/bin/generate-mutt-alias b/bin/.local/bin/generate-mutt-alias @@ -9,16 +9,16 @@ SQL_CMD="$SQL_CMD FROM contacts JOIN users ON users.user_id=contacts.user_id" SQL_CMD="$SQL_CMD WHERE users.username=\"$1\"" SSH_CMD="$(cat <<'EOT' sudo /usr/bin/mysql - --skip-column-names - -D roundcubemail - -e + --skip-column-names + -D roundcubemail + -e EOT )" SSH_CMD="$SSH_CMD'$SQL_CMD'" SSH_CMD="$SSH_CMD$(cat <<'EOT' | awk - -F '\\t' - '{print "alias "tolower(substr($1,1,3)substr($2,1,3))" "$3" ("$1" "$2")"}' + -F '\\t' + '{print "alias "tolower(substr($1,1,3)substr($2,1,3))" "$3" ("$1" "$2")"}' EOT )" diff --git a/bin/.local/bin/lbry2rss b/bin/.local/bin/lbry2rss @@ -8,65 +8,65 @@ CHNL="$1" CHNL_REQ="{ - \"jsonrpc\":\"2.0\", - \"method\":\"resolve\", - \"params\":{ - \"urls\":[\"$CHNL\"] - } + \"jsonrpc\":\"2.0\", + \"method\":\"resolve\", + \"params\":{ + \"urls\":[\"$CHNL\"] + } }" CHNL_QRY=".result | to_entries[].value | .value.title,.name,.value.description" LIST_REQ="{ - \"jsonrpc\":\"2.0\", - \"method\":\"claim_search\", - \"params\":{ - \"channel\":\"$CHNL\", - \"order_by\":[\"release_time\"], - \"page\":1, - \"page_size\":50 - } + \"jsonrpc\":\"2.0\", + \"method\":\"claim_search\", + \"params\":{ + \"channel\":\"$CHNL\", + \"order_by\":[\"release_time\"], + \"page\":1, + \"page_size\":50 + } }" LIST_QRY=".result.items[] | .value.title, .value.description, \"https://api.lbry.tv/content/claims/\" - +.normalized_name+\"/\" - +.claim_id - +\"/stream\", + +.normalized_name+\"/\" + +.claim_id + +\"/stream\", .permanent_url, .meta.creation_timestamp " CHNL_DATA="$(curl \ - --data-binary "$CHNL_REQ" \ - -H 'content-type:text/plain;' \ - --silent https://api.lbry.tv/api/v1/proxy \ + --data-binary "$CHNL_REQ" \ + -H 'content-type:text/plain;' \ + --silent https://api.lbry.tv/api/v1/proxy \ | jq "$CHNL_QRY" \ | sed \ - -e 's/^"//' \ - -e 's/"$//' \ + -e 's/^"//' \ + -e 's/"$//' \ | awk ' - NR == 1 {print "<title>"$0"</title>"} - NR == 2 {print "<link>"$0"</link>"} - NR == 3 {print "<description><![CDATA["$0"]]></description>"} + NR == 1 {print "<title>"$0"</title>"} + NR == 2 {print "<link>"$0"</link>"} + NR == 3 {print "<description><![CDATA["$0"]]></description>"} ' )" LIST_DATA="$(curl \ - --data-binary "$LIST_REQ" \ - -H 'content-type:text/plain;' \ - --silent https://api.lbry.tv/api/v1/proxy \ + --data-binary "$LIST_REQ" \ + -H 'content-type:text/plain;' \ + --silent https://api.lbry.tv/api/v1/proxy \ | jq "$LIST_QRY" \ | sed \ - -e 's/^"//' \ - -e 's/"$//' \ + -e 's/^"//' \ + -e 's/"$//' \ | awk ' - NR % 5 == 1 {print "<item>"} - NR % 5 == 1 {print "\t<title>"$0"</title>"} - NR % 5 == 2 {gsub(/\\n/, "</p><p>"); print "\t<description><![CDATA[<p>"$0"</p>]]></description>"} - NR % 5 == 3 {print "\t<link>"$0"</link>"} - NR % 5 == 4 {print "\t<guid isPermaLink=\"false\">"$0"</guid>"} - NR % 5 == 0 {print "\t<pubDate>"strftime("%a, %d %b %Y %T %z",$0)"</pubDate>"} - NR % 5 == 0 {print "</item>"} + NR % 5 == 1 {print "<item>"} + NR % 5 == 1 {print "\t<title>"$0"</title>"} + NR % 5 == 2 {gsub(/\\n/, "</p><p>"); print "\t<description><![CDATA[<p>"$0"</p>]]></description>"} + NR % 5 == 3 {print "\t<link>"$0"</link>"} + NR % 5 == 4 {print "\t<guid isPermaLink=\"false\">"$0"</guid>"} + NR % 5 == 0 {print "\t<pubDate>"strftime("%a, %d %b %Y %T %z",$0)"</pubDate>"} + NR % 5 == 0 {print "</item>"} ' \ | sed 's:<p></p>::g' )" diff --git a/bin/.local/bin/listen-new-mail b/bin/.local/bin/listen-new-mail @@ -2,11 +2,11 @@ # Listen for changes forever while true; do - ls -d \ - "$HOME"/mail/webmail-*/INBOX/new/ \ - "$HOME"/mail/webmail-*/INBOX/new/* \ - 2>/dev/null | entr -n -r -a -d -p 2>/dev/null echo - count="$(find "$HOME"/mail/webmail-*/INBOX/new/* 2>/dev/null | wc -l)" - [ "$count" != "0" ] && ztatusc notify "you have $count new mail(s)" - ztatusc update mail + ls -d \ + "$HOME"/mail/webmail-*/INBOX/new/ \ + "$HOME"/mail/webmail-*/INBOX/new/* \ + 2>/dev/null | entr -n -r -a -d -p 2>/dev/null echo + count="$(find "$HOME"/mail/webmail-*/INBOX/new/* 2>/dev/null | wc -l)" + [ "$count" != "0" ] && ztatusc notify "you have $count new mail(s)" + ztatusc update mail done diff --git a/bin/.local/bin/listen-new-pkg b/bin/.local/bin/listen-new-pkg @@ -2,7 +2,7 @@ # Listen for changes forever ls /var/db/xbps/pkgdb*.plist | entr -n -p -s ' - count="$(pkg queue | wc -l)" - [ "$count" != "0" ] && ztatusc notify "you have $count new pakage(s)" - ztatusc update updates + count="$(pkg queue | wc -l)" + [ "$count" != "0" ] && ztatusc notify "you have $count new pakage(s)" + ztatusc update updates ' diff --git a/bin/.local/bin/mbsync-stdin b/bin/.local/bin/mbsync-stdin @@ -8,14 +8,14 @@ targets="$(echo "$stdin" | grep -oe "$regex" | uniq)" tmpfile="$(mktemp /tmp/.mbsyncrc.XXXXXX)" load_encypted_conf() { - acc="$(pass mail/account-id | sed "$(($1+1))q;d")" - printf "%s" "$(pass mail/"$acc"/"$2")" + acc="$(pass mail/account-id | sed "$(($1+1))q;d")" + printf "%s" "$(pass mail/"$acc"/"$2")" } echo "$targets" | while read -r target; do - args="$(echo "$target" | sed -e "s/$regex/\1 \2/")" - stdin="$(echo "$stdin" | sed -e "s/$target/$(load_encypted_conf $args)/")" - echo "$stdin" > "$tmpfile" + args="$(echo "$target" | sed -e "s/$regex/\1 \2/")" + stdin="$(echo "$stdin" | sed -e "s/$target/$(load_encypted_conf $args)/")" + echo "$stdin" > "$tmpfile" done mbsync -c "$tmpfile" "$@" diff --git a/bin/.local/bin/mkthemes b/bin/.local/bin/mkthemes @@ -2,23 +2,23 @@ for vt in "$XDG_CONFIG_HOME"/themes/*.vt do - _r=""; _g=""; _b="" - _n=${vt##*/} - _n=${_n%%.*} - _f=/usr/share/kbd/vtrgb/vtrgb.$_n + _r=""; _g=""; _b="" + _n=${vt##*/} + _n=${_n%%.*} + _f=/usr/share/kbd/vtrgb/vtrgb.$_n - set -- $(sed -e 's/#.*$//' -e '/^$/d' "$vt") - for line - do - _r="$_r,$(echo $line | cut -c1-2 | xargs -I . printf '%d' '0x.')" - _g="$_g,$(echo $line | cut -c3-4 | xargs -I . printf '%d' '0x.')" - _b="$_b,$(echo $line | cut -c5-6 | xargs -I . printf '%d' '0x.')" - done + set -- $(sed -e 's/#.*$//' -e '/^$/d' "$vt") + for line + do + _r="$_r,$(echo $line | cut -c1-2 | xargs -I . printf '%d' '0x.')" + _g="$_g,$(echo $line | cut -c3-4 | xargs -I . printf '%d' '0x.')" + _b="$_b,$(echo $line | cut -c5-6 | xargs -I . printf '%d' '0x.')" + done - { - echo "[ -f \"$_f\" ] && rm -f \"$_f\"" - echo "echo \"${_r#*,}\" >> \"$_f\"" - echo "echo \"${_g#*,}\" >> \"$_f\"" - echo "echo \"${_b#*,}\" >> \"$_f\"" - } | sudo + { + echo "[ -f \"$_f\" ] && rm -f \"$_f\"" + echo "echo \"${_r#*,}\" >> \"$_f\"" + echo "echo \"${_g#*,}\" >> \"$_f\"" + echo "echo \"${_b#*,}\" >> \"$_f\"" + } | sudo done diff --git a/bin/.local/bin/mnt b/bin/.local/bin/mnt @@ -25,58 +25,58 @@ sources|sshfs|nas:/strg/src|~/mnt/src " _lines() { - local _tmp="${_table}" - local _fmt='{print $0}' - local _opt="$1"; shift + local _tmp="${_table}" + local _fmt='{print $0}' + local _opt="$1"; shift - while :; do - line="${_tmp%% + while :; do + line="${_tmp%% *}" - _tmp="${_tmp#* + _tmp="${_tmp#* }" - _id="${line%%|*}" - [ "$line" = "$_tmp" ] && break - [ "$line" = "" ] && continue - [ "$1" != "" ] && [ "$@" != "$_id" ] && continue - case "$_opt" in - 'name') _fmt='{print $1}' ;; - 'src') _fmt='{print $3}' ;; - 'target') _fmt='{print $4}' ;; - 'cmd') _fmt='{print $2, $3, $4}' ;; - 'state') - printf '[%-1s] %s\n' \ - "$(grep -qs "^$(_lines src $_id)" /proc/mounts && echo '*')"\ - "$(_lines name $_id)" - continue - ;; - esac - echo "${line}" | awk -F '|' "$_fmt" - done + _id="${line%%|*}" + [ "$line" = "$_tmp" ] && break + [ "$line" = "" ] && continue + [ "$1" != "" ] && [ "$@" != "$_id" ] && continue + case "$_opt" in + 'name') _fmt='{print $1}' ;; + 'src') _fmt='{print $3}' ;; + 'target') _fmt='{print $4}' ;; + 'cmd') _fmt='{print $2, $3, $4}' ;; + 'state') + printf '[%-1s] %s\n' \ + "$(grep -qs "^$(_lines src $_id)" /proc/mounts && echo '*')"\ + "$(_lines name $_id)" + continue + ;; + esac + echo "${line}" | awk -F '|' "$_fmt" + done } [ "$#" -gt 1 ] && echo "$_usage" && return case "$1" in --list|-l) - /bin/column -t /proc/mounts - ;; + /bin/column -t /proc/mounts + ;; --help|-h) - echo "$_usage" - ;; + echo "$_usage" + ;; '') - echo "$(_lines state)" \ - | fzf --multi --layout=reverse-list \ - | cut -c 4- \ - | xargs -r -n 1 mnt - ;; + echo "$(_lines state)" \ + | fzf --multi --layout=reverse-list \ + | cut -c 4- \ + | xargs -r -n 1 mnt + ;; *) - echo "$(_lines name)" | grep "^$1$" 2>&1 >/dev/null || return + echo "$(_lines name)" | grep "^$1$" 2>&1 >/dev/null || return - if grep -qs "^$(_lines src $1)" /proc/mounts - then - echo sudo /bin/umount "$(_lines target "$1")" | ${SHELL:-"/bin/sh"} - else - echo "$(_lines cmd "$1")" | ${SHELL:-"/bin/sh"} - fi - ;; + if grep -qs "^$(_lines src $1)" /proc/mounts + then + echo sudo /bin/umount "$(_lines target "$1")" | ${SHELL:-"/bin/sh"} + else + echo "$(_lines cmd "$1")" | ${SHELL:-"/bin/sh"} + fi + ;; esac diff --git a/bin/.local/bin/monitor b/bin/.local/bin/monitor @@ -8,71 +8,71 @@ hdmi="$drm_dir/$int_card-HDMI-*/status" gpu_count="$(ls "$drm_dir" | grep -o card. | sort -u | wc -l)" print_help() { - echo "Usage: ${0##*/} ACTION\n" - echo "ACTIONS:" - echo " setup normal setup." - echo " daemon start monitor daemon." - echo " force-lvds enable lvds forcefully." - echo " help print this help message." + echo "Usage: ${0##*/} ACTION\n" + echo "ACTIONS:" + echo " setup normal setup." + echo " daemon start monitor daemon." + echo " force-lvds enable lvds forcefully." + echo " help print this help message." } install_udev_rule() { - if [ "$(id -u)" = 0 ]; then - rule="" - rule="${rule}ACTION==\"change\", " - rule="${rule}SUBSYSTEM==\"drm\", " - rule="${rule}ENV{HOTPLUG}==\"1\", " - rule="${rule}RUN+=\"/bin/sh -c 'cat ${hdmi} > ${hdmi_status}'\"" - mkdir -p /etc/udev/rules.d - printf "$rule" > /etc/udev/rules.d/95-hotplug-drm.rules - else - echo "must run as root" - fi + if [ "$(id -u)" = 0 ]; then + rule="" + rule="${rule}ACTION==\"change\", " + rule="${rule}SUBSYSTEM==\"drm\", " + rule="${rule}ENV{HOTPLUG}==\"1\", " + rule="${rule}RUN+=\"/bin/sh -c 'cat ${hdmi} > ${hdmi_status}'\"" + mkdir -p /etc/udev/rules.d + printf "$rule" > /etc/udev/rules.d/95-hotplug-drm.rules + else + echo "must run as root" + fi } enable_egpu() { - [ "$gpu_count" = "2" ] && xrandr --setprovideroutputsource 1 0 + [ "$gpu_count" = "2" ] && xrandr --setprovideroutputsource 1 0 } enable_lvds() { - xrandr --output LVDS1 --mode 1280x800 --rate 60 - xrandr --output HDMI2 --off + xrandr --output LVDS1 --mode 1280x800 --rate 60 + xrandr --output HDMI2 --off } enable_hdmi() { - # create new resolution for 21:9 (under 160 mhz bandwidth) - xrandr --delmode HDMI2 2560x1080_43 - xrandr --rmmode 2560x1080_43 - xrandr --newmode "2560x1080_43" \ - 159.94 2560 2688 2960 3360 1080 1081 1084 1107 -HSync +Vsync - xrandr --addmode HDMI2 2560x1080_43 + # create new resolution for 21:9 (under 160 mhz bandwidth) + xrandr --delmode HDMI2 2560x1080_43 + xrandr --rmmode 2560x1080_43 + xrandr --newmode "2560x1080_43" \ + 159.94 2560 2688 2960 3360 1080 1081 1084 1107 -HSync +Vsync + xrandr --addmode HDMI2 2560x1080_43 - xrandr --output HDMI2 --mode 2560x1080_43 --rate 43.0 - xrandr --output LVDS1 --off + xrandr --output HDMI2 --mode 2560x1080_43 --rate 43.0 + xrandr --output LVDS1 --off } case "$1" in force-lvds) - if [ "$(cat ${lvds})" != "enabled" ]; then - enable_lvds - fi + if [ "$(cat ${lvds})" != "enabled" ]; then + enable_lvds + fi ;; setup) - if grep -q ^connected$ $hdmi; then - enable_hdmi - enable_egpu - else - enable_lvds - fi + if grep -q ^connected$ $hdmi; then + enable_hdmi + enable_egpu + else + enable_lvds + fi ;; daemon) - [ ! -f ${hdmi_status} ] && touch ${hdmi_status} - echo "${hdmi_status}" | entr -n -p "${0}" setup + [ ! -f ${hdmi_status} ] && touch ${hdmi_status} + echo "${hdmi_status}" | entr -n -p "${0}" setup ;; install-udev-rule) - install_udev_rule + install_udev_rule ;; *) - print_help + print_help ;; esac diff --git a/bin/.local/bin/msmtp-tpl b/bin/.local/bin/msmtp-tpl @@ -8,14 +8,14 @@ targets="$(echo "$template" | grep -oe "$regex" | uniq)" tmpfile="$(mktemp /tmp/.msmtprc.XXXXXX)" load_encypted_conf() { - acc="$(pass mail/account-id | sed "$(($1+1))q;d")" - printf "%s" "$(pass mail/"$acc"/"$2")" + acc="$(pass mail/account-id | sed "$(($1+1))q;d")" + printf "%s" "$(pass mail/"$acc"/"$2")" } echo "$targets" | while read -r target; do - args="$(echo "$target" | sed -e "s/$regex/\1 \2/")" - template="$(echo "$template" | sed -e "s/$target/$(load_encypted_conf $args)/")" - echo "$template" > "$tmpfile" + args="$(echo "$target" | sed -e "s/$regex/\1 \2/")" + template="$(echo "$template" | sed -e "s/$target/$(load_encypted_conf $args)/")" + echo "$template" > "$tmpfile" done echo "$stdin" | msmtp -C "$tmpfile" $@ diff --git a/bin/.local/bin/nrowgrid.tmux b/bin/.local/bin/nrowgrid.tmux @@ -7,18 +7,17 @@ rows=${rows:-1} # read number of desired rows from input input=${@:-} -if [ -n "$input" ] -then - case "$input" in - # increase row number - '++') rows=$((rows + 1)) ;; - - # decrease row number - '--') rows=$((rows - 1)) ;; - - # allow numeric input for row count - *) [ $input -eq $input 2>/dev/null ] && rows=$input ;; - esac +if [ -n "$input" ]; then + case "$input" in + # increase row number + '++') rows=$((rows + 1)) ;; + + # decrease row number + '--') rows=$((rows - 1)) ;; + + # allow numeric input for row count + *) [ $input -eq $input 2>/dev/null ] && rows=$input ;; + esac fi # get some initial data @@ -30,72 +29,68 @@ ww=${wd%%x*} wh=${wd##*x} exec tmux $({ - - n=$# - - [ $rows -lt 1 ] && rows=1 # at least one row, please - [ $n -lt $rows ] && rows=$n # never allow empty rows - - tmux setenv nrows $rows - - # counters - ri=0; ci=0; uc=0; uw=0; uh=0 - - # define first row - cols=$((n / rows)) # number of columns - ch=$((wh / rows)) # client/pane height - uc=$cols # utilized columns - uh=$ch # utilized height - rs="" # resolutions tracker - - # stack panes - echo select-layout even-vertical - - # format panes in a grid - for pid - do - if [ $ci -eq $cols ] - then - uw=0 # utilized width - ci=0 # column index - ri=$((ri + 1)) # row index - - # next row - cols=$(((n - uc) / (rows - ri))) - uc=$((uc + cols)) - ch=$(((wh - uh) / (rows - ri))) - uh=$((uh + ch)) - fi - - cw=$(((ww - uw) / (cols - ci))) # client/pane width - uw=$((uw + cw)) - rs="$rs$cw:$ch;" - - echo select-pane -t $pid - - # move pane if it's not first in the row - if [ $ci -gt 0 ] - then - echo move-pane -d -s . -t .-1 -h - echo resize-pane -t . -x $((cw - 1)) - fi - - ci=$((ci+1)) - done - - # resize panes in the new grid layout - for pid - do - r="${rs%%;*}" # resolution - w="${r%%:*}" # width - h="${r##*:}" # height - rs="${rs#*;}" - - echo resize-pane -t $pid -x $((w - 1)) -y $((h - 1)) - done - - # restore selection - [ -n "$hpane" ] && echo select-pane -t $hpane - echo select-pane -t $spane + n=$# + + [ $rows -lt 1 ] && rows=1 # at least one row, please + [ $n -lt $rows ] && rows=$n # never allow empty rows + + tmux setenv nrows $rows + + # counters + ri=0; ci=0; uc=0; uw=0; uh=0 + + # define first row + cols=$((n / rows)) # number of columns + ch=$((wh / rows)) # client/pane height + uc=$cols # utilized columns + uh=$ch # utilized height + rs="" # resolutions tracker + + # stack panes + echo select-layout even-vertical + + # format panes in a grid + for pid + do + if [ $ci -eq $cols ]; then + uw=0 # utilized width + ci=0 # column index + ri=$((ri + 1)) # row index + + # next row + cols=$(((n - uc) / (rows - ri))) + uc=$((uc + cols)) + ch=$(((wh - uh) / (rows - ri))) + uh=$((uh + ch)) + fi + + cw=$(((ww - uw) / (cols - ci))) # client/pane width + uw=$((uw + cw)) + rs="$rs$cw:$ch;" + + echo select-pane -t $pid + + # move pane if it's not first in the row + if [ $ci -gt 0 ] + then + echo move-pane -d -s . -t .-1 -h + echo resize-pane -t . -x $((cw - 1)) + fi + + ci=$((ci+1)) + done + + # resize panes in the new grid layout + for pid; do + r="${rs%%;*}" # resolution + w="${r%%:*}" # width + h="${r##*:}" # height + rs="${rs#*;}" + echo resize-pane -t $pid -x $((w - 1)) -y $((h - 1)) + done + + # restore selection + [ -n "$hpane" ] && echo select-pane -t $hpane + echo select-pane -t $spane } | sed 's/$/ ;/') diff --git a/bin/.local/bin/operations b/bin/.local/bin/operations @@ -7,51 +7,51 @@ option="$([ "$1" = "-" ] && cat - || echo "$1")" case "$option" in list) - echo notify - echo sync-mail - echo ztatus + echo notify + echo sync-mail + echo ztatus ;; notify) - text="$( - [ "$2" = "" ] \ - && echo "$(echo -n | dmenu_vtc${args} -l 0 -p text:)" \ - || echo "$2" - )" - if [ "$text" != "" ]; then - ztatusc notify "$text" - else - operations dmenu ${args} - fi + text="$( + [ "$2" = "" ] \ + && echo "$(echo -n | dmenu_vtc${args} -l 0 -p text:)" \ + || echo "$2" + )" + if [ "$text" != "" ]; then + ztatusc notify "$text" + else + operations dmenu ${args} + fi ;; ztatus) - case "$2" in - list) - echo show-time - ;; - show-time) - ztatusc toggle datetime - ;; - dmenu|"") - option="$(operations ztatus list | dmenu_vtc${args} -p ztatus:)" - if [ "$option" != "" ]; then - operations ztatus "$option" - else - operations dmenu "${args}" - fi - ;; - esac + case "$2" in + list) + echo show-time + ;; + show-time) + ztatusc toggle datetime + ;; + dmenu|"") + option="$(operations ztatus list | dmenu_vtc${args} -p ztatus:)" + if [ "$option" != "" ]; then + operations ztatus "$option" + else + operations dmenu "${args}" + fi + ;; + esac ;; sync-mail) - "$HOME"/.local/bin/mbsync-stdin < "$XDG_CONFIG_HOME"/mbsync/template -a -V - for f in "$HOME"/mail/webmail-*/INBOX/new/*; do touch "$f" 2>/dev/null; done + "$HOME"/.local/bin/mbsync-stdin < "$XDG_CONFIG_HOME"/mbsync/template -a -V + for f in "$HOME"/mail/webmail-*/INBOX/new/*; do touch "$f" 2>/dev/null; done ;; dmenu|"") - option="$(operations list | dmenu_vtc${@#dmenu})" - if [ "$option" != "" ]; then - operations "$option" "${@#dmenu}" - fi + option="$(operations list | dmenu_vtc${@#dmenu})" + if [ "$option" != "" ]; then + operations "$option" "${@#dmenu}" + fi ;; *) - printf 'the operation "%s" is not implamented.\n' "$option" + printf 'the operation "%s" is not implamented.\n' "$option" ;; esac diff --git a/bin/.local/bin/print-sxhkd b/bin/.local/bin/print-sxhkd @@ -2,27 +2,27 @@ raw="$(sed -e 's/shift + \([a-z]\)$/\U\1/g' ~/.config/sxhkd/sxhkdrc | awk ' BEGIN { - first = 1; - desc = ""; - len = 0; + first = 1; + desc = ""; + len = 0; } desc!="" { - printf "|%s|%s|\n", $0, desc; - desc = ""; + printf "|%s|%s|\n", $0, desc; + desc = ""; } match($0, /# ---([^-]*)/, a) { - if (!first) printf "\n"; - printf "#%s#\n", substr($0, 6, RLENGTH - 5); - first = 0; + if (!first) printf "\n"; + printf "#%s#\n", substr($0, 6, RLENGTH - 5); + first = 0; } /# :.*/ { - desc = substr($0, 4); + desc = substr($0, 4); } { - if (length > len) len = length; + if (length > len) len = length; } END { - print len; + print len; } ')" length="$(echo "$raw" | sed '$!d')" @@ -30,13 +30,13 @@ length="$(echo "$raw" | sed '$!d')" echo "$raw" \ | sed '$d' \ | pr \ - -t \ - -"$((($(tput cols)+$length-1)/$length))" \ - -w "$(tput cols)" \ + -t \ + -"$((($(tput cols)+$length-1)/$length))" \ + -w "$(tput cols)" \ | sed \ - -e "s/|\([^#|]*\)|\([^|]*\)|/`printf \ - "\033[38;1;255m"`\1`printf \ - "\033[0m"` \2 /g" \ - -e "s/#\([^#]*\)#/`printf \ - "\033[48;5;255m\033[30m"`\1`printf \ - "\033[0m "`/g" + -e "s/|\([^#|]*\)|\([^|]*\)|/`printf \ + "\033[38;1;255m"`\1`printf \ + "\033[0m"` \2 /g" \ + -e "s/#\([^#]*\)#/`printf \ + "\033[48;5;255m\033[30m"`\1`printf \ + "\033[0m "`/g" diff --git a/bin/.local/bin/proxify b/bin/.local/bin/proxify @@ -8,52 +8,52 @@ readonly dmz_pid="$(pgrep -a ssh | grep "ssh -g -f -N -D $dmz_port $dmz_name" | readonly lan_pid="$(pgrep -a ssh | grep "ssh -g -f -N -D $lan_port $lan_name" | awk '{print $1}')" check_proxy() { - if [ "$lan_pid" != "" ] && [ "$dmz_pid" != "" ]; then - printf "[$(tput setaf 6)$(tput bold)+$(tput sgr0)] %s\n" \ - "proxy is opened at 127.0.0.1:$lan_port" - return 0 - else - printf "[$(tput setaf 1)$(tput bold)-$(tput sgr0)] %s\n" \ - "proxy is closed" - return 1 - fi + if [ "$lan_pid" != "" ] && [ "$dmz_pid" != "" ]; then + printf "[$(tput setaf 6)$(tput bold)+$(tput sgr0)] %s\n" \ + "proxy is opened at 127.0.0.1:$lan_port" + return 0 + else + printf "[$(tput setaf 1)$(tput bold)-$(tput sgr0)] %s\n" \ + "proxy is closed" + return 1 + fi } kill_proxy() { - [ "$lan_pid" != "" ] && kill "$lan_pid" - [ "$dmz_pid" != "" ] && kill "$dmz_pid" + [ "$lan_pid" != "" ] && kill "$lan_pid" + [ "$dmz_pid" != "" ] && kill "$dmz_pid" } start_proxy() { - printf "[$(tput setaf 6)$(tput bold)*$(tput sgr0)] %s\n" \ - "(1/2) connecting to noxz.tech..." - ssh -g -f -N -D "$dmz_port" "$dmz_name" -p 9922 - [ "$?" != "0" ] && return 1 - - printf "\n[$(tput setaf 6)$(tput bold)*$(tput sgr0)] %s\n" \ - "(2/2) connecting to lanprox.system.local..." - ssh -g -f -N -D "$lan_port" "$lan_name" -o ProxyCommand="ncat --proxy 127.0.0.1:$dmz_port --proxy-type socks4 %h %p" - [ "$?" != "0" ] && return 1 - - printf "\n[$(tput setaf 2)$(tput bold)+$(tput sgr0)] %s\n" \ - "proxy successfully opened at 127.0.0.1:$lan_port" - - return 0 - - ## Usage examples: - # - # setup the proxy for vimb - # # export http_proxy='socks4://localhost:9950' - # - # start ksh through the proxy - # # proxychains4 -q -f /etc/proxychains.noxz.conf ksh + printf "[$(tput setaf 6)$(tput bold)*$(tput sgr0)] %s\n" \ + "(1/2) connecting to noxz.tech..." + ssh -g -f -N -D "$dmz_port" "$dmz_name" -p 9922 + [ "$?" != "0" ] && return 1 + + printf "\n[$(tput setaf 6)$(tput bold)*$(tput sgr0)] %s\n" \ + "(2/2) connecting to lanprox.system.local..." + ssh -g -f -N -D "$lan_port" "$lan_name" -o ProxyCommand="ncat --proxy 127.0.0.1:$dmz_port --proxy-type socks4 %h %p" + [ "$?" != "0" ] && return 1 + + printf "\n[$(tput setaf 2)$(tput bold)+$(tput sgr0)] %s\n" \ + "proxy successfully opened at 127.0.0.1:$lan_port" + + return 0 + + ## Usage examples: + # + # setup the proxy for vimb + # # export http_proxy='socks4://localhost:9950' + # + # start ksh through the proxy + # # proxychains4 -q -f /etc/proxychains.noxz.conf ksh } case "$1" in - ""|status) check_proxy ;; - start) kill_proxy; start_proxy;; - stop) kill_proxy;; - string) [ "$lan_pid" != "" ] && [ "$dmz_pid" != "" ] && echo\ - "/bin/ncat --proxy 127.0.0.1:$lan_port --proxy-type socks4 %h %p";; - *) echo "usage: "$0" status|start|stop|string" + ""|status) check_proxy ;; + start) kill_proxy; start_proxy;; + stop) kill_proxy;; + string) [ "$lan_pid" != "" ] && [ "$dmz_pid" != "" ] && echo \ + "/bin/ncat --proxy 127.0.0.1:$lan_port --proxy-type socks4 %h %p";; + *) echo "usage: "$0" status|start|stop|string" esac diff --git a/bin/.local/bin/repo-graph b/bin/.local/bin/repo-graph @@ -16,303 +16,303 @@ _ALL="" _LOG="" git_log() { - cmd='git log --no-merges --pretty=format:"%at" --since="13 months"' - [ "$_AUTHOR" != "" ] && cmd="$cmd --author=\"$_AUTHOR\"" - [ "$_ALL" != "" ] && cmd="$cmd --all" - if [ "$1" != "" ] - then - if [ -d "$1" ] - then - cmd="cd \"$1\" && $cmd" - else - printf 'error: %s: no such file or directory\n' "$1" 1>&2 && exit 1 - fi - fi - echo $(eval "$cmd") + cmd='git log --no-merges --pretty=format:"%at" --since="13 months"' + [ "$_AUTHOR" != "" ] && cmd="$cmd --author=\"$_AUTHOR\"" + [ "$_ALL" != "" ] && cmd="$cmd --all" + if [ "$1" != "" ] + then + if [ -d "$1" ] + then + cmd="cd \"$1\" && $cmd" + else + printf 'error: %s: no such file or directory\n' "$1" 1>&2 && exit 1 + fi + fi + echo $(eval "$cmd") } get_days() { - set -- $(echo $_LOG) - for epoch - do - date -d "@$epoch" +%Y:%j - done + set -- $(echo $_LOG) + for epoch + do + date -d "@$epoch" +%Y:%j + done } get_day_count() { - get_days | sort | uniq -c | sed -e 's/^\ *//g' -e 's/\ /:/g' + get_days | sort | uniq -c | sed -e 's/^\ *//g' -e 's/\ /:/g' } main() { - _TODAY=$(date +%j) - _DOW=$(date +%u) - _YEAR=$(date +%Y) - _LENGTH=$([ $(((_YEAR - 1) % 4)) -eq 0 ] && echo 366 || echo 365) - _FIRST=$((_TODAY - (53 * 7) - (_DOW % 7) - _WSWM)) - _FMONTH=$(date -d "$_YEAR-01-01 $_FIRST day" +%m) - _FDOY=$(date -d "$_YEAR-01-01 $_FIRST day" +%j) - _MNAMES="$(echo $_MNAMES | cut -d ' ' -f $_FMONTH-) $_MNAMES" - [ $(tput colors) != 256 ] && _COLORS=$_8COLORS + _TODAY=$(date +%j) + _DOW=$(date +%u) + _YEAR=$(date +%Y) + _LENGTH=$([ $(((_YEAR - 1) % 4)) -eq 0 ] && echo 366 || echo 365) + _FIRST=$((_TODAY - (53 * 7) - (_DOW % 7) - _WSWM)) + _FMONTH=$(date -d "$_YEAR-01-01 $_FIRST day" +%m) + _FDOY=$(date -d "$_YEAR-01-01 $_FIRST day" +%j) + _MNAMES="$(echo $_MNAMES | cut -d ' ' -f $_FMONTH-) $_MNAMES" + [ $(tput colors) != 256 ] && _COLORS=$_8COLORS - [ "$_PATH" = "" ] && _PATH=$(pwd) - for d in $_PATH - do - d="$(realpath $d)" - _LOG=$(printf '%s\n%s' "$_LOG" "$(git_log $d | tr ' ' '\n')") - [ $? -ne 0 ] && printf 'error: %s failed to get log: %s\n' \ - "$0" "$d" && return - done + [ "$_PATH" = "" ] && _PATH=$(pwd) + for d in $_PATH + do + d="$(realpath $d)" + _LOG=$(printf '%s\n%s' "$_LOG" "$(git_log $d | tr ' ' '\n')") + [ $? -ne 0 ] && printf 'error: %s failed to get log: %s\n' \ + "$0" "$d" && return + done - [ "$_LOG" = "" ] && printf '%s: got empty log, exiting...\n' "$0" && return + [ "$_LOG" = "" ] && printf '%s: got empty log, exiting...\n' "$0" && return - _DATA=$(get_day_count) - _COUNTS=$(echo "$_DATA" | sed -e 's/:.*$//g' | sort -n) - _CCOUNTS=$(echo "$_COUNTS" | wc -l) - _Q1=$(echo $_COUNTS | cut -d ' ' -f $(((_CCOUNTS + 4 - 1) / 4))) - _Q2=$(echo $_COUNTS | cut -d ' ' -f $(((_CCOUNTS + 2 - 1) / 2))) - _Q3=$(echo $_COUNTS | cut -d ' ' -f $(((3 * _CCOUNTS + 2 - 1) / 4))) + _DATA=$(get_day_count) + _COUNTS=$(echo "$_DATA" | sed -e 's/:.*$//g' | sort -n) + _CCOUNTS=$(echo "$_COUNTS" | wc -l) + _Q1=$(echo $_COUNTS | cut -d ' ' -f $(((_CCOUNTS + 4 - 1) / 4))) + _Q2=$(echo $_COUNTS | cut -d ' ' -f $(((_CCOUNTS + 2 - 1) / 2))) + _Q3=$(echo $_COUNTS | cut -d ' ' -f $(((3 * _CCOUNTS + 2 - 1) / 4))) - _HMONTH=$_FMONTH - mi=1 - ci=1 + _HMONTH=$_FMONTH + mi=1 + ci=1 - case "$_OUTPUT" in - ""|t) print_tui;; - s) print_svg;; - esac + case "$_OUTPUT" in + ""|t) print_tui;; + s) print_svg;; + esac } print_tui() { - printf '%s' " " - for w in $(seq 1 53) - do - _CINDEX=$((_FDOY + 7 * w - 1)) - _CYEAR=$((_YEAR - 1)) - [ $_CINDEX -ge $_LENGTH ] && _CYEAR=$_YEAR - _CMONTH=$(date -d "$_CYEAR-01-01 $((_CINDEX % _LENGTH)) day" +%m) + printf '%s' " " + for w in $(seq 1 53) + do + _CINDEX=$((_FDOY + 7 * w - 1)) + _CYEAR=$((_YEAR - 1)) + [ $_CINDEX -ge $_LENGTH ] && _CYEAR=$_YEAR + _CMONTH=$(date -d "$_CYEAR-01-01 $((_CINDEX % _LENGTH)) day" +%m) - if [ $_CMONTH -ne $_HMONTH ] - then - mi=$((mi + 1)) - ci=1 - fi + if [ $_CMONTH -ne $_HMONTH ] + then + mi=$((mi + 1)) + ci=1 + fi - # make sure first 2 weeks are of the same month - if [ $mi -eq 1 ] \ - && [ $(date -d "$_YEAR-01-15 $_FIRST day" +%m) -ne $_FMONTH ] - then - printf ' ' - else - [ $ci -le 3 ] && printf '%-2s' \ - "$(echo $_MNAMES | cut -d ' ' -f $mi | cut -c $ci-$((ci + 1)))" \ - || printf ' ' - fi + # make sure first 2 weeks are of the same month + if [ $mi -eq 1 ] \ + && [ $(date -d "$_YEAR-01-15 $_FIRST day" +%m) -ne $_FMONTH ] + then + printf ' ' + else + [ $ci -le 3 ] && printf '%-2s' \ + "$(echo $_MNAMES | cut -d ' ' -f $mi | cut -c $ci-$((ci + 1)))" \ + || printf ' ' + fi - ci=$((ci + 2)) - _HMONTH=$_CMONTH - done - printf '\n' + ci=$((ci + 2)) + _HMONTH=$_CMONTH + done + printf '\n' - for wd in $(seq 1 7) - do - if [ $((wd % 2)) -eq 0 ] - then - printf '%5s ' "$(echo $_WNAMES | cut -d ' ' -f $((wd - _WSWM)))" - else - printf ' ' - fi - for w in $(seq 1 53) - do - _CINDEX=$((_FDOY + 7 * w - 1 + (wd - 1))) - _CYEAR=$((_YEAR - 1)) - [ $_CINDEX -ge $_LENGTH ] && _CYEAR=$_YEAR - _CDOY=$(date -d "$_CYEAR-01-01 $((_CINDEX % _LENGTH)) day" +%j) - _DC=$(echo "$_DATA" | grep -o ".*$_CYEAR:$_CDOY$") - _C=${_DC%%:*} - [ "$_C" = "" ] && _C=0 + for wd in $(seq 1 7) + do + if [ $((wd % 2)) -eq 0 ] + then + printf '%5s ' "$(echo $_WNAMES | cut -d ' ' -f $((wd - _WSWM)))" + else + printf ' ' + fi + for w in $(seq 1 53) + do + _CINDEX=$((_FDOY + 7 * w - 1 + (wd - 1))) + _CYEAR=$((_YEAR - 1)) + [ $_CINDEX -ge $_LENGTH ] && _CYEAR=$_YEAR + _CDOY=$(date -d "$_CYEAR-01-01 $((_CINDEX % _LENGTH)) day" +%j) + _DC=$(echo "$_DATA" | grep -o ".*$_CYEAR:$_CDOY$") + _C=${_DC%%:*} + [ "$_C" = "" ] && _C=0 - [ $_CYEAR -eq $_YEAR ] && [ $((_CINDEX % _LENGTH)) -ge $_TODAY ] && break + [ $_CYEAR -eq $_YEAR ] && [ $((_CINDEX % _LENGTH)) -ge $_TODAY ] && break - _CC="$(( - ( $_C == 0 ) * 1 + - ( $_C > 0 && $_C <= $_Q1 ) * 2 + - ( $_C > $_Q1 && $_C <= $_Q2 ) * 3 + - ( $_C > $_Q2 && $_C <= $_Q3 ) * 4 + - ( $_C > $_Q3 ) * 5 ))" + _CC="$(( + ( $_C == 0 ) * 1 + + ( $_C > 0 && $_C <= $_Q1 ) * 2 + + ( $_C > $_Q1 && $_C <= $_Q2 ) * 3 + + ( $_C > $_Q2 && $_C <= $_Q3 ) * 4 + + ( $_C > $_Q3 ) * 5 ))" - printf "$(tput setaf $(echo "$_COLORS" | cut -d ' ' -f $_CC))" - printf '%s%s' "$_DSYMB" "$(tput sgr0) " - done - printf "\n" - done - printf '\n%92s%s ' " " "$_NLESS" - for i in $(seq 1 5) - do - printf "$(tput setaf $(echo "$_COLORS" | cut -d ' ' -f $i))$_DSYMB$(tput sgr0) " - done - printf '%s\n' "$_NMORE" + printf "$(tput setaf $(echo "$_COLORS" | cut -d ' ' -f $_CC))" + printf '%s%s' "$_DSYMB" "$(tput sgr0) " + done + printf "\n" + done + printf '\n%92s%s ' " " "$_NLESS" + for i in $(seq 1 5) + do + printf "$(tput setaf $(echo "$_COLORS" | cut -d ' ' -f $i))$_DSYMB$(tput sgr0) " + done + printf '%s\n' "$_NMORE" } print_svg() { - printf '<svg width="650" height="120">\n' - printf ' <style>\n' - printf ' .m { font: normal 10px monospace, sans-serif; fill: #767676;}\n' - printf ' .wd { font: normal 10px monospace, sans-serif; fill: #767676;}\n' - printf ' .l { font: normal 10px monospace, sans-serif; fill: #767676;}\n' - printf ' </style>\n' - printf ' <g transform="translate(20, 20)">\n' - for w in $(seq 1 53) - do - printf ' <g transform="translate(%d, 0)">\n' $(((w - 1) * 12)) - for wd in $(seq 1 7) - do - _CINDEX=$((_FDOY + 7 * w - 1 + (wd - 1))) - _CYEAR=$((_YEAR - 1)) - [ $_CINDEX -ge $_LENGTH ] && _CYEAR=$_YEAR - _CDOY=$(date -d "$_CYEAR-01-01 $((_CINDEX % _LENGTH)) day" +%j) - _DC=$(echo "$_DATA" | grep -o ".*$_CYEAR:$_CDOY$") - _C=${_DC%%:*} - [ "$_C" = "" ] && _C=0 + printf '<svg width="650" height="120">\n' + printf ' <style>\n' + printf ' .m { font: normal 10px monospace, sans-serif; fill: #767676;}\n' + printf ' .wd { font: normal 10px monospace, sans-serif; fill: #767676;}\n' + printf ' .l { font: normal 10px monospace, sans-serif; fill: #767676;}\n' + printf ' </style>\n' + printf ' <g transform="translate(20, 20)">\n' + for w in $(seq 1 53) + do + printf ' <g transform="translate(%d, 0)">\n' $(((w - 1) * 12)) + for wd in $(seq 1 7) + do + _CINDEX=$((_FDOY + 7 * w - 1 + (wd - 1))) + _CYEAR=$((_YEAR - 1)) + [ $_CINDEX -ge $_LENGTH ] && _CYEAR=$_YEAR + _CDOY=$(date -d "$_CYEAR-01-01 $((_CINDEX % _LENGTH)) day" +%j) + _DC=$(echo "$_DATA" | grep -o ".*$_CYEAR:$_CDOY$") + _C=${_DC%%:*} + [ "$_C" = "" ] && _C=0 - [ $_CYEAR -eq $_YEAR ] && [ $((_CINDEX % _LENGTH)) -ge $_TODAY ]\ - && break + [ $_CYEAR -eq $_YEAR ] && [ $((_CINDEX % _LENGTH)) -ge $_TODAY ]\ + && break - _CC="$(( - ( $_C == 0 ) * 1 + - ( $_C > 0 && $_C <= $_Q1 ) * 2 + - ( $_C > $_Q1 && $_C <= $_Q2 ) * 3 + - ( $_C > $_Q2 && $_C <= $_Q3 ) * 4 + - ( $_C > $_Q3 ) * 5 ))" + _CC="$(( + ( $_C == 0 ) * 1 + + ( $_C > 0 && $_C <= $_Q1 ) * 2 + + ( $_C > $_Q1 && $_C <= $_Q2 ) * 3 + + ( $_C > $_Q2 && $_C <= $_Q3 ) * 4 + + ( $_C > $_Q3 ) * 5 ))" - printf ' <rect %s %s %s %s %s><title>%s</title></rect>\n' \ - 'width="8"' \ - 'height="8"' \ - "x=\"$((16 - (w - 1)))\"" \ - "y=\"$(((wd - 1) * 11))\"" \ - "fill=\"#$(echo "$_HCOLORS" | cut -d ' ' -f $_CC)\"" \ - "$_C commits" - done - printf ' </g>\n' - done + printf ' <rect %s %s %s %s %s><title>%s</title></rect>\n' \ + 'width="8"' \ + 'height="8"' \ + "x=\"$((16 - (w - 1)))\"" \ + "y=\"$(((wd - 1) * 11))\"" \ + "fill=\"#$(echo "$_HCOLORS" | cut -d ' ' -f $_CC)\"" \ + "$_C commits" + done + printf ' </g>\n' + done - for w in $(seq 1 53) - do - _CINDEX=$((_FDOY + 7 * w - 1)) - _CYEAR=$((_YEAR - 1)) - [ $_CINDEX -ge $_LENGTH ] && _CYEAR=$_YEAR - _CMONTH=$(date -d "$_CYEAR-01-01 $((_CINDEX % _LENGTH)) day" +%m) + for w in $(seq 1 53) + do + _CINDEX=$((_FDOY + 7 * w - 1)) + _CYEAR=$((_YEAR - 1)) + [ $_CINDEX -ge $_LENGTH ] && _CYEAR=$_YEAR + _CMONTH=$(date -d "$_CYEAR-01-01 $((_CINDEX % _LENGTH)) day" +%m) - if [ $mi -eq 1 ] \ - && [ $(date -d "$_YEAR-01-30 $_FIRST day" +%m) -ne $_FMONTH ] - then - mi=$((mi + 1)) - fi + if [ $mi -eq 1 ] \ + && [ $(date -d "$_YEAR-01-30 $_FIRST day" +%m) -ne $_FMONTH ] + then + mi=$((mi + 1)) + fi - if [ $_CMONTH -ne $_HMONTH ] - then - printf ' <text %s %s %s %s>%s</text>\n' \ - 'dominant-baseline="middle"' \ - 'class="m"' \ - "dx=\"$((16 + 11 * (w - 1)))\"" \ - 'dy="-10"' \ - "$(echo $_MNAMES | cut -d ' ' -f $mi)" - mi=$((mi + 1)) - fi - _HMONTH=$_CMONTH - done + if [ $_CMONTH -ne $_HMONTH ] + then + printf ' <text %s %s %s %s>%s</text>\n' \ + 'dominant-baseline="middle"' \ + 'class="m"' \ + "dx=\"$((16 + 11 * (w - 1)))\"" \ + 'dy="-10"' \ + "$(echo $_MNAMES | cut -d ' ' -f $mi)" + mi=$((mi + 1)) + fi + _HMONTH=$_CMONTH + done - for wd in $(seq 1 7) - do - [ $((wd % 2)) -ne 0 ] && continue - printf ' <text %s %s %s %s %s %s>%s</text>\n' \ - 'transform="translate(5)"' \ - 'text-anchor="end"' \ - 'dominant-baseline="middle"' \ - 'class="wd"' \ - 'dx="0"' \ - "dy=\"$((6 + 11 * (wd - 1)))\"" \ - "$(echo $_WNAMES | cut -d ' ' -f $((wd - _WSWM)))" - done + for wd in $(seq 1 7) + do + [ $((wd % 2)) -ne 0 ] && continue + printf ' <text %s %s %s %s %s %s>%s</text>\n' \ + 'transform="translate(5)"' \ + 'text-anchor="end"' \ + 'dominant-baseline="middle"' \ + 'class="wd"' \ + 'dx="0"' \ + "dy=\"$((6 + 11 * (wd - 1)))\"" \ + "$(echo $_WNAMES | cut -d ' ' -f $((wd - _WSWM)))" + done - printf ' <text %s %s %s %s %s %s>%s</text>\n' \ - 'transform="translate(476)"' \ - 'dominant-baseline="middle"' \ - 'text-anchor="end"' \ - 'class="l"' \ - 'dx="0"' \ - 'dy="90"' \ - "$_NLESS" - for x in $(seq 1 5) - do - printf ' <rect %s %s %s %s %s/>\n' \ - 'width="8"' \ - 'height="8"' \ - "x=\"$((489 + 11 * (x - 1)))\"" \ - "y=\"85\"" \ - "fill=\"#$(echo "$_HCOLORS" | cut -d ' ' -f $x)\"" - done - printf ' <text %s %s %s %s %s %s>%s</text>\n' \ - 'transform="translate(556)"' \ - 'dominant-baseline="middle"' \ - 'text-anchor="start"' \ - 'class="l"' \ - 'dx="0"' \ - 'dy="90"' \ - "$_NMORE" + printf ' <text %s %s %s %s %s %s>%s</text>\n' \ + 'transform="translate(476)"' \ + 'dominant-baseline="middle"' \ + 'text-anchor="end"' \ + 'class="l"' \ + 'dx="0"' \ + 'dy="90"' \ + "$_NLESS" + for x in $(seq 1 5) + do + printf ' <rect %s %s %s %s %s/>\n' \ + 'width="8"' \ + 'height="8"' \ + "x=\"$((489 + 11 * (x - 1)))\"" \ + "y=\"85\"" \ + "fill=\"#$(echo "$_HCOLORS" | cut -d ' ' -f $x)\"" + done + printf ' <text %s %s %s %s %s %s>%s</text>\n' \ + 'transform="translate(556)"' \ + 'dominant-baseline="middle"' \ + 'text-anchor="start"' \ + 'class="l"' \ + 'dx="0"' \ + 'dy="90"' \ + "$_NMORE" - printf ' </g>\n' - printf '</svg>\n' + printf ' </g>\n' + printf '</svg>\n' } show_help() { - printf 1>&2 '%s\n' "$0" - printf 1>&2 'usage: %s ' "$0" - printf 1>&2 '%s ' \ - "[-A|--all]" \ - "[-a|--author <name>]" \ - "[-t|--tui]" \ - "[-s|--svg]" \ - "[-h|--help]" - printf 1>&2 '\n' - printf 1>&2 '%s\n' \ - " -A, --all include all branches" \ - " -a, --author <name> specify a user" \ - " -h, --help show this help text and exit" \ - "" \ - " OUTPUT TYPES" \ - " -t, --tui output for terminal (default)" \ - " -s, --svg output as svg" + printf 1>&2 '%s\n' "$0" + printf 1>&2 'usage: %s ' "$0" + printf 1>&2 '%s ' \ + "[-A|--all]" \ + "[-a|--author <name>]" \ + "[-t|--tui]" \ + "[-s|--svg]" \ + "[-h|--help]" + printf 1>&2 '\n' + printf 1>&2 '%s\n' \ + " -A, --all include all branches" \ + " -a, --author <name> specify a user" \ + " -h, --help show this help text and exit" \ + "" \ + " OUTPUT TYPES" \ + " -t, --tui output for terminal (default)" \ + " -s, --svg output as svg" } while :; do - case "$1" in - -h|--help) - show_help; exit 0;; - -A|--all) - _ALL=1;; - -a|--author) - shift; _AUTHOR=$1;; - -t|--tui) - if [ "$_OUTPUT" = "" ] - then _OUTPUT='t' - else printf 1>&2 'error: only one output type allowed\n'; exit 1 - fi;; - -s|--svg) - if [ "$_OUTPUT" = "" ] - then _OUTPUT='s' - else printf 1>&2 'error: only one output type allowed\n'; exit 1 - fi;; - --) - shift; break;; - -*) - echo "invalid option: $1" 1>&2; return 1;; - "") - break;; - *) - _PATH=$@ - break;; - esac - shift + case "$1" in + -h|--help) + show_help; exit 0;; + -A|--all) + _ALL=1;; + -a|--author) + shift; _AUTHOR=$1;; + -t|--tui) + if [ "$_OUTPUT" = "" ] + then _OUTPUT='t' + else printf 1>&2 'error: only one output type allowed\n'; exit 1 + fi;; + -s|--svg) + if [ "$_OUTPUT" = "" ] + then _OUTPUT='s' + else printf 1>&2 'error: only one output type allowed\n'; exit 1 + fi;; + --) + shift; break;; + -*) + echo "invalid option: $1" 1>&2; return 1;; + "") + break;; + *) + _PATH=$@ + break;; + esac + shift done main diff --git a/bin/.local/bin/screenrec b/bin/.local/bin/screenrec @@ -5,11 +5,11 @@ geo=$(xrectsel "%x %y %w %h") # record region on screen using backgrounded ffmpeg ffmpeg \ - -video_size $(echo $geo | awk {'print $3 "x" $4'}) \ - -framerate 25 \ - -f x11grab \ - -i $(echo $geo | awk {'print ":0.0+" $1 "," $2'}) \ - -y "$HOME/screenrec-$(date +%Y-%m-%dT%H:%M:%S).mkv" & + -video_size $(echo $geo | awk {'print $3 "x" $4'}) \ + -framerate 25 \ + -f x11grab \ + -i $(echo $geo | awk {'print ":0.0+" $1 "," $2'}) \ + -y "$HOME/screenrec-$(date +%Y-%m-%dT%H:%M:%S).mkv" & # store ffmpeg pid ffmpeg_pid=$! diff --git a/bin/.local/bin/set-wallpaper b/bin/.local/bin/set-wallpaper @@ -6,16 +6,16 @@ STDIN="$(cat -)" case "$STDIN" in *.ff.gz) - cp "$STDIN" "$XDG_CONFIG_HOME/wallpaper.ff.gz" - ;; + cp "$STDIN" "$XDG_CONFIG_HOME/wallpaper.ff.gz" + ;; *.png | *.jpg | *.jpeg | *.gif | *.bmp) - tmp="$(mktemp)" - convert "$STDIN" png:- | png2ff | gzip -c > "$tmp" && \ - mv "$tmp" "$XDG_CONFIG_HOME/wallpaper.ff.gz" - ;; + tmp="$(mktemp)" + convert "$STDIN" png:- | png2ff | gzip -c > "$tmp" && \ + mv "$tmp" "$XDG_CONFIG_HOME/wallpaper.ff.gz" + ;; *) - exit 1 - ;; + exit 1 + ;; esac swall "$XDG_CONFIG_HOME/wallpaper.ff.gz" diff --git a/bin/.local/bin/ssh-add-pass b/bin/.local/bin/ssh-add-pass @@ -1,15 +1,15 @@ #!/bin/sh if [ $# -ne 1 ] ; then - echo "Usage: ssh-add-pass keyfile" - exit 1 + echo "Usage: ssh-add-pass keyfile" + exit 1 fi _KEYFILE="$1" _PASS="$(cat - | sed -e "s|\"|\\\"|g")" expect -c " \ - spawn ssh-add $_KEYFILE; \ - expect -re \".*passphrase.*\"; \ - send -- \"$_PASS\r\"; \ - expect eof" + spawn ssh-add $_KEYFILE; \ + expect -re \".*passphrase.*\"; \ + send -- \"$_PASS\r\"; \ + expect eof" diff --git a/bin/.local/bin/ssh-agent-init b/bin/.local/bin/ssh-agent-init @@ -3,12 +3,12 @@ ssh-add -D set -- $(ls "$XDG_DATA_HOME/pass/ssh"); for key do - pass ssh/$key/passphrase | ssh-add-pass "$HOME/.ssh/keys/.$key.key" \ - 2>&1 >/dev/null && printf '[%s+%s] identity added: %s%s%s\n' \ - "$(tput setaf 10)" \ - "$(tput sgr0)" \ - "$(tput setaf 15)" \ - "$key" \ - "$(tput sgr0)" + pass ssh/$key/passphrase | ssh-add-pass "$HOME/.ssh/keys/.$key.key" \ + 2>&1 >/dev/null && printf '[%s+%s] identity added: %s%s%s\n' \ + "$(tput setaf 10)" \ + "$(tput sgr0)" \ + "$(tput setaf 15)" \ + "$key" \ + "$(tput sgr0)" done touch "$HOME/.tmp/.ssh-agent-init-done" diff --git a/bin/.local/bin/status.tmux b/bin/.local/bin/status.tmux @@ -2,25 +2,25 @@ case "$1" in cpu) - echo "$(cut -f1 /tmp/.tmstat)%" - ;; + echo "$(cut -f1 /tmp/.tmstat)%" + ;; mem) - echo "$(cut -f2 /tmp/.tmstat)%" - ;; + echo "$(cut -f2 /tmp/.tmstat)%" + ;; battery) - _PATH="/sys/class/power_supply/BAT0" - _STATUS="$(cat "$_PATH/status")" - _FULL="$(cat "$_PATH/energy_full")" - _NOW="$(cat "$_PATH/energy_now")" + _PATH="/sys/class/power_supply/BAT0" + _STATUS="$(cat "$_PATH/status")" + _FULL="$(cat "$_PATH/energy_full")" + _NOW="$(cat "$_PATH/energy_now")" - [ "$_STATUS" = "Discharging" ] && _STATUS="-" || _STATUS="+" - echo "$_STATUS$((100 * _NOW / _FULL))%" - ;; + [ "$_STATUS" = "Discharging" ] && _STATUS="-" || _STATUS="+" + echo "$_STATUS$((100 * _NOW / _FULL))%" + ;; temp) - _TEMP="$(sensors | awk '/Core\ 0/ {gsub(/\+/,"",$3); gsub(/\..+/,"",$3); print $3}')" + _TEMP="$(sensors | awk '/Core\ 0/ {gsub(/\+/,"",$3); gsub(/\..+/,"",$3); print $3}')" - echo "$_TEMP°c" - ;; + echo "$_TEMP°c" + ;; pkg) - echo "$([ -f /tmp/.xbps.queue ] && cat /tmp/.xbps.queue || echo 0)•" + echo "$([ -f /tmp/.xbps.queue ] && cat /tmp/.xbps.queue || echo 0)•" esac diff --git a/bin/.local/bin/timer b/bin/.local/bin/timer @@ -4,20 +4,20 @@ timeout="$1"; case "$timeout" in ''|*[!0-9]*) - echo "usage: timer SECONDS" - ;; + echo "usage: timer SECONDS" + ;; *) - while [ "$timeout" != "0" ]; do - printf '\b\b\b\b\b\b\b\b' - printf '%02d:%02d:%02d' \ - "$((timeout/3600))" \ - "$((timeout/60))" \ - "$((timeout % 60))"; + while [ "$timeout" != "0" ]; do + printf '\b\b\b\b\b\b\b\b' + printf '%02d:%02d:%02d' \ + "$((timeout/3600))" \ + "$((timeout/60))" \ + "$((timeout % 60))"; - timeout="$((timeout-1))"; - sleep 1; - done - ;; + timeout="$((timeout-1))"; + sleep 1; + done + ;; esac printf '\b\b\b\b\b\b\b\b' printf '00:00:00\n' diff --git a/bin/.local/bin/tmstat b/bin/.local/bin/tmstat @@ -5,12 +5,12 @@ stat="/bin/vmstat" [ "$(pidof -o $$ -x "$(basename $0)")" != "" ] && return while :; do - cpu="$($stat 1 5 -w \ - | stdbuf -o0 cut -c1- \ - | tail -1 \ - | awk '{print 100-$15}')" - mem="$($stat -s \ - | { read a b ; read c d ; echo $((100 * $c / $a)); })" - echo "$cpu\t$mem" > /tmp/.tmstat + cpu="$($stat 1 5 -w \ + | stdbuf -o0 cut -c1- \ + | tail -1 \ + | awk '{print 100-$15}')" + mem="$($stat -s \ + | { read a b ; read c d ; echo $((100 * $c / $a)); })" + echo "$cpu\t$mem" > /tmp/.tmstat done diff --git a/bin/.local/bin/vifmimg b/bin/.local/bin/vifmimg @@ -13,72 +13,72 @@ readonly _H="$5" [ ! -e "$FIFO_UEBERZUG" ] && exit _draw () { - echo "{ \ - \"action\" : \"add\", \ - \"identifier\" : \"$ID_PREVIEW\", \ - \"x\" : $_X, \ - \"y\" : $((_Y + 1)), \ - \"width\" : $_W, \ - \"height\" : $_H, \ - \"path\" : \"$1\" \ - }" > "$FIFO_UEBERZUG" + echo "{ \ + \"action\" : \"add\", \ + \"identifier\" : \"$ID_PREVIEW\", \ + \"x\" : $_X, \ + \"y\" : $((_Y + 1)), \ + \"width\" : $_W, \ + \"height\" : $_H, \ + \"path\" : \"$1\" \ + }" > "$FIFO_UEBERZUG" } case "$1" in draw) - _draw "$PWD/$6" - ;; + _draw "$PWD/$6" + ;; drawmagick) - [ ! -d "$TMP/$6/" ] && mkdir -p "$TMP/$6/" - [ ! -f "$TMP/$6.png" ] && convert -resize 200x200 -density 1200 "$PWD/$6" "$TMP/$6.png" - _draw "$TMP/$6.png" - ;; + [ ! -d "$TMP/$6/" ] && mkdir -p "$TMP/$6/" + [ ! -f "$TMP/$6.png" ] && convert -resize 200x200 -density 1200 "$PWD/$6" "$TMP/$6.png" + _draw "$TMP/$6.png" + ;; drawff) - [ ! -d "$TMP/$6/" ] && mkdir -p "$TMP/$6/" - if [ ! -f "$TMP/$6.png" ]; then - case "$6" in - *.ff.bz) bzip2 -d -c "$PWD/$6" | ff2png > "$TMP/$6.png" ;; - *.ff.gz) gzip -d -c "$PWD/$6" | ff2png > "$TMP/$6.png" ;; - *.ff.xz) xz -d -c "$PWD/$6" | ff2png > "$TMP/$6.png" ;; - *.ff) ff2png < "$PWD/$6" > "$TMP/$6.png" ;; - *) exit ;; - esac - convert -resize 512x512\> "$TMP/$6.png" "$TMP/$6.png" - fi - _draw "$TMP/$6.png" - ;; + [ ! -d "$TMP/$6/" ] && mkdir -p "$TMP/$6/" + if [ ! -f "$TMP/$6.png" ]; then + case "$6" in + *.ff.bz) bzip2 -d -c "$PWD/$6" | ff2png > "$TMP/$6.png" ;; + *.ff.gz) gzip -d -c "$PWD/$6" | ff2png > "$TMP/$6.png" ;; + *.ff.xz) xz -d -c "$PWD/$6" | ff2png > "$TMP/$6.png" ;; + *.ff) ff2png < "$PWD/$6" > "$TMP/$6.png" ;; + *) exit ;; + esac + convert -resize 512x512\> "$TMP/$6.png" "$TMP/$6.png" + fi + _draw "$TMP/$6.png" + ;; videopreview) - [ ! -d "$TMP/$6/" ] && mkdir -p "$TMP/$6/" - [ ! -f "$TMP/$6.png" ] && ffmpegthumbnailer -i "$PWD/$6" -o "$TMP/$6.png" -s 0 -q 10 - _draw "$TMP/$6.png" - ;; + [ ! -d "$TMP/$6/" ] && mkdir -p "$TMP/$6/" + [ ! -f "$TMP/$6.png" ] && ffmpegthumbnailer -i "$PWD/$6" -o "$TMP/$6.png" -s 0 -q 10 + _draw "$TMP/$6.png" + ;; gifpreview) - [ ! -d "$TMP/$6/" ] && mkdir -p "$TMP/$6/" && convert -coalesce "$PWD/$6" "$TMP/$6/$6.png" - if [ -n "$PLAY_GIF" ]; then - for frame in $(find "$TMP/$6" -name "*.png" | sort -V); do - _draw "$frame" - sleep .07 - done - else - _draw "$TMP/$6/$6-0.png" - fi - ;; + [ ! -d "$TMP/$6/" ] && mkdir -p "$TMP/$6/" && convert -coalesce "$PWD/$6" "$TMP/$6/$6.png" + if [ -n "$PLAY_GIF" ]; then + for frame in $(find "$TMP/$6" -name "*.png" | sort -V); do + _draw "$frame" + sleep .07 + done + else + _draw "$TMP/$6/$6-0.png" + fi + ;; epubpreview) - [ ! -d "$TMP/$6/" ] && mkdir -p "$TMP/$6/" - [ ! -f "$TMP/$6.png" ] && epub-thumbnailer "$6" "$TMP/$6.png" 512 - _draw "$TMP/$6.png" - ;; + [ ! -d "$TMP/$6/" ] && mkdir -p "$TMP/$6/" + [ ! -f "$TMP/$6.png" ] && epub-thumbnailer "$6" "$TMP/$6.png" 512 + _draw "$TMP/$6.png" + ;; pdfpreview) - [ ! -d "$TMP/$6/" ] && mkdir -p "$TMP/$6/" - [ ! -f "$TMP/$6.png" ] && pdftoppm -png -singlefile "$6" "$TMP/$6" - _draw "$TMP/$6.png" - ;; + [ ! -d "$TMP/$6/" ] && mkdir -p "$TMP/$6/" + [ ! -f "$TMP/$6.png" ] && pdftoppm -png -singlefile "$6" "$TMP/$6" + _draw "$TMP/$6.png" + ;; clear) - echo "{ \ - \"action\" : \"remove\", \ - \"identifier\" : \"$ID_PREVIEW\" \ - }" > "$FIFO_UEBERZUG" - [ -n "$AUTO_REMOVE" ] && [ -f "$TMP/$6.png" ] && rm -f "$TMP/$6.png" - [ -n "$AUTO_REMOVE" ] && [ -d "$TMP/$6/" ] && rm -rf "$TMP/$6/" - ;; + echo "{ \ + \"action\" : \"remove\", \ + \"identifier\" : \"$ID_PREVIEW\" \ + }" > "$FIFO_UEBERZUG" + [ -n "$AUTO_REMOVE" ] && [ -f "$TMP/$6.png" ] && rm -f "$TMP/$6.png" + [ -n "$AUTO_REMOVE" ] && [ -d "$TMP/$6/" ] && rm -rf "$TMP/$6/" + ;; esac diff --git a/bin/.local/bin/vifmrun b/bin/.local/bin/vifmrun @@ -2,8 +2,8 @@ export FIFO_UEBERZUG="/tmp/vifm-ueberzug-${PPID}" cleanup() { - rm "$FIFO_UEBERZUG" 2>/dev/null - pkill -P $$ 2>/dev/null + rm "$FIFO_UEBERZUG" 2>/dev/null + pkill -P $$ 2>/dev/null } pkill -P $$ 2>/dev/null diff --git a/bin/.local/bin/web-report b/bin/.local/bin/web-report @@ -2,29 +2,29 @@ site="$(fzf < $XDG_DATA_HOME/web-report/sites)" action="cat /var/log/quark.%s/*.u /var/log/quark.%s/current 2>/dev/null \ - | grep '^[^ ]* [0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}' 2>/dev/null \ - | goaccess 2>/dev/null \ - --exclude-ip 10.0.0.0-10.255.255.255 \ - --log-format='%%^ %%dT%%tZ\t%%h\t%%s\t%%v\t%%U' \ - --date-format='%%Y-%%m-%%d' \ - --time-format='%%H:%%M:%%S' \ - --html-prefs='{ \ - \"theme\" : \"darkBlue\", \ - \"perPage\" : 10, \ - \"layout\" : \"horizontal\", \ - \"showTables\" : true, \ - \"visitors\" : { \ - \"plot\" : { \ - \"chartType\" : \"area-spline\" \ - } \ - } \ - }' \ - --ignore-panel='OS' \ - --ignore-panel='BROWSERS' \ - --ignore-panel='VIRTUAL_HOSTS' \ - --ignore-panel='REFERRERS' \ - --ignore-panel='REFERRING_SITES' \ - --ignore-panel='KEYPHRASES' \ - -o html -" + | grep '^[^ ]* [0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}' 2>/dev/null \ + | goaccess 2>/dev/null \ + --exclude-ip 10.0.0.0-10.255.255.255 \ + --log-format='%%^ %%dT%%tZ\t%%h\t%%s\t%%v\t%%U' \ + --date-format='%%Y-%%m-%%d' \ + --time-format='%%H:%%M:%%S' \ + --html-prefs='{ \ + \"theme\" : \"darkBlue\", \ + \"perPage\" : 10, \ + \"layout\" : \"horizontal\", \ + \"showTables\" : true, \ + \"visitors\" : { \ + \"plot\" : { \ + \"chartType\" : \"area-spline\" \ + } \ + } \ + }' \ + --ignore-panel='OS' \ + --ignore-panel='BROWSERS' \ + --ignore-panel='VIRTUAL_HOSTS' \ + --ignore-panel='REFERRERS' \ + --ignore-panel='REFERRING_SITES' \ + --ignore-panel='KEYPHRASES' \ + -o html -" ssh anthra -t "$(printf "$action" "$site" "$site")" | vimb -c /dev/null -