dotfiles

custom dotfiles
git clone git://git.pyratebeard.net/dotfiles.git
Log | Files | Refs | README

commit c10a3516182b4382c52317ef607701ee763beba8
parent 8fab91cd02a36968aecd55e2be7664d84d6dd079
Author: pyratebeard <root@pyratebeard.net>
Date:   Tue, 28 Jun 2022 15:25:47 +0100

bins

some updates. move some scripts to new bins (newsboat, mutt). remove some unused stuffs

Diffstat:
Abin/bin/colorer | 22++++++++++++++++++++++
Abin/bin/hexcodes | 43+++++++++++++++++++++++++++++++++++++++++++
Abin/bin/linez | 3+++
Mbin/bin/lock | 2+-
Dbin/bin/mail_sync | 27---------------------------
Mbin/bin/mario | 8+++-----
Dbin/bin/mus | 21---------------------
Abin/bin/src_fetch | 15+++++++++++++++
Mbin/bin/switchkb | 6+++++-
Abin/bin/syscat | 93+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mbin/bin/sysinfo | 6++++--
Dbin/bin/vol | 4----
Admenu/bin/rundmc | 92+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Amutt/bin/mail_sync | 29+++++++++++++++++++++++++++++
Rbin/bin/mailfmt -> mutt/bin/mailfmt | 0
Rbin/bin/mailfmtshort -> mutt/bin/mailfmtshort | 0
Rbin/bin/boat_sync -> newsboat/bin/boat_sync | 0
17 files changed, 310 insertions(+), 61 deletions(-)

diff --git a/bin/bin/colorer b/bin/bin/colorer @@ -0,0 +1,22 @@ +#!/bin/sh +# https://github.com/rxw/bin/blob/master/colorer.sh +echo -e " + \033[0;30m▒░ \033[0;31m▒░ \033[0;32m▒░ \033[0;33m▒░ \033[0;34m▒░ \033[0;35m▒░ \033[0;36m▒░ \033[0;37m▒░ + \033[0;30m▒░ \033[0;31m▒░ \033[0;32m▒░ \033[0;33m▒░ \033[0;34m▒░ \033[0;35m▒░ \033[0;36m▒░ \033[0;37m▒░ + \033[1;30m▒░ \033[1;31m▒░ \033[1;32m▒░ \033[1;33m▒░ \033[1;34m▒░ \033[1;35m▒░ \033[1;36m▒░ \033[1;37m▒░ + \033[1;30m▒░ \033[1;31m▒░ \033[1;32m▒░ \033[1;33m▒░ \033[1;34m▒░ \033[1;35m▒░ \033[1;36m▒░ \033[1;37m▒░ + \033[0;39m" + +#echo -e "\0033[0;36m +# ██████ +# ██████ +# ▓▓▓▓▓▓ +# ▓▓▓▓▓ +# ▒▒▒▒▒ +# ▒▒▒▒ +# ▒▒▒▒ +# ▒▒▒ +# ░░ +# ░ +#\033[0;39m +#" diff --git a/bin/bin/hexcodes b/bin/bin/hexcodes @@ -0,0 +1,43 @@ +#!/bin/sh + +c00=$'\e[0;30m' +c01=$'\e[0;31m' +c02=$'\e[0;32m' +c03=$'\e[0;33m' +c04=$'\e[0;34m' +c05=$'\e[0;35m' +c06=$'\e[0;36m' +c07=$'\e[0;37m' +c08=$'\e[1;30m' +c09=$'\e[1;31m' +c10=$'\e[1;32m' +c11=$'\e[1;33m' +c12=$'\e[1;34m' +c13=$'\e[1;35m' +c14=$'\e[1;36m' +c15=$'\e[1;37m' + +f0=$'\e[1;30m' +f1=$'\e[1;37m' +f2=$'\e[0;37m' + +hexs=( $(xrdb -query | grep -P '^.*color[0-9]*:' | tr -d '\t' | cut -d: -f2) ) + +cat << EOF +${c00} ░░▓▓██ ${hexs[0]} +${c08} ░░▓▓██ ${hexs[1]} +${c01} ░░▓▓██ ${hexs[2]} +${c09} ░░▓▓██ ${hexs[3]} +${c02} ░░▓▓██ ${hexs[4]} +${c10} ░░▓▓██ ${hexs[5]} +${c03} ░░▓▓██ ${hexs[6]} +${c11} ░░▓▓██ ${hexs[7]} +${c04} ░░▓▓██ ${hexs[8]} +${c12} ░░▓▓██ ${hexs[9]} +${c05} ░░▓▓██ ${hexs[10]} +${c13} ░░▓▓██ ${hexs[11]} +${c06} ░░▓▓██ ${hexs[12]} +${c14} ░░▓▓██ ${hexs[13]} +${c07} ░░▓▓██ ${hexs[14]} +${c15} ░░▓▓██ ${hexs[15]} +EOF diff --git a/bin/bin/linez b/bin/bin/linez @@ -0,0 +1,3 @@ +#!/usr/bin/env bash +pcs() { for i in {0..7}; do echo -en "\e[${1}$((30+$i))m ┅━┅\e[0m"; done; } +printf "\n%s\n%s\n\n" "$(pcs)" "$(pcs '1;')" diff --git a/bin/bin/lock b/bin/bin/lock @@ -1,2 +1,2 @@ #pkill ssh-agent ; pkill gpg-agent -light-locker-command --lock +i3lock -u -c \#1e1b1c diff --git a/bin/bin/mail_sync b/bin/bin/mail_sync @@ -1,27 +0,0 @@ -#!/usr/bin/env bash - -export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus -mail_dir="$HOME/lib/documents/email" -log_file="/var/log/mail_sync.log" -cached_key=$(gpg-connect-agent 'keyinfo --list' /bye 2>/dev/null | awk 'BEGIN{CACHED=0} /^S/ {if($7==1){CACHED=1}} END{if($0!=""){print CACHED} else {print "none"}}') - -log() { - echo "$(date +%H:%M:%S): ${1}" >> ${log_file} -} - -if [[ "${cached_key}" == "1" ]] ; then - log "INFO: gpg key cached, beginning sync" - offlineimap -f INBOX >/dev/null 2>&1 - sleep 5 - - for inbox in pyratebeard ; do - new_mail=$(ls -l ${mail_dir}/${inbox}/INBOX/new | wc -l) - let new_mail=new_mail-1 - if [ ${new_mail} -gt 0 ] ; then - /usr/bin/notify-send -u 'normal' "${new_mail} new mail(s) for ${inbox}" - fi - done -else - log "ERROR: no gpg key cached" -fi - diff --git a/bin/bin/mario b/bin/bin/mario @@ -18,7 +18,7 @@ iso_type() { vimify() { timestamp=$(date +%s) curl -L -o /tmp/mario-${timestamp} "${1}" - urxvtc -hold -e vim /tmp/mario-${timestamp} + urxvt -cd /home/pyratebeard -hold -e vim -u ~/tmp/mario.vimrc /tmp/mario-${timestamp} #rm -f /tmp/mario-${timestamp} } @@ -28,14 +28,12 @@ plumbit() { Audio) /usr/bin/mpv "${url}" ;; POSIX) urxvtc -hold -e curl -s ${url} ;; ISO) iso_type ;; - #HTML) urxvtc -hold -e lynx -lss=~/.config/lynx/lynx.lss "${url}" ;; HTML|XML) qutebrowser "${url}" ;; - #Unicode|Bourne-Again|ASCII|C|Python) curl -L -o /tmp/mario.sh "${url}" ; urxvtc -hold -e vim /tmp/mario.sh ; rm -f /tmp/mario.sh ;; Unicode|Bourne-Again|ASCII|C|Python) vimify "${url}" ;; - #Unicode|Bourne-Again|ASCII|C|Python) urxvtc -hold -e curl -Ls "${url}" ;; PDF) curl -L -o /tmp/mario.pdf "${url}" ; zathura /tmp/mario.pdf ; rm -f /tmp/mario.pdf ;; *) /usr/bin/notify-send -u 'normal' "mario: unknown filetype ${filetype}" ;; esac } -[[ "${url}" == *"youtube"* ]] && mpv "${url}" || plumbit +vidreg="(youtu|watch?v=)" +(([[ "${url}" =~ $vidreg ]] && mpv "${url}") || ([[ "${url}" == *"gallery"* ]] && qutebrowser "${url}")) || plumbit diff --git a/bin/bin/mus b/bin/bin/mus @@ -1,21 +0,0 @@ -#!/bin/bash - -cmd=$1 - -if [ "$TERM" == "screen-256color" ] ; then - dtach -A /tmp/mus cmus -elif [ -z "$cmd" ] ; then - urxvtc -e dtach -A /tmp/mus cmus -elif [ "$cmd" == "p" ] ; then - /usr/bin/cmus-remote -u -elif [ "$cmd" == "n" ] ; then - /usr/bin/cmus-remote -n -elif [ "$cmd" == "s" ] ; then - /usr/bin/cmus-remote -s -elif [ "$cmd" == "song" ] ; then - if [[ $(cmus-remote -Q | grep tag) ]] ; then - /usr/bin/notify-send -u 'normal' "$(cmus-remote -Q | grep -E "tag artist |tag album |tag title " | awk '{$1=""; print $0}')" - else - /usr/bin/notify-send -u 'normal' 'no song details available' - fi -fi diff --git a/bin/bin/src_fetch b/bin/bin/src_fetch @@ -0,0 +1,15 @@ +#!/bin/sh + +find $HOME/src \ + -mindepth 1 \ + -maxdepth 2 \ + -type d \ + -not -path '*/warez/*' \ + -not -path '*/suit/*' \ + -not -path '*/node_modules/*' \ + -not -path '*/perl5/*' \ + -not -path '*/\.git' \ + -exec zsh -c "cd '{}' ; pwd ; \ + [ -d .git ] \ + && grep '\[remote ' .git/config >/dev/null \ + && git fetch -q 2>&1" \; diff --git a/bin/bin/switchkb b/bin/bin/switchkb @@ -9,7 +9,11 @@ fi kill $(pidof xcape) setxkbmap -option -setxkbmap -option ctrl:nocaps $lang +if [[ "$lang" == "colemak" ]] ; then + setxkbmap -option ctrl:nocaps us -variant colemak-ctrl +else + setxkbmap -option ctrl:nocaps $lang +fi xcape -e 'Control_L=Escape' echo "keyboard is switched to $lang" diff --git a/bin/bin/syscat b/bin/bin/syscat @@ -0,0 +1,93 @@ +#!/bin/sh +# ┐─┐┐ ┬┐─┐┌─┐┬─┐┌┐┐ +# └─┐└┌┘└─┐│ │─┤ │ +# ──┘ ┆ ──┘└─┘┘ ┆ ┆ +# syscat by pyratebeard (https://git.pyratebeard.net/dotfiles/file/bin/bin/syscat.html) +# └─ forked from info.sh by z3bra (https://pub.z3bra.org/monochromatic/misc/info.sh) + +gitdir=https://git.pyratebeard.net +myblog=https://log.pyratebeard.net +homepage=https://pyratebeard.net + +c00=$'\e[0;30m' +c01=$'\e[0;31m' +c02=$'\e[0;32m' +c03=$'\e[0;33m' +c04=$'\e[0;34m' +c05=$'\e[0;35m' +c06=$'\e[0;36m' +c07=$'\e[0;37m' +c08=$'\e[1;30m' +c09=$'\e[1;31m' +c10=$'\e[1;32m' +c11=$'\e[1;33m' +c12=$'\e[1;34m' +c13=$'\e[1;35m' +c14=$'\e[1;36m' +c15=$'\e[1;37m' + +f0=$'\e[1;30m' +f1=$'\e[1;37m' +f2=$'\e[0;37m' + +host=$(hostname -s) +up=$(uptime -p | cut -b4- | tr -d ',|eeks|ay|our|inute') +kernel=`uname -r | tr '[:upper:]' '[:lower:]'` +#kernel=`uname -rmo | tr '[:upper:]' '[:lower:]'` +cpuspe="`sed -n '/model\ name/s/^.*:\ //p' /proc/cpuinfo | uniq | rev | cut -d' ' -f 3- | rev | tr '[:upper:]' '[:lower:]'` (x`nproc`)" +cpu=$(grep 'cpu ' /proc/stat | awk '{usage=($2+$4)*100/($2+$4+$5)} END {print usage}') +load=`printf "%.0f" $cpu`% +system=`sed 's/\s*[\(\\]\+.*$//' /etc/issue | tr '[:upper:]' '[:lower:]'` +ram=`free | awk '/Mem:/ {print int($3/$2 * 100.0)}'`% + +if [ -n "$DISPLAY" ]; then + wmname=`xprop -root _NET_WM_NAME|cut -d\" -f2` + #termfn=`sed -n 's/^.*\*font:\s* -\*-\([^-]*\)-.*/\1/p' ~/.Xdefaults|sed 1q` + termfn=$(grep -Ei "^urxvt\*font" ~/.Xdefaults | awk -F: '{print $3}') + fnsize=$(grep -Ei "^urxvt\*font" ~/.Xdefaults | grep -Eo '[0-9]{1,2}' | head -n1) + #systfn=`sed -n 's/^.*font.*"\(.*\)".*$/\1/p' ~/.gtkrc-2.0` + termco=$(awk -F/ '/colors/{print $NF}' ~/.Xdefaults | tr -d '"') + #termco=$(sed -n '/color/s/^.*\///p' ~/.Xdefaults | tr -d '"') +else + wmname="none" + termfn="none" + #systfn="none" +fi + +pkgnum=`pacman -Q|wc -l` +birthd=`sed -n '1s/^\[\([0-9-]*\).*$/\1/p' /var/log/pacman.log | tr - .` + +#${c00}▓▒ │ ${f1}os ${f0}........... $f2$system +#${c08} ▒░│ ${f1}name ${f0}......... $f2$host +#${c01}▓▒ │ ${f1}birth day${f0}..... $f2$birthd +#${c09} ▒░│ ${f1}packages ${f0}..... $f2$pkgnum +#${c02}▓▒ │ +#${c10} ▒░│ ${f1}wm ${f0}........... $f2$wmname +#${c03}▓▒ │ ${f1}shell ${f0}........ $f2$SHELL +#${c11} ▒░│ ${f1}terminal ${f0}..... $f2$TERM +#${c04}▓▒ │ ${f1}term font ${f0}.... $f2$termfn $fnsize +#${c12} ▒░│ ${f1}term colors ${f0}.. $f2$termco +#${c05}▓▒ │ +#${c13} ▒░│ ${f1}kernel ${f0}....... $f2$kernel +#${c06}▓▒ │ ${f1}processor ${f0}.... $f2$cpuspe +#${c14} ▒░│ +#${c07}▓▒ │ ${f1}web log ${f0}...... $f2$myblog +#${c15} ▒░│ ${f1}git repos ${f0}.... $f2$gitdir +cat << EOF +${c00}▓▒ │ ${f1}host ${f0}......... $f2$host +${c08} ▒░│ ${f1}up ${f0}........... $f2$up +${c01}▓▒ │ +${c09} ▒░│ ${f1}os ${f0}........... $f2$system +${c02}▓▒ │ ${f1}birth ${f0}........ $f2$birthd +${c10} ▒░│ +${c03}▓▒ │ ${f1}wm ${f0}........... $f2$wmname +${c11} ▒░│ ${f1}shell ${f0}........ $f2$SHELL +${c04}▓▒ │ ${f1}term ${f0}......... $f2$TERM +${c12} ▒░│ ${f1}font ${f0}......... $f2$termfn $fnsize +${c05}▓▒ │ ${f1}colors ${f0}....... $f2$termco +${c13} ▒░│ +${c06}▓▒ │ ${f1}kernel ${f0}....... $f2$kernel +${c14} ▒░│ ${f1}processor ${f0}.... $f2$cpuspe +${c07}▓▒ │ +${c15} ▒░│ ${f1}homepage ${f0}..... $f2$homepage +EOF diff --git a/bin/bin/sysinfo b/bin/bin/sysinfo @@ -12,7 +12,7 @@ EMPTY=─ FULL=┅ name=$USER -host=$(hostname) +host=$(hostname -s) uptime=$(uptime -p | cut -b4- | tr -d ',|eeks|ay|our|inute') battery=/sys/class/power_supply/BAT1 distro=$(grep -E "^ID=" /etc/os-release | awk -F= '{print $2}') @@ -24,7 +24,7 @@ shell=$(echo $SHELL | awk -F/ '{print $NF}') term="urxvt" colors=$(grep urxvt-colors ~/.Xdefaults | awk -F\/ '{print $NF}' | tr -d '"') font=$(grep -Ei "^urxvt\*font" ~/.Xdefaults | awk -F: '{print $3}') -font_size=$(grep -Ei "^urxvt\*font" ~/.Xdefaults | grep -Eo '[0-9]{1,2}') +font_size=$(grep -Ei "^urxvt\*font" ~/.Xdefaults | grep -Eo '[0-9]{1,2}' | head -n1) #wm=$XDG_SESSION_DESKTOP wm='2bwm' @@ -73,11 +73,13 @@ printf " \e[0m\n" #\\ cpu cpu=$(grep 'cpu ' /proc/stat | awk '{usage=($2+$4)*100/($2+$4+$5)} END {print usage}') +proc=$(grep ^processor /proc/cpuinfo | wc -l) c_lvl=`printf "%.0f" $cpu` printf " \e[1;35m%-4s \e[1;37m%-5s %-25s \n" " cpu" "$c_lvl%" " "`draw $c_lvl 15` #\\ ram ram=`free | awk '/Mem:/ {print int($3/$2 * 100.0)}'` +mem=$(free -hg --si | grep ^Mem | awk '{print $2}' | tr '[:upper:]' '[:lower:]') printf " \e[1;35m%-4s \e[1;37m%-5s %-25s \n" " ram" "$ram%" " "`draw $ram 15` #\\ battery diff --git a/bin/bin/vol b/bin/bin/vol @@ -1,4 +0,0 @@ -#!/bin/sh -perc=$1 - -amixer set Master ${perc}% diff --git a/dmenu/bin/rundmc b/dmenu/bin/rundmc @@ -0,0 +1,92 @@ +#!/usr/bin/zsh + +#DM_CMD=$(dmenu -m 0 -fn tamzen:pixelsize=15 -i -nb '#2b2b2d' -nf '#baba9e' -sb '#753747' -sf '#bbbbbb' -l 10) + +dm_bin() { + bin_arr=() + while IFS= read -r line; do + bin_arr+=( "$line" ) + done < <( find $HOME/bin ) + + choice=$(printf '%s\n' "${bin_arr[@]}" | awk -F/ '{print $NF}' | dmenu -i -l 10 -m 0 -fn tamzen:pixelsize=15 -nb '#2b2b2d' -nf '#baba9e' -sb '#753747' -sf '#bbbbbb' -p 'bin: ') + + if [ "$choice" ] ; then + #cmd="printf '%s\n' "${bin_arr[@]}" | grep $HOME/bin/$choice | head -n1" + cmd="$HOME/bin/${choice} $@" + urxvt -geometry 1x1+3000+1920 -e zsh -c "$cmd" + fi +} + +dm_func() { + func_arr=() + while IFS= read -r line; do + func_arr+=( "$line" ) + done < <( find $HOME/.zsh/functions ) + + choice=$(printf '%s\n' "${func_arr[@]}" | awk -F/ '{print $NF}' | dmenu -i -l 10 -m 0 -fn tamzen:pixelsize=15 -nb '#2b2b2d' -nf '#baba9e' -sb '#753747' -sf '#bbbbbb' -p 'functions: ') + + if [ "$choice" ] ; then + #cmd="printf '%s\n' "${func_arr[@]}" | grep $HOME/bin/$choice | head -n1" + cmd="$HOME/.zsh/functions/${choice} $@" + urxvt -geometry 1x1+3000+1920 -e zsh -c "$cmd" + fi +} + +dm_aliases() { + source $HOME/.zsh/aliases.zsh + alias_arr=() + while IFS= read -r line; do + alias_arr+=( "$line" ) + done < <( alias ) + + choice=$(printf '%s\n' "${alias_arr[@]}" | awk -F= '{print $1}' | dmenu -i -l 10 -m 0 -fn tamzen:pixelsize=15 -nb '#2b2b2d' -nf '#baba9e' -sb '#753747' -sf '#bbbbbb' -p 'submenu: ') + + if [ "$choice" ] ; then + cmd=$(printf '%s\n' "${alias_arr[@]}" | grep ^$choice | head -n1 | sed 's/=/%/' | awk -F% '{ print $NF }' | tr -d "'") + urxvt -e zsh -c "$cmd" + #echo $cmd + fi +} + +dm_hidden() { + hide_arr=() + while IFS= read -r line; do + hide_arr+=( "$line" ) + done < <(hidden -c) + + choice=$(printf '%s\n' "${hide_arr[@]}" | awk -F: '{print $1}' | tr -d "'" | dmenu -i -l 10 -m 0 -fn tamzen:pixelsize=15 -nb '#2b2b2d' -nf '#baba9e' -sb '#753747' -sf '#bbbbbb' -p 'submenu: ') + + if [ "$choice" ] ; then + cmd=$(printf '%s\n' "${hide_arr[@]}" | grep "^'$choice'" | awk -F: '{ print $NF }' | tr -d "'") + urxvt -e zsh -c "$cmd" + #echo $cmd + fi +} + +dm_man() { + man_arr=() + while IFS= read -r line; do + man_arr+=( "$line" ) + done < <(man -k .) + + choice=$(printf '%s\n' "${man_arr[@]}" | dmenu -i -l 10 -m 0 -fn tamzen:pixelsize=15 -nb '#2b2b2d' -nf '#baba9e' -sb '#753747' -sf '#bbbbbb' -p 'manpage: ') + + if [ "$choice" ] ; then + cmd=$(printf '%s\n' "${man_arr[@]}" | grep ^$choice | awk '{print $1}') + urxvt -e zsh -c "source $HOME/.zsh/colored-man-pages.zsh ; man ${cmd}" + fi +} + +select_arr=("run" "bin" "functions" "aliases" "hidden" "man" "scratch") +submenu=$(printf '%s\n' "${select_arr[@]}" | dmenu -i -l 10 -m 0 -fn tamzen:pixelsize=15 -nb '#2b2b2d' -nf '#baba9e' -sb '#753747' -sf '#bbbbbb' -p 'submenu: ') + +case $submenu in + run) dmenu_run -i -l 10 -m 0 -fn tamzen:pixelsize=15 -nb '#2b2b2d' -nf '#baba9e' -sb '#753747' -sf '#bbbbbb' -p 'rundmc: ' ;; + bin) dm_bin ;; + functions) dm_func ;; + aliases) dm_aliases ;; + hidden) dm_hidden ;; + man) dm_man ;; + scratch) urxvtc -e zsh -c "less $HOME/.vimrc" ;; + *) exit ;; +esac diff --git a/mutt/bin/mail_sync b/mutt/bin/mail_sync @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus +export PYTHONDONTWRITEBYTECODE=1 +mail_dir="$HOME/var/mbox" +log_file="$HOME/var/log/mail_sync.log" +cached_key=$(gpg-connect-agent 'keyinfo --list' /bye 2>/dev/null | awk 'BEGIN{CACHED=0} /^S/ {if($7==1){CACHED=1}} END{if($0!=""){print CACHED} else {print "none"}}') + +log() { + echo "$(date +%H:%M:%S): ${1}" >> ${log_file} +} + +if [[ "${cached_key}" == "1" ]] ; then + log "INFO: gpg key cached, beginning sync" + offlineimap -f INBOX >/dev/null 2>&1 + sleep 5 + + for inbox in pyratebeard ; do + new_mail=$(ls -l ${mail_dir}/${inbox}/INBOX/new | wc -l) + let new_mail=new_mail-1 + if [ ${new_mail} -gt 0 ] ; then + /usr/bin/notify-send -u 'normal' "${new_mail} new mail(s) for ${inbox}" + fi + done +else + log "ERROR: no gpg key cached" +fi + +[ -d $HOME/__pycache__ ] && rm -rf $HOME/__pycache__ diff --git a/bin/bin/mailfmt b/mutt/bin/mailfmt diff --git a/bin/bin/mailfmtshort b/mutt/bin/mailfmtshort diff --git a/bin/bin/boat_sync b/newsboat/bin/boat_sync