Return of bin
Anirudh Oppiliappan x@icyphox.sh
Tue, 10 Nov 2020 19:50:09 +0530
12 files changed,
415 insertions(+),
48 deletions(-)
A
bin/bat
@@ -0,0 +1,23 @@
+#!/usr/bin/env bash + +cap="$(apm -l)" +is_charging="$(apm -a)" + +status="discharging" + +tmux_bat() { + if [[ "$is_charging" -eq 1 ]]; then + printf '%s%%' "+$cap" + else + printf '%s%%' "$cap" + fi +} + +if [[ "$1" == "-q" ]]; then + tmux_bat +else + [[ "$is_charging" -eq 1 ]] && + status="charging" + printf '%s%% [%s]\n' $cap $status +fi +
A
bin/coltest
@@ -0,0 +1,21 @@
+#!/usr/bin/env bash + +BLK="\e[30m" +RED="\e[31m" +GRN="\e[32m" +YLW="\e[33m" +BLU="\e[34m" +PUR="\e[35m" +CYN="\e[36m" +WHT="\e[37m" +RST="\e[0m" + +printf '%b\n' " no color " +printf '%b\n' "${BLK} black ${RST} [black]" +printf '%b\n' "${RED} red ${RST} [red]" +printf '%b\n' "${GRN} green ${RST} [green]" +printf '%b\n' "${YLW} yellow ${RST} [yellow]" +printf '%b\n' "${BLU} blue ${RST} [blue]" +printf '%b\n' "${PUR} purple ${RST} [purple]" +printf '%b\n' "${CYN} cyan ${RST} [cyan]" +printf '%b\n' "${WHT} white ${RST} [white]"
A
bin/date.sh
@@ -0,0 +1,6 @@
+#!/usr/bin/env bash + +date="$(date +"%a, %d %b" | tr A-Z a-z)" + +printf "%s " "$date" +
A
bin/info
@@ -0,0 +1,92 @@
+#!/usr/bin/env bash +# icyinfo, but better + +export BLK="\e[30m" +export RED="\e[31m" +export GRN="\e[32m" +export YLW="\e[33m" +export BLU="\e[34m" +export PUR="\e[35m" +export CYN="\e[36m" +export BRED="\e[31m" +export BGRN="\e[32m" +export BYLW="\e[33m" +export BBLU="\e[34m" +export BPUR="\e[35m" +export BCYN="\e[36m" +export WHT="\e[37m" +export RST="\e[0m" + +#BAR="████" +#((LEN = ${#BAR} * 6)) +#COLOR_BARS="$RED$BAR$GRN$BAR$YLW$BAR$BLU$BAR$PUR$BAR$CYN$BAR$RST" + +basename() { + # Usage: basename "path" ["suffix"] + local tmp + + tmp=${1%"${1##*[!/]}"} + tmp=${tmp##*/} + tmp=${tmp%"${2/"$tmp"}"} + + printf '%s\n' "${tmp:-/}" +} + +prinfo() { + # 1 - field + # 2 - info + # 3 - prev line + prev_line="$1$2" + export prev_line + + + printf '\e[%sD\e[B' "${#3}" + printf '%b' "${BLU}$1${RST}$2" +} + +user="$USER" +host="$HOSTNAME" +kernel="$(uname -r)" +shell="$(basename "$SHELL")" + +# cactus art +#art=" +#${GRN} +# o +#.oo.Oo. +# O. +# Ooo'${RST} +# ${RED}___${RST}${GRN}O${RST}${RED}___ +# \ / +# \___/${RST} +#" + +# blowfish + +printf '\e[?25l' +printf '\e[2J' +art=" +${YLW} \.-----./ + / ^ ^ ^ \ ${RST} + (${PUR}o${RST})(${PUR}o${RST})${YLW} ^ ^ |_/|${RST} + ${RED}{}${RST} ${YLW}^ ^ > ^| \| + \^ ^ ^ ^/ + /-----\\ ${RST} + +" + +printf '%b' "$art" +os="$(uname)" +pkgs="$(pkg_info | wc -l)" + +printf '%b\n' "${CYN}$user${RST}@${CYN}$host${RST}" + +prinfo "os" " $os" +prinfo "kernel" " $kernel" "$prev_line" +prinfo "pkgs" " $pkgs" "$prev_line" +prinfo "shell" " $shell" "$prev_line" + + +# Pause +read -rsn1 _ +clear
A
bin/pkg
@@ -0,0 +1,20 @@
+#!/bin/sh +# pkg - a wrapper around pkg_* + +case "$1" in + add*) + shift + doas pkg_add "$@" + ;; + del*) + shift + doas pkg_delete "$@" + ;; + info*) + shift + doas pkg_info -Q "$@" + ;; + upd*) + doas pkg_add -u + ;; +esac
A
bin/record
@@ -0,0 +1,96 @@
+#!/bin/sh +# stolen from mitch weaver + +: "${RECORD_FRAMERATE:=30}" +: "${RECORD_OUTPUT_DIR:=$PWD}" + +mkdir -p /tmp/record +sock=/tmp/record/sock +pidfile=/tmp/record/pidfile + +msg() { printf '* %s\n' "$*" ; } +die() { >&2 msg "$*" ; exit 1 ; } + +usage() { + die "Usage: ${0##*/} [-o output dir] [-r rate] [-f foreground]" +} + +isrunning() { kill -0 "$(getpid)" 2>/dev/null ; return $? ; } + +getpid() { + [ -s $pidfile ] && read -r pid <$pidfile + echo "${pid:-?}" +} + +start() { + isrunning && die "Another instance already exists: $(getpid)" + + file="$RECORD_OUTPUT_DIR/record-$(date "+%Y.%m.%d-%H:%M:%S").mp4" + :>$sock + + if command -v xrectsel >/dev/null ; then + xrectsel -f '%x %y %w %h' + elif command -v slop >/dev/null ; then + slop -f '%x %y %w %h' + else + die 'Needs xrectsel or slop' + fi | { + read -r x y w h + + <$sock ffmpeg -y -f x11grab -s "${w}x${h}" -r $RECORD_FRAMERATE \ + -i "${DISPLAY:-:0}+${x},${y}" -vcodec libx264 \ + -pix_fmt yuv420p -filter:v "crop=iw-mod(iw\\,2):ih-mod(ih\\,2)" \ + "$file" >/tmp/record/log 2>&1 & + + msg "recording on pid $!" + + if ${FOREGROUND:-false} ; then + trap 'rm "$sock" /tmp/record/log 2>/dev/null ||: ; rmdir /tmp/record 2>/dev/null ||:' EXIT INT TERM + wait + else + echo $! >$pidfile + echo "$file" >/tmp/record/file + fi + } +} + +end() { + if isrunning ; then + echo q >>$sock + read -r name </tmp/record/file + msg "Success! Saved as $name" + rm /tmp/record/* 2>/dev/null ||: + rmdir /tmp/record 2>/dev/null ||: + exit + else + die 'Nothing being recorded.' + fi +} + +toggle() { + if isrunning ; then + end + else + start + fi +} + +while [ "$1" ] ; do + case $1 in + -f) + FOREGROUND=true + ;; + -r) + RECORD_FRAMERATE=$1 + ;; + -o) + [ -d "$2" ] || usage + RECORD_OUTPUT_DIR=$2 + shift + ;; + *) usage + esac + shift +done + +toggle
A
bin/scr
@@ -0,0 +1,42 @@
+#!/usr/bin/env bash +# scr: screenshot tool + +scr_path=~/pics/scrots +output="$(tr -dc 'a-zA-Z0-9' < /dev/random | fold -w 5 | head -n 1)" + +usage() { + echo "usage:" + echo " scr [option]" + echo "options:" + echo " -f full screenshot" + echo " -w window screenshot" + echo " -s selection screenshot" +} + +while getopts fws option +do + case $option in + f) + import -window root "$scr_path/$output.png" + ;; + w) + import -window "$(xdotool getwindowfocus)" "$scr_path/$output.png" + ;; + s) + import "$scr_path/$output.png" + ;; + * | ?) + usage + exit;; + esac +done + +if [ $OPTIND -eq 1 ]; then + echo "scr: missing argument" + usage + exit +fi + + +xclip -selection clipboard -t image/png -i "$scr_path/$output.png" +cp "$scr_path/$output.png" "$scr_path/latest.png"
A
bin/up
@@ -0,0 +1,20 @@
+#!/usr/bin/env bash + +random_name="$(tr -dc 'a-zA-Z0-9' < /dev/random | fold -w 5 | head -n 1)" + +export LATEST_SCROT="$HOME/pics/scrots/latest.png" + +upload() { + file="$(basename "$1")" + ext="${file##*.}" + fullname="$random_name.$ext" + scp -P 22222 "$1" fern:~/www/icy/uploads/"$fullname" + printf '%s\n' "https://x.icyphox.sh/$fullname" + printf '%s' "https://x.icyphox.sh/$fullname" | xclip -selection clipboard +} + +if [ "$1" == "l" ]; then + upload "$LATEST_SCROT" +elif [ "$1" != "l" ]; then + upload "$1" +fi
A
bin/xres
@@ -0,0 +1,4 @@
+#!/usr/bin/env bash +# stolen from nerdy + +xrdb -query | grep -w $1 | awk '{print $2}'
A
bin/zatheme.sh
@@ -0,0 +1,37 @@
+#!/usr/bin/env bash + +# stolen from @nerdypepper + +echo 'set incremental-search true + +set recolor "true" + +set default-bg "'$( get_xres color0 )'" +set default-fg "'$( get_xres color7 )'" + +set completion-bg "'$( get_xres color0 )'" +set completion-fg "'$( get_xres color7 )'" +set completion-highlight-bg "'$( get_xres color4 )'" +set completion-highlight-fg "'$( get_xres color7 )'" + +set statusbar-bg "'$( get_xres color4 )'" +set statusbar-fg "'$( get_xres color0 )'" + +set inputbar-bg "'$( get_xres color0 )'" +set inputbar-fg "'$( get_xres color7 )'" + +set recolor-darkcolor "'$( get_xres color7 )'" +set recolor-lightcolor "'$( get_xres color0 )'" + +set window-height "800" +set window-width "600" + +set adjust-open "width" +set statusbar-home-tilde "true" +set statusbar-h-padding "50" +set statusbar-v-padding "50" + +set font "SF Mono 12" + +' > ~/.config/zathura/zathurarc +
M
weechat/weechat.conf
→
weechat/weechat.conf
@@ -393,54 +393,57 @@ default.buffer = "core;weechat;1"
default.buffer = "irc;server.deavmi;2" default.buffer = "irc;deavmi.#general;3" default.buffer = "irc;deavmi.#programming;4" -default.buffer = "irc;server.freenode;5" -default.buffer = "irc;freenode.##crustaceans;6" -default.buffer = "irc;freenode.#kisslinux;7" -default.buffer = "irc;freenode.#kubernetes;8" -default.buffer = "irc;freenode.#lobsters;9" -default.buffer = "irc;freenode.#merveilles;10" -default.buffer = "irc;freenode.#openbsd;11" -default.buffer = "irc;server.rizon;12" -default.buffer = "irc;rizon.#buddy;13" -default.buffer = "irc;rizon.#crimson;14" -default.buffer = "irc;rizon.#homescreen;15" -default.buffer = "irc;rizon.#rice;16" -default.buffer = "python;makera-org.slack.com;17" -default.buffer = "python;makera-org.slack.com.Abhishek,Dish,Kauts;18" -default.buffer = "python;makera-org.slack.com.Abhishek,Kauts;19" -default.buffer = "python;makera-org.slack.com.#backend;20" -default.buffer = "python;makera-org.slack.com.#bugs;21" -default.buffer = "python;makera-org.slack.com.#celebrations;22" -default.buffer = "python;makera-org.slack.com.#design;23" -default.buffer = "python;makera-org.slack.com.#dev;24" -default.buffer = "python;makera-org.slack.com.#general;25" -default.buffer = "python;makera-org.slack.com.#innerjourney;26" -default.buffer = "python;makera-org.slack.com.#legal;27" -default.buffer = "python;makera-org.slack.com.#makera;28" -default.buffer = "python;makera-org.slack.com.#random;29" -default.buffer = "python;makera-org.slack.com.#ycombinator;30" -default.buffer = "python;makera-org.slack.com.Abhishek;31" -default.buffer = "python;makera-org.slack.com.Anirudh;32" -default.buffer = "python;makera-org.slack.com.Dish;33" -default.buffer = "python;makera-org.slack.com.GitHub;34" -default.buffer = "python;makera-org.slack.com.Kavya;35" -default.buffer = "python;makera-org.slack.com.Vishesh;36" -default.buffer = "python;teamcometchat.slack.com;37" -default.buffer = "python;teamcometchat.slack.com.&breakouts-pro;38" -default.buffer = "python;teamcometchat.slack.com.&hipaa;39" -default.buffer = "python;teamcometchat.slack.com.&interns-pro;40" -default.buffer = "python;teamcometchat.slack.com.&xmpp-pro;41" -default.buffer = "python;teamcometchat.slack.com.#general;42" -default.buffer = "python;teamcometchat.slack.com.#product-releases;43" -default.buffer = "python;teamcometchat.slack.com.#random;44" -default.buffer = "python;teamcometchat.slack.com.#spotlight;45" -default.buffer = "python;teamcometchat.slack.com.AjayGajra;46" -default.buffer = "python;teamcometchat.slack.com.AjayPrabhakar;47" -default.buffer = "python;teamcometchat.slack.com.donut;48" -default.buffer = "python;teamcometchat.slack.com.KetanYekale;49" -default.buffer = "python;teamcometchat.slack.com.PrathameshMajgaonkar;50" -default.buffer = "python;teamcometchat.slack.com.RaviRanjan;51" -default.buffer = "python;teamcometchat.slack.com.standuply;52" +default.buffer = "irc;deavmi.*status;5" +default.buffer = "irc;server.freenode;6" +default.buffer = "irc;freenode.#cosmere;7" +default.buffer = "irc;freenode.##crustaceans;8" +default.buffer = "irc;freenode.#kisslinux;9" +default.buffer = "irc;freenode.#kubernetes;10" +default.buffer = "irc;freenode.#lobsters;11" +default.buffer = "irc;freenode.#merveilles;12" +default.buffer = "irc;freenode.#openbsd;13" +default.buffer = "irc;server.rizon;14" +default.buffer = "irc;rizon.#buddy;15" +default.buffer = "irc;rizon.#crimson;16" +default.buffer = "irc;rizon.#fsg;17" +default.buffer = "irc;rizon.#homescreen;18" +default.buffer = "irc;rizon.#rice;19" +default.buffer = "python;makera-org.slack.com;20" +default.buffer = "python;makera-org.slack.com.Abhishek,Dish,Kauts;21" +default.buffer = "python;makera-org.slack.com.Abhishek,Kauts;22" +default.buffer = "python;makera-org.slack.com.#backend;23" +default.buffer = "python;makera-org.slack.com.#bugs;24" +default.buffer = "python;makera-org.slack.com.#celebrations;25" +default.buffer = "python;makera-org.slack.com.#design;26" +default.buffer = "python;makera-org.slack.com.#dev;27" +default.buffer = "python;makera-org.slack.com.#general;28" +default.buffer = "python;makera-org.slack.com.#innerjourney;29" +default.buffer = "python;makera-org.slack.com.#legal;30" +default.buffer = "python;makera-org.slack.com.#makera;31" +default.buffer = "python;makera-org.slack.com.#random;32" +default.buffer = "python;makera-org.slack.com.#ycombinator;33" +default.buffer = "python;makera-org.slack.com.Abhishek;34" +default.buffer = "python;makera-org.slack.com.Anirudh;35" +default.buffer = "python;makera-org.slack.com.Dish;36" +default.buffer = "python;makera-org.slack.com.Kauts;37" +default.buffer = "python;makera-org.slack.com.Kavya;38" +default.buffer = "python;makera-org.slack.com.Vishesh;39" +default.buffer = "python;teamcometchat.slack.com;40" +default.buffer = "python;teamcometchat.slack.com.&breakouts-pro;41" +default.buffer = "python;teamcometchat.slack.com.&hipaa;42" +default.buffer = "python;teamcometchat.slack.com.&interns-pro;43" +default.buffer = "python;teamcometchat.slack.com.&xmpp-pro;44" +default.buffer = "python;teamcometchat.slack.com.#general;45" +default.buffer = "python;teamcometchat.slack.com.#product-releases;46" +default.buffer = "python;teamcometchat.slack.com.#random;47" +default.buffer = "python;teamcometchat.slack.com.#spotlight;48" +default.buffer = "python;teamcometchat.slack.com.AjayGajra;49" +default.buffer = "python;teamcometchat.slack.com.AjayPrabhakar;50" +default.buffer = "python;teamcometchat.slack.com.donut;51" +default.buffer = "python;teamcometchat.slack.com.KetanYekale;52" +default.buffer = "python;teamcometchat.slack.com.PrathameshMajgaonkar;53" +default.buffer = "python;teamcometchat.slack.com.RaviRanjan;54" +default.buffer = "python;teamcometchat.slack.com.standuply;55" default.window = "1;0;0;0;irc;rizon.Carp" default.current = on