├── 16 ├── 256 ├── usess ├── pack ├── mp3 ├── x11 ├── clip ├── view ├── stabbed ├── term ├── xr ├── wayland ├── init-touchscreen ├── wksswp ├── colors ├── powermenu ├── scr ├── rwal ├── ndmen ├── mkc ├── myswaylock ├── wifimen ├── the ├── rcmen └── thew ├── net ├── prt ├── chmac ├── interface ├── gmi ├── netmon ├── dns ├── wifi ├── sshpeed ├── up └── hosts ├── wttr ├── shr ├── rgen ├── squeeze ├── old ├── sysinfo ├── os ├── qr ├── len ├── own ├── map ├── dimensions ├── wm ├── pkgs ├── esc ├── reduce ├── temp ├── repo ├── dl ├── bar ├── log ├── uptime ├── rice ├── chr ├── covid ├── mem ├── nfe ├── mk ├── img ├── mandel └── lbar ├── mkx ├── lib ├── has ├── tumbler_helper.py ├── human ├── std ├── esc └── tumbler_oauth_helper.py ├── tru ├── pow2 ├── toggle-battery-conserve ├── gupd ├── emo ├── branch ├── mkil ├── pi ├── amo ├── mks ├── irc ├── shame ├── webmify ├── base ├── ed ├── arvelie ├── kfe ├── grt ├── mpvbg ├── clean ├── shells ├── e ├── j ├── glo ├── README ├── extract ├── timeleft ├── þ ├── font ├── fetches ├── dylanaraps ├── kiedtl-fetch1 ├── kfetch └── mitchweaver ├── srv └── check-battery ├── COPYING ├── blks ├── missing ├── shtat ├── todo ├── zn ├── archive-image └── bdf2c /usess: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | who | awk '{ print $1 }' | sort | uniq -c | sort -bnr 4 | -------------------------------------------------------------------------------- /pack: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | [ -d "$1" ] || exit 1 4 | 5 | tar -cvf - "$1" | xz -qcT0 >"${1%/}".tar.xz 6 | -------------------------------------------------------------------------------- /mp3: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | yt-dlp \ 4 | -x \ 5 | --embed-thumbnail \ 6 | --audio-format mp3 \ 7 | "$@" 8 | -------------------------------------------------------------------------------- /x11/clip: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # clippy: clipboard manager 4 | # (c) Kied Llaentenn (@kiedtl) 5 | 6 | xclip -selection clipboard 7 | -------------------------------------------------------------------------------- /16: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # 16 color script. 4 | # (c) Dylan Araps 5 | 6 | echo -e \\n \\e[10{0..7}m\ \ \\e[m \\n \\e[4{0..7}m\ \ \\e[m \\n 7 | -------------------------------------------------------------------------------- /net/prt: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # prt - Check what programs are using what ports 4 | # (c) Kied Llaentenn (@kiedtl): 5 | 6 | ss -tulpn | grep LISTEN 7 | -------------------------------------------------------------------------------- /wttr: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # (c) Kiëd Llaentenn 4 | # See the COPYING file for copyright information. 5 | 6 | curl wttr.in/?0FAT 7 | -------------------------------------------------------------------------------- /shr: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # shr - ¯\_(ツ)_/¯ 4 | # (c) Kiëd Llaentenn (@kiedtl) 5 | # See the COPYING for more information. 6 | 7 | printf '%s\n' "¯\_(ツ)_/¯" 8 | -------------------------------------------------------------------------------- /rgen: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # http://github.com/mitchweaver/bin 4 | # 5 | # generate a random string 6 | # 7 | 8 | head /dev/urandom | tr -dc A-Za-z0-9 | cut -c1-"${1:-16}" 9 | -------------------------------------------------------------------------------- /squeeze: -------------------------------------------------------------------------------- 1 | #!/usr/bin/awk -f 2 | # 3 | # http://github.com/mitchweaver/bin 4 | # 5 | # squeeze multiple blank lines into one 6 | # 7 | 8 | !NF {if (++n <= 1) print; next}; {n=0;print} 9 | -------------------------------------------------------------------------------- /old/sysinfo: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # sysinfo - rsfetch wrapper 4 | # (c) Kied Llaentenn (@kiedtl) 5 | 6 | main() { 7 | rsfetch -dkrwNlcuUH@p xbps || pfetch 8 | } 9 | 10 | main "$@" 11 | -------------------------------------------------------------------------------- /x11/view: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # (c) Kiëd Llaentenn 4 | # See the COPYING file for copyright information. 5 | 6 | [ -z "$1" ] && exit 1 7 | 8 | curl -sSL "$1" | feh - -g $(res) 9 | -------------------------------------------------------------------------------- /old/os: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # os - get operating system 4 | # (c) Kiëd Llaentenn 5 | # See the COPYING file for copyright information. 6 | 7 | . /etc/os-release 8 | printf '%s\n' "$ID" 9 | -------------------------------------------------------------------------------- /old/qr: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # http://github.com/mitchweaver/bin 4 | # 5 | # create scannable qr codes in terminal 6 | # 7 | 8 | [ $# -eq 0 ] && read inp && set $inp 9 | 10 | echo $* | curl -F-=\<- qrenco.de 11 | -------------------------------------------------------------------------------- /x11/stabbed: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # (c) Kiëd Llaentenn 4 | # See the COPYING file for copyright information. 5 | 6 | . $HOME/.cache/wal/colors.sh 7 | exec tabbed -U $color0 -u $color1 -O $color0 -o $color7 alacritty --embed 8 | -------------------------------------------------------------------------------- /old/len: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # len - get number of lines in a file 4 | # (c) Kied Llaentenn (@kiedtl) 5 | # See the COPYING for more information. 6 | 7 | [ "$1" ] || exit 1 8 | 9 | main() { 10 | cat "${1}" | wc -l 11 | } 12 | 13 | main "$@" 14 | -------------------------------------------------------------------------------- /old/own: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # own - take ownership of directory 4 | # (c) Kiëd Llaentenn 5 | # See the COPYING for copyright information. 6 | 7 | for file in $(file ${1:-.}) 8 | do 9 | chown kiedtl "${file}" 10 | done 11 | -------------------------------------------------------------------------------- /mkx: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # http://github.com/mitchweaver/bin 4 | # 5 | # toggle a file between executable / non-executable 6 | # 7 | 8 | [ -f "$1" ] || exit 1 9 | 10 | if [ -x "$1" ] ; then 11 | chmod -x "$1" 12 | else 13 | chmod +x "$1" 14 | fi 15 | -------------------------------------------------------------------------------- /lib/has: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # has - i can has command? 4 | # (c) Kiëd Llaentenn 5 | # See the COPYING file for copyright information. 6 | 7 | if command -v "$1" 2>/dev/null >&2 8 | then 9 | return 0 10 | else 11 | return 1 12 | fi 13 | -------------------------------------------------------------------------------- /old/map: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # map - execute command for each item in stdin 4 | # (c) Kiëd Llaentenn 5 | # See the COPYING file for copyright information. 6 | 7 | read items 8 | 9 | for item in $items 10 | do 11 | $@ "$item" 12 | done 13 | -------------------------------------------------------------------------------- /old/dimensions: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # http://github.com/mitchweaver/bin 4 | # 5 | # get screen dimensions 6 | # 7 | 8 | res=$(xrandr --nograb --current | awk '/\*/ {print $1}' | tail -n 1) 9 | res=${res% *} 10 | sw=${res%x*} 11 | sh=${res#*x} 12 | echo -n ${sw%.*} ${sh%.*} 13 | -------------------------------------------------------------------------------- /tru: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # tru - truncate text 4 | # (c) Kiëd Llaentenn 5 | # See the COPYING file for copyright information. 6 | 7 | awk -v len="${1:-$(tput cols)}" \ 8 | '{ 9 | if (length($0) > len) print substr($0, 1, len - 3) "..." 10 | else print 11 | }' 12 | -------------------------------------------------------------------------------- /pow2: -------------------------------------------------------------------------------- 1 | #!/bin/lua 2 | -- 3 | -- pow2 - list powers of 2 4 | -- (c) Kied Llaentenn (@kiedtl) 5 | -- See the COPYING for more information. 6 | 7 | local function pow2(i, to) 8 | print(("2^%d %10d"):format(i, 2 ^ i)) 9 | if i < to then pow2(i + 1, to) end 10 | end 11 | 12 | pow2(1, tonumber(arg[1]) or 24) 13 | -------------------------------------------------------------------------------- /net/chmac: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # chmac - Change the MAC address temporarily. 4 | # Must be run as root! 5 | # (c) Kied Llaentenn (@kiedtl) 6 | 7 | inter=$(interface) 8 | 9 | ip l set "${inter}" down 10 | ip l set "${inter}" address "${1}" 11 | 12 | #ifconfig wlan0 down hw ether $1 13 | ip l set "${inter}" up 14 | -------------------------------------------------------------------------------- /old/wm: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # wm - get window manager 4 | # (c) Kiëd Llaentenn 5 | # See the COPYING file for copyright information. 6 | 7 | [ -z "$DISPLAY" ] && exit 8 | 9 | wm="$(xprop -root -notype _NET_WM_NAME)" 10 | wm="${wm##*= \"}" 11 | wm="${wm%%\"*}" 12 | 13 | printf '%s\n' "$wm" 14 | -------------------------------------------------------------------------------- /toggle-battery-conserve: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # (c) Kiëd Llaentenn 4 | # See the COPYING file for copyright information. 5 | 6 | case "$(sudo tlp-stat -b | grep conservation_mode | cut -d' ' -f3)" in 7 | 0) sudo tlp setcharge 90 1 BAT0 ;; 8 | 1) sudo tlp setcharge 90 0 BAT0 ;; 9 | esac 10 | -------------------------------------------------------------------------------- /gupd: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # gupd - git: update file 4 | # (c) Kiëd Llaentenn 5 | # See the COPYING file for copyright information. 6 | 7 | . $(which std) 8 | 9 | file="$1" 10 | shift 11 | 12 | git add "$file" || die "git add failed" 13 | git commit -m "$file: ${@:-update}" || die "git commit failed" 14 | -------------------------------------------------------------------------------- /emo: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # emo - copy emoticons or whatever these things are called 4 | # (c) Kiëd Llaentenn 5 | # See the COPYING file for copyright information. 6 | 7 | list=" 8 | shrug ¯\_(ツ)_/¯ 9 | " 10 | echo $list > /tmp/$$-emo 11 | ndmen "cat /tmp/$$-emo" cat | cut -d' ' -f2- | tr -d '\n' | xsel -nib 12 | -------------------------------------------------------------------------------- /x11/term: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # term - my terminal of choice 4 | # (c) Kiëd Llaentenn 5 | # See the COPYING file for copyright information. 6 | 7 | command -v ghostty 2>/dev/null >&2 && \ 8 | exec ghostty 9 | 10 | command -v alacritty 2>/dev/null >&2 && \ 11 | exec alacritty 12 | 13 | exec xterm 14 | -------------------------------------------------------------------------------- /old/pkgs: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # pkgs - get number of pkgs 4 | # (c) Kiëd Llaentenn 5 | # See the COPYING file for copyright information. 6 | 7 | command= 8 | [ -z "$1" ] && set -- "$(os)" 9 | 10 | case "$1" in 11 | void) 12 | command="xbps-query -l" 13 | ;; 14 | esac 15 | 16 | $command | wc -l 17 | -------------------------------------------------------------------------------- /old/esc: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # esc - swap CAPS LOCK and Escape 4 | # (c) Kied Llaentenn (@kiedtl) 5 | # See the COPYING for more information. 6 | 7 | command -v xmodmap >/dev/null 2>&1 || exit 1 8 | 9 | xmodmap -e "clear lock" 10 | xmodmap -e "keycode 9 = Caps_Lock NoSymbol Caps_Lock" 11 | xmodmap -e "keycode 66 = Escape NoSymbol Escape" 12 | -------------------------------------------------------------------------------- /branch: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # bra - get git branch 4 | # (c) Kiëd Llaentenn 5 | # See the COPYING file for copyright information. 6 | # 7 | # usage: bra [-n] 8 | # -n don't output a newline 9 | 10 | (git rev-parse --abbrev-ref HEAD 2>/dev/null || \ 11 | echo 'none') | tr -d '\n' 12 | 13 | [ "$1" = "-n" ] || printf '\n' 14 | -------------------------------------------------------------------------------- /mkil: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # mkil - 'kill -9 $(ps | dmenu)' 4 | # (c) Kiëd Llaentenn 5 | # See the COPYING file for copyright information. 6 | 7 | cmd='ps -eukiedtl axh -opid,%cpu,%mem,command --sort=-%cpu' 8 | pid=$(ndmen "$cmd" cat | awk '{print $1}') 9 | [ "$pid" ] && herbe "$($(which kill) -9 "$pid" 2>&1 && echo Killed $pid)" 10 | -------------------------------------------------------------------------------- /pi: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # pi [scale] - calculate pi to [scale] digits 4 | # (c) Kiëd Llaentenn 5 | # See the COPYING file for copyright information. 6 | # 7 | # this uses the machin formula 8 | # pi = (4 * arctangent(1/5) - arctangent(1/239)) * 4 9 | 10 | echo " 11 | scale=${1:-10} 12 | (4 * a(1/5) - a(1/239)) * 4 13 | " | bc -ql 14 | -------------------------------------------------------------------------------- /lib/tumbler_helper.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import pytumblr 3 | import json 4 | 5 | blogname = sys.argv[5] 6 | postid = sys.argv[6] 7 | 8 | tumblr = pytumblr.TumblrRestClient(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4]) 9 | url = '/v2/blog/{}/posts/{}'.format(blogname, postid) 10 | response = tumblr.request.get(url, {}) 11 | 12 | print(json.dumps(response)) 13 | -------------------------------------------------------------------------------- /old/reduce: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # (c) Kiëd Llaentenn 4 | # See the COPYING file for copyright information. 5 | 6 | command=$@ 7 | 8 | read items 9 | set -- $items 10 | 11 | if [ $# -lt 2 ] 12 | then 13 | echo "$@" 14 | exit 0 15 | fi 16 | 17 | accm=$($command "$1" "$2") 18 | shift 2 19 | 20 | exec echo "$accm" $@ | $0 $command 21 | -------------------------------------------------------------------------------- /x11/xr: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # xr -- reload xrdb 4 | # (c) Kiëd Llaentenn 5 | # See the COPYING file for copyright information. 6 | 7 | xrdb -merge ~/.Xresources 8 | xrdb -merge ~/.cache/wal/colors.Xresources 9 | xrdb -merge ~/.cache/wal/2bwm.Xresources 10 | xrdb -merge ~/.cache/wal/polybar.Xresources 11 | xrdb -merge ~/.cache/wal/herbe.Xresources 12 | -------------------------------------------------------------------------------- /amo: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # bin/amo - play among-sus on tilde.team! 4 | # (c) Kiëd Llaentenn 5 | # See the COPYING file for copyright information. 6 | 7 | LOGS="$HOME/.local/share/among-sus/log-$(date +%Y-%m-%d).txt" 8 | 9 | if has rlwrap; then 10 | rlwrap nc tilde.team 1234 | tee -a "$LOGS" 11 | else 12 | nc tilde.team 1234 | tee -a "$LOGS" 13 | fi 14 | -------------------------------------------------------------------------------- /old/temp: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # http://github.com/mitchweaver/bin 4 | # 5 | # get CPU temperature 6 | # 7 | 8 | case $(uname) in 9 | OpenBSD) 10 | temp=$(sysctl -n hw.sensors.cpu0.temp0) 11 | printf '%s°C\n' "${temp%.*}" 12 | ;; 13 | Linux) 14 | read -r tmp ||' 11 | } 12 | 13 | main "$@" 14 | 15 | -------------------------------------------------------------------------------- /mks: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # mks - create a shell script using a template. 4 | # partly stolen from Dylan Arap's dotfiles. 5 | 6 | [ -z "$1" ] && exit 7 | 8 | echo "#!/bin/sh 9 | #" > "$1" 10 | 11 | [ -z "$2" ] || echo "# $1 - $2" >> "$1" 12 | 13 | echo "# (c) Kiëd Llaentenn 14 | # See the COPYING file for copyright information. 15 | 16 | " >> "$1" 17 | 18 | chmod +x "$1" 19 | -------------------------------------------------------------------------------- /old/dl: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | [ "$1" ] || { read -r inp && set "$inp" ; } 4 | 5 | case "$1" in 6 | *) 7 | exec curl \ 8 | --ipv4 \ 9 | --disable \ 10 | --location \ 11 | --retry 2 \ 12 | --continue-at - \ 13 | --url "$1" \ 14 | --progress-bar \ 15 | --output "${1##*/}" 16 | ;; 17 | esac 18 | -------------------------------------------------------------------------------- /old/bar: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # bar - the holy polybar 4 | # (c) Kiëd Llaentenn 5 | 6 | get_dwminfo() { 7 | mode=$(cat /tmp/dwm_info/current_layout) 8 | case $mode in 9 | "0") echo "[]=" ;; 10 | "1") echo "><>" ;; 11 | "2") echo "[M]" ;; 12 | "3") echo "(@)" ;; 13 | "4") echo "[\]" ;; 14 | esac 15 | } 16 | 17 | main() { 18 | pkill polybar 19 | exec polybar -r bar 20 | } 21 | 22 | main "$@" 23 | -------------------------------------------------------------------------------- /old/log: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # log - read logs from an IRC channel 4 | # as always, mostly stolen from Dylan Araps 5 | # https://github.com/dylanaraps/bin 6 | 7 | log() { 8 | curl -sSL "https://freenode.logbot.info/${1}/${2}/raw" | \ 9 | while read -r _ n m; do 10 | n=${n%>} 11 | n=${n#<} 12 | 13 | printf '%12s %s\n' "$n" "$m" 14 | done 15 | } 16 | 17 | log "${1:-kisslinux}" "$(date +%Y%m%d)" 18 | -------------------------------------------------------------------------------- /lib/human: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # human - convert sizes to human-readable sizes 4 | # stolen from stackoverflow 5 | 6 | input="$@" 7 | [ -z "$input" ] && read -r input 8 | 9 | echo "$input" | awk \ 10 | 'function human(x) { 11 | if (x<1000) {return x} else {x/=1024} 12 | s="kMGTEPZY"; 13 | while (x>=1000 && length(s)>1) 14 | {x/=1024; s=substr(s,2)} 15 | return int(x+0.5) substr(s,1,1) 16 | } 17 | {sub(/^[0-9]+/, human($1)); print}' 18 | -------------------------------------------------------------------------------- /x11/wayland: -------------------------------------------------------------------------------- 1 | #!/bin/sh -e 2 | # 3 | # (c) Kiëd Llaentenn 4 | # See the COPYING file for copyright information. 5 | 6 | eval "$(dbus-launch --sh-syntax)" 7 | 8 | export DBUS_SESSION_BUS_ADDRESS 9 | export DISPLAY=:7 10 | 11 | swayidle -w \ 12 | timeout 300 'niri msg action power-off-monitors' \ 13 | timeout 600 myswaylock \ 14 | resume 'niri msg action power-on-monitors' \ 15 | before-sleep myswaylock & 16 | 17 | ssh-agent niri --session 18 | -------------------------------------------------------------------------------- /net/interface: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # interface: get network interface 4 | # (c) Kiëd Llaentenn 5 | # originally from http://github.com/mitchweaver/bin 6 | # 7 | # (wifi preferred, if no wifi interface 8 | # is found try to use ethernet) 9 | # 10 | 11 | for dev in wl ens eth enp; do 12 | set -- "$(ip l | grep $dev)" 13 | [ -z "$1" ] || break 14 | done 15 | 16 | echo "$*" | \ 17 | sed 's/Link//' | \ 18 | awk '{print $2}' | \ 19 | sed 's/://' | \ 20 | head -n 1 21 | -------------------------------------------------------------------------------- /irc: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # irc - tilde.town irc tunnel 4 | # (c) Kiëd Llaentenn 5 | # See the COPYING file for copyright information. 6 | 7 | PIDFILE="/tmp/irc_ssh_pid" 8 | 9 | case "$1" in 10 | start) 11 | ssh -N town-irc -L localhost:6667:localhost:6667 & 12 | echo $! > "$PIDFILE" 13 | ;; 14 | stop) 15 | if [ -f "$PIDFILE" ] 16 | then 17 | kill $(cat "$PIDFILE") 18 | rm -f "$PIDFILE" 19 | fi 20 | ;; 21 | esac 22 | -------------------------------------------------------------------------------- /x11/init-touchscreen: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # init-touchscreen - Initialize touchscreen input 4 | # (c) Kiëd Llaentenn 5 | # See the COPYING file for copyright information. 6 | 7 | # https://www.reddit.com/r/i3wm/comments/h8i0nm/touchscreen_issues_when_using_second_monitor/ 8 | monitor_id=$(xrandr --listmonitors | grep '^ 0' | awk '{print $4}') 9 | touchinput_id=$(xinput | grep Finger | awk -F'=' '{print $2}' | cut -f1) 10 | xinput map-to-output $touchinput_id $monitor_id 11 | 12 | touchegg & 13 | -------------------------------------------------------------------------------- /net/gmi: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # (c) Kiëd Llaentenn 4 | # See the COPYING file for copyright information. 5 | 6 | . $(which std) 7 | 8 | [ "$1" ] || die "need gemini url" 9 | 10 | url="$1" 11 | domain="${url##*://}" domain="${domain%%/*}" 12 | port=1965 13 | 14 | log "requesting gemini://$url from $domain" 15 | 16 | echo "gemini://$url" | \ 17 | openssl s_client -crlf -quiet \ 18 | -connect "$domain:$port" \ 19 | -servername "$domain" \ 20 | -no_ssl3 -no_tls1 -no_tls1_1 21 | -------------------------------------------------------------------------------- /old/uptime: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # uptime - get uptime on Linux hosts 4 | # (c) Kiëd Llaentenn 5 | # See the COPYING file for copyright information. 6 | 7 | seconds=$(cat /proc/uptime) 8 | seconds=${seconds%%.*} 9 | 10 | days=$((seconds/86400)) 11 | hours=$((seconds/3600%24)) 12 | minutes=$((seconds/60%60)) 13 | 14 | [ $days = 0 ] || uptime="${uptime}${days}d " 15 | [ $hours = 0 ] || uptime="${uptime}${hours}h " 16 | [ $minutes = 0 ] || uptime="${uptime}${minutes}m" 17 | 18 | echo "${uptime}" 19 | -------------------------------------------------------------------------------- /shame: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # (c) Kiëd Llaentenn 4 | 5 | git log --format='%ae %H' --numstat $@ | \ 6 | awk ' 7 | NF == 2 { user=$1 } 8 | NF == 3 { ins[user]+=$1; del[user]+=$2; } 9 | END { 10 | for (user in ins) { 11 | tcon+=1; 12 | tins+=ins[user]; tdel+=del[user]; 13 | 14 | printf("%s: %d insertions, %d deletions.\n", 15 | user, ins[user], del[user]) 16 | } 17 | }' | \ 18 | column -t 19 | -------------------------------------------------------------------------------- /old/rice: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # rice - restore previous rice 4 | # (c) Kied Llaentenn (@kiedtl) 5 | # See the COPYING for more information. 6 | 7 | main() { 8 | # set dwm's resources 9 | dwm_rice 10 | 11 | # merge Xresources 12 | xrdb -merge ~/etc/Xorg/.Xresources 13 | 14 | # merge pywal's Xresources 15 | xrdb -merge ~/.cache/wal/colors.Xresources 16 | 17 | # set wallpaper 18 | [ -f ~/.fehbg ] && ~/.fehbg & 19 | 20 | # start xcompmgr 21 | xcompmgr & 22 | 23 | # start bars 24 | bar & 25 | } 26 | 27 | main "$@" 28 | -------------------------------------------------------------------------------- /x11/wksswp: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # (c) Kiëd Llaentenn 4 | # See the COPYING file for copyright information. 5 | 6 | # Sometimes I3SOCK might be out of date. Remove it to force i3-msg to find 7 | # actual pid of i3. 8 | unset I3SOCK 9 | 10 | new=$1 11 | current=$(i3-msg -t get_workspaces | \ 12 | jq 'map(select(.focused == true)) | .[].name' | \ 13 | tr -d '"') 14 | 15 | i3-msg "rename workspace $new to temporary; \ 16 | rename workspace $current to $new; \ 17 | rename workspace temporary to $current" 18 | -------------------------------------------------------------------------------- /webmify: -------------------------------------------------------------------------------- 1 | #!/bin/sh -e 2 | # 3 | # http://github.com/mitchweaver/bin 4 | # 5 | # convert video files to webm 6 | # 7 | 8 | for file ; do 9 | if [ -f "$file" ] ; then 10 | ext=${file##*.} 11 | 12 | # shellcheck disable=SC2295 13 | ffmpeg -i "$1" -y \ 14 | -c:v libvpx -crf 4 -b:v 1500K -vf \ 15 | scale=640:-1 -ac 1 -c:a libvorbis "${file%$ext}webm" 16 | 17 | rm -f "$file" 18 | else 19 | >&2 printf 'No such file: %s\n' "$file" 20 | continue 21 | fi 22 | done 23 | -------------------------------------------------------------------------------- /x11/colors: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # colors - dump pywal colorscheme 4 | # (c) Kiëd Llaentenn 5 | # See the COPYING for copyright information. 6 | 7 | [ -f "$HOME/.cache/wal/colors.sh" ] || \ 8 | exit 1 9 | . "$HOME/.cache/wal/colors.sh" 10 | 11 | printf "$foreground 12 | $background 13 | $cursor 14 | $color0 15 | $color1 16 | $color2 17 | $color3 18 | $color4 19 | $color5 20 | $color6 21 | $color7 22 | $color8 23 | $color9 24 | $color10 25 | $color11 26 | $color12 27 | $color13 28 | $color14 29 | $color15\n" | sed 's/#//g' 30 | -------------------------------------------------------------------------------- /base: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # http://github.com/mitchweaver/bin 4 | # 5 | # convert between different number formats 6 | # 7 | 8 | usage() { 9 | >&2 echo "Usage: conv -i {d,b,h,o} -o {d,b,h,o} " 10 | exit 1 11 | } 12 | 13 | case "$2" in 14 | d) in="A" ;; 15 | b) in="2" ;; 16 | h) in="16" ;; 17 | o) in="8" ;; 18 | *) usage 19 | esac 20 | 21 | case "$4" in 22 | d) out="A" ;; 23 | b) out="2" ;; 24 | h) out="16" ;; 25 | o) out="8" ;; 26 | *) usage 27 | esac 28 | 29 | echo "obase=$out ; ibase=$in ; $5" | bc 30 | -------------------------------------------------------------------------------- /ed: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # ed - open file in editor. 4 | # (c) Kied Llaentenn (@kiedtl) 5 | # See the COPYING for more information. 6 | 7 | . $(which std) 8 | 9 | [ -d "$1" ] && die 'cannot edit directory' 10 | 11 | [ ! -f "$1" ] && { 12 | printf "ed: \"${1}\" doesn't exist -- create? [yN] "; 13 | read ans; 14 | 15 | case "$ans" in 16 | [Yy]*) touch "$1" ;; 17 | *) exit 1 ;; 18 | esac 19 | } 20 | 21 | ed="${EDITOR:-nvim}" 22 | has $ed || ed="vim --clean" 23 | has $ed || ed="vi" 24 | 25 | [ -f "$1" ] && exec $ed "$@" 26 | -------------------------------------------------------------------------------- /arvelie: -------------------------------------------------------------------------------- 1 | #!/usr/bin/lua 2 | -- 3 | -- arvelie - calculate date in arvelie format 4 | -- (c) Kiëd Llaentenn 5 | -- See the COPYING file for copyright information. 6 | 7 | local date = os.date("*t") 8 | local absday = date.yday 9 | 10 | 11 | if date.year < 2000 then 12 | print("ye olde days") 13 | return 14 | end 15 | 16 | local y = date.year - 2000 17 | local m_ind = math.floor((absday / 14) + 0.5) + 1 18 | local m = (" ABCDEFGHIJKLMNOPQRSTUVWXYZ"):sub(m_ind, m_ind) 19 | local d = absday % 14 20 | local dstr = ("%02d%s%02d"):format(y, m, d) 21 | 22 | print(dstr) 23 | -------------------------------------------------------------------------------- /kfe: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # simple-colored - simple, colored. 4 | # (c) Kiëd Llaentenn 5 | # See the COPYING file for copyright information. 6 | 7 | br="$(printf '\033[33m')" 8 | re="$(printf '\033[0m')" 9 | bo="$(printf '\033[1m')" 10 | 11 | echo " 12 | ${br}${USER}${re}@${br}$(hostname)${re} 13 | ${br} ${re}$(os) 14 | ${br} ${re}$(uname -r) 15 | ${br} ${re}$(upt) 16 | ${br} ${re}$(pkgs '$pkgs_total') 17 | ${br} ${re}$(wm) 18 | ${br} ${re}${SHELL##*/} 19 | ${br} ${re}xterm 20 | ${br} ${re}$(interface) 21 | ${br} ${re}$(disk) 22 | ${br} ${re}$(mem) 23 | " 2>/dev/null 24 | -------------------------------------------------------------------------------- /net/netmon: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # netmon [delay] - monitor network 4 | # 5 | # (c) Kiëd Llaentenn 6 | # See the COPYING file for copyright information. 7 | 8 | tx_path=/sys/class/net/$(interface)/statistics/tx_packets #bytes 9 | rx_path=/sys/class/net/$(interface)/statistics/rx_packets #bytes 10 | 11 | while :; do 12 | sleep "${1:-1}" 13 | 14 | read -r tx_cur < "$tx_path" 15 | read -r rx_cur < "$rx_path" 16 | cur=$((rx_cur+tx_cur)) 17 | 18 | printf '%s,%s\n' \ 19 | "$(date +%s)" \ 20 | "$(dc -e "$cur ${last:-$cur} - p")" 21 | 22 | last=$cur 23 | done 24 | -------------------------------------------------------------------------------- /old/chr: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # chr - chroot 4 | # (c) Kiëd Llaentenn 5 | # See the COPYING file for copyright information. 6 | 7 | mount --bind ~/glibc ~/glibc || exit 1 8 | 9 | [ -f ~/glibc/etc/hosts] || \ 10 | cp -L /etc/hosts ~/glibc/etc/hosts 11 | 12 | [ -f ~/glibc/etc/resolv.conf ] || \ 13 | cp -L /etc/resolv.conf ~/glibc/etc/resolv.conf 14 | 15 | mount -t proc none ~/glibc/proc || exit 1 16 | mount -t sysfs none ~/glibc/sys || exit 1 17 | 18 | mount --rbind /dev ~/glibc/dev || exit 1 19 | mount --rbind /run ~/glibc/run || exit 1 20 | 21 | chroot ~/glibc 22 | 23 | umount -Rl ~/glibc 24 | -------------------------------------------------------------------------------- /256: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # 256 -- print colors in the 256 palette 4 | # (c) Kiëd Llaentenn 5 | # See the COPYING for more information 6 | 7 | e="$(printf "\033")" 8 | t="Lorem \033[1mipsum." 9 | 10 | f256() { 11 | i=$1 12 | 13 | while [ $i -le 255 ] 14 | do 15 | printf "${i}$e[4D$e[4C" 16 | printf "$e[38;5;${i}m $t $e[0m " 17 | printf "$e[48;5;${i}m$e[30m $t $e[0m " 18 | printf "$e[48;5;${i}m $t $e[0m " 19 | printf "$e[48;5;${i}m$e[K$e[m\n" 20 | i=$(( i + 1 )) 21 | done 22 | } 23 | 24 | if [ -z "${1}" ]; then 25 | f256 0 26 | else 27 | f256 "${1}" 28 | fi 29 | -------------------------------------------------------------------------------- /grt: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Simple script to toggle github remote to/from https/git. 4 | # (c) Dylan Araps 5 | 6 | repo_remote="$(git remote get-url origin || exit 1)" 7 | 8 | [[ -z $repo_remote || ! $repo_remote =~ github.com ]] && exit 1 9 | 10 | if [[ $repo_remote =~ ^git@github ]]; then 11 | repo=${repo_remote/'git@github.com:'} 12 | repo=${repo%'.git'} 13 | repo=https://github.com/${repo} 14 | else 15 | repo=${repo_remote/'https://github.com/'} 16 | repo=${repo%%.git} 17 | repo=git@github.com:${repo}.git 18 | fi 19 | 20 | printf '%s\n' "Changing repo to $repo" 21 | git remote set-url origin "$repo" 22 | -------------------------------------------------------------------------------- /mpvbg: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # http://github.com/mitchweaver/bin 4 | # 5 | # play a video on the root window with mpv 6 | # 7 | 8 | [ -f "$1" ] || printf "I CAN HAS WAL\n" 9 | 10 | mpv -wid 0 --keepaspect=no --loop \ 11 | --really-quiet --name=mpvbg --title=mpvbg "$1" & 12 | 13 | # store our pid here so we can avoid killing our background later 14 | # Example: $ kill $(pgrep mpv | grep -v $(pgrep -P $(cat ${HOME}/.cache/mpvbg.pid))) 15 | # --- Here we are killing "all mpvs, except with THIS PID" 16 | # --- This lets us kill a video we're watching, without stopping our desktop background! 17 | echo $! >${HOME}/.cache/mpvbg.pid 18 | -------------------------------------------------------------------------------- /old/covid: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # http://github.com/mitchweaver/bin 4 | # 5 | # output current COVID-19 statistics 6 | # 7 | 8 | url="https://coronavirus-tracker-api.herokuapp.com/all" 9 | 10 | read -r confirmed deaths recovered </dev/null 2>&1; then 11 | xbps-remove -o 12 | rm -rf /var/cache/xbps/* 13 | fi 14 | 15 | [ -d ~/.cargo ] && rm -rf ~/.cargo/* 16 | [ -d ~/go ] && { 17 | for junk in $(find ~/go/pkg/* ~/go/src/*); do 18 | chmod 700 "$junk" 19 | rm -f "$junk" >&2 2>/dev/null 20 | done 21 | } 22 | [ -d ~/tmp ] && rm -rf ~/tmp/* 23 | [ -d ~/Downloads ] && rm -rf ~/Downloads/* 24 | -------------------------------------------------------------------------------- /shells: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # shells: see who uses what shell 4 | # (c) Kiëd Llaentenn 5 | # See the COPYING file for copyright information. 6 | 7 | if [ "$1" = "--help" ]; then 8 | printf "shells: see who uses what shell\n" 9 | exit 0 10 | fi 11 | 12 | cat /etc/passwd | \ 13 | awk -F/ -v CONVFMT=%.2g ' 14 | { 15 | if (/.*nologin.*|.*false.*|.*sync.*/) 16 | printf "" 17 | else 18 | shells[$NF]+=1; total+=1 19 | } 20 | 21 | END { 22 | for (sh in shells) { 23 | p=(shells[sh]*100)/total 24 | printf "%8s%% %-5s (%s)\n", p, sh, shells[sh] 25 | } 26 | } 27 | ' | sort -bn 28 | -------------------------------------------------------------------------------- /x11/powermenu: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # powermenu - sleep/reboot/etc menu with dmenu 4 | # (c) Kiëd Llaentenn 5 | # See the COPYING file for copyright information. 6 | 7 | . $(which std) 8 | INTERFACE=$(interface) 9 | 10 | chosen=$(echo "login\nsleep\nhibernate\nhalt\nreboot" | ndmen 'cat -' 'cat' || exit 1) 11 | [ -z "$chosen" ] && exit 0 12 | 13 | confirm=$(echo "yes\nno" | NDMEN_PROMPT="Confirm $chosen " ndmen 'cat -' 'cat' || exit 1) 14 | [ "$confirm" = "no" ] && exit 0 15 | 16 | case "$chosen" in 17 | lock) i3lock-fancy -pf Fira-Code-Regular ;; 18 | sleep) sudo zzz ;; 19 | hibernate) sudo ZZZ ;; 20 | halt) sudo halt ;; 21 | reboot) sudo reboot ;; 22 | esac 23 | -------------------------------------------------------------------------------- /e: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # e [iters] [scale] - calculate e 4 | # (c) Kiëd Llaentenn 5 | # See the COPYING file for copyright information. 6 | # 7 | # this uses the following infinite series formula: 8 | # 9 | # inf 10 | # ___ 1 11 | # e = 1 + \ ─── 12 | # /__ +n! 13 | # n=0 14 | 15 | echo " 16 | define fac(n) { 17 | if (n == 1) { 18 | return 1; 19 | } 20 | 21 | return n * fac(n - 1) 22 | } 23 | 24 | define calc_e(iters, accm) { 25 | if (iters == 0) { 26 | return accm 27 | } 28 | 29 | return calc_e(iters - 1, accm + 1/(fac(iters))) 30 | } 31 | 32 | scale=${2:-10} 33 | 1 + calc_e(${1:-20}, 0) 34 | " | bc -ql 35 | -------------------------------------------------------------------------------- /j: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # j - Java stuff. 4 | # (c) Kiëd Llaentenn 5 | # See the COPYING file for copyright information. 6 | 7 | . $(which std) 8 | 9 | JUNIT="/home/kiedtl/.local/lib/java/junit-platform-console-standalone.jar" 10 | 11 | name=${2%%.java} 12 | 13 | [ -f $JUNIT ] || die "Can't find jUnit" 14 | 15 | case "$1" in 16 | c) javac -cp .:$JUNIT ${name}.java ;; 17 | r) 18 | javac -cp .:$JUNIT ${name}.java || die "Compilation failed." 19 | shift 2 20 | java -ea $name "$@" 21 | ;; 22 | t) 23 | javac -cp .:$JUNIT ${name}.java || die "Compilation failed." 24 | java -jar $JUNIT -cp . --select-class ${name}Test 25 | ;; 26 | esac 27 | -------------------------------------------------------------------------------- /old/mem: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # mem - get memory usage information 4 | # (c) Kiëd Llaentenn 5 | # See the COPYING file for copyright information. 6 | 7 | while IFS=: read -r set data 8 | do 9 | data="${data%%kB}" 10 | 11 | case "$set" in 12 | MemTotal) 13 | used=$((used+=data)) 14 | total=$((total=data)) 15 | ;; 16 | 17 | Shmem) 18 | used=$((used+=data)) 19 | ;; 20 | 21 | MemFree|Buffers|Cached|SReclaimable) 22 | used=$((used-=data)) 23 | ;; 24 | esac 25 | done < /proc/meminfo 26 | 27 | used=$((used/=1024)) 28 | total=$((total/=1024)) 29 | 30 | printf '%sM / %sM\n' "$used" "$total" 31 | -------------------------------------------------------------------------------- /x11/scr: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # scr: take a screenshot. 4 | # (c) Dylan Araps 5 | 6 | scr_dir=~/img/screenshots 7 | 8 | # Give time for the dmenu window to go away... 9 | sleep 0.4 10 | 11 | printf -v date '%(%F)T' -1 12 | printf -v time '%(%I-%M-%S)T' -1 13 | 14 | mkdir -p "${scr_dir}/${date}" 15 | scr=${scr_dir}/${date}/${date}-${time} 16 | 17 | # Old X11 stuff 18 | #import -window root "$scr".png 19 | #import "$scr".png 20 | 21 | grim -g "$(slurp)" "$scr.png" || exit 1 22 | cp -f "$scr".png "${scr_dir}/current.png" 23 | 24 | [ -z "$1" ] || up f "${scr_dir}/current.png" 25 | #xclip -selection clipboard -target image/png -i < "${scr_dir}/current.png" 26 | wl-copy -t "image/png" < "${scr_dir}/current.png" 27 | -------------------------------------------------------------------------------- /glo: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # glo -- Git LOg 4 | # (c) Kiëd Llaentenn 5 | # See the COPYING file for copyright information. 6 | 7 | ttywidth="$(tput cols)" 8 | 9 | # 34 = 7 (hash) + 1 (spc) + 22 (email) 10 | width=34 11 | 12 | # use dc 'cause it's faster than bc :) 13 | foldwidth="$(echo "$ttywidth $width - p" | dc)" 14 | 15 | git log --format="%as %h %aE %s" | \ 16 | while read -r date hash email subject 17 | do 18 | email="$(echo "$email" | tru 22)" 19 | subject="$(echo "$subject" | tru "$foldwidth")" 20 | 21 | printf '\033[38m%s \033[31m%s \033[0;1m%25s\033[m %s\n' \ 22 | "$date" "$hash" "<$email>" "$subject" 23 | done | \ 24 | head -n"${1:-10}" 25 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | Random scripts 2 | ============= 3 | 4 | All scripts, unless otherwise noted at the top of each file, were written 5 | by me. If I have stolen any scripts from others I've usually^W preserved the 6 | headers and authorship information. 7 | 8 | If you see one of your scripts here, and I forgot to give you credit, just 9 | let me know with an issue or email and I'll fix it. 10 | 11 | Special thanks to: 12 | - Dylan Araps (@dylanaraps) 13 | - Mitch Weaver (@mitchweaver) 14 | 15 | License 16 | ======= 17 | 18 | - MIT License. Use these scripts however you please, but preserve the 19 | headers. 20 | 21 | 22 | TODO 23 | ==== 24 | 25 | - esc: emit VTE escape codes 26 | usage: esc [ARG]... 27 | e.g.: esc SETBG red 28 | - params: parse arguments 29 | -------------------------------------------------------------------------------- /net/dns: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # http://github.com/mitchweaver/bin 4 | # 5 | # return dns server with lowest ping 6 | # 7 | 8 | servers="\ 9 | 10.0.0.123 10 | 1.1.1.1 11 | 1.0.0.1 12 | 4.2.2.1 13 | 4.2.2.2 14 | 8.8.8.8 15 | 8.4.4.8 16 | 9.9.9.9 17 | 8.26.56.26 18 | 8.20.247.30 19 | 75.75.75.75 20 | 75.75.76.76 21 | " 22 | 23 | lowest_time=9999 24 | lowest_dns="" 25 | 26 | for i in $servers ; do 27 | time=$(ping -c 1 -s 16 -w 1 -n $i) 28 | [ $? -gt 0 ] && continue 29 | 30 | time=$(echo $time | grep -oE '[0-9]+(\.[0-9]+)?( )?ms' | \ 31 | head -n 1 | sed -E -e 's/ms//' -e 's/\.[0-9]+//') 32 | 33 | if [ $time -lt $lowest_time ] ; then 34 | lowest_time=$time 35 | lowest_dns=$i 36 | fi 37 | done 38 | 39 | echo $lowest_dns 40 | -------------------------------------------------------------------------------- /net/wifi: -------------------------------------------------------------------------------- 1 | #!/bin/mksh 2 | # 3 | # wfi - Connect to Wi-Fi 4 | # Create configuration with the following command: 5 | # wpa_passphrase NETWORK P@S$W0rD1234 | tee /etc/wpa_supplicant.conf 6 | # by Kied Llaentenn (@kiedtl) 7 | # 8 | # TODO: ethernet 9 | 10 | INTERFACE=$(interface) 11 | INTERFACE=${INTERFACE:-wlan0} 12 | 13 | dhcp() { 14 | if has dhcpcd; then 15 | doas pkill dhcpcd ; doas dhcpcd 16 | elif has udhcpc; then 17 | doas pkill udhcpc ; doas udhcpc -i "$INTERFACE" 18 | fi 19 | } 20 | 21 | wifi() { 22 | doas ip l set $INTERFACE up 23 | doas pkill wpa_supplicant ; doas wpa_supplicant -B \ 24 | -c /etc/wpa_supplicant/wpa_supplicant.conf \ 25 | -i $INTERFACE 26 | sleep 1 27 | dhcp 28 | } 29 | 30 | wifi "$@" 31 | -------------------------------------------------------------------------------- /old/nfe: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # simple-colored - simple, colored. 4 | # (c) Kiëd Llaentenn 5 | # See the COPYING file for copyright information. 6 | 7 | br="$(printf '\033[1;31m')" 8 | re="$(printf '\033[0m')" 9 | bo="$(printf '\033[1m')" 10 | 11 | echo " 12 | ) ( 13 | ( ) ) 14 | ) ( ( 15 | │${re} ) ${re}│ ${br}${USER}${re}@${br}$(hostname)${re} 16 | │${br}▒▒▒▒▒▒▒▒▒▒▒▒▒▒${re}│ ${br}os ${re}$(os) $(uname) 17 | .-│${br}▒▒▒▒▒▒▒▒▒▒▒▒▒▒${re}│ ${br}shell ${re}${SHELL##*/} 18 | / │${br}▒▒▒▒▒▒▒▒▒▒▒▒▒▒${re}│ ${br}kernel ${re}$(uname -r) 19 | \ │${br}▒▒▒▒▒▒▒▒▒▒▒▒▒▒${re}│ ${br}uptime ${re}$(upt) 20 | '-│${br}▒▒▒▒▒▒▒▒▒▒▒▒▒▒${re}│ ${br}pkgs ${re}$(pkgs '$pkgs_total') 21 | └──────────────┘ ${br}memory ${re}$(mem) 22 | " 2>/dev/null 23 | -------------------------------------------------------------------------------- /old/mk: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # mk - build a project 4 | # (c) Kiëd Llaentenn 5 | # See the COPYING for copyright information. 6 | 7 | com= 8 | 9 | # prefer samurai, it's a bit faster 10 | samu="samu" 11 | command -v "$samu" 2>/dev/null >&2 || \ 12 | samu="ninja" 13 | 14 | # GNU Make 15 | [ -f makefile ] && com="make" 16 | [ -f Makefile ] && com="make" 17 | 18 | # Meson 19 | [ -f meson.build ] && com="$samu -C build" 20 | 21 | # CMake 22 | if [ -f CMakeLists.txt ] 23 | then 24 | mkdir -p build && cd build 25 | cmake .. \ 26 | -DCMAKE_BUILD_TYPE=Release \ 27 | -DCMAKE_UNITY_BUILD=True \ 28 | -GNinja || \ 29 | exit 1 30 | com="$samu" 31 | fi 32 | 33 | # Rust 34 | [ -f Cargo.toml ] && \ 35 | com="cargo build --release -j$(nproc)" 36 | 37 | $com $@ 38 | -------------------------------------------------------------------------------- /net/sshpeed: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # http://github.com/mitchweaver/bin 4 | # 5 | # sshpeed - test ssh transfer speed 6 | # 7 | # deps: pv (if your 'dd' doesn't have status=progress) 8 | # 9 | 10 | usage() { 11 | >&2 printf '%s\n' "Usage: $(basename $0) [-s size] [-p port] user@host" 12 | exit 1 13 | } 14 | 15 | while [ "$1" ] ; do 16 | case $1 in 17 | -h) usage ;; 18 | -p) port="-p $2" ; shift 2 ;; 19 | -s) size=$2 ; shift 2 ;; 20 | *) dest=$1 ; break 21 | esac 22 | done 23 | 24 | [ "$dest" ] || usage 25 | 26 | # Note: we use /dev/random over /dev/zero here as not to let 27 | # ssh's compression alter the true network transfer speed. 28 | dd if=/dev/urandom bs=$((1024 * 1024)) count=${size:-500} | \ 29 | pv -r -s ${size:-500}m -b | \ 30 | ssh "$dest" dd of=/dev/null status=none 31 | -------------------------------------------------------------------------------- /extract: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # extract - an all-purpose file archive extractor 4 | # from Manjaro Linux 5 | 6 | [ -z "${1}" ] && exit 1 7 | 8 | if [ -f $1 ] ; then 9 | case $1 in 10 | *.tar.xz) tar xvf $1 ;; 11 | *.tar.bz2) tar xjf $1 ;; 12 | *.tar.gz) tar xzf $1 ;; 13 | *.bz2) bunzip2 $1 ;; 14 | *.rar) unrar x $1 ;; 15 | *.gz) gunzip $1 ;; 16 | *.tar) tar xf $1 ;; 17 | *.tbz2) tar xjf $1 ;; 18 | *.tgz) tar xzf $1 ;; 19 | *.zip) unzip $1 ;; 20 | *.Z) uncompress $1 ;; 21 | *.7z) 7z x $1 ;; 22 | *) echo "'$1' cannot be extracted!" ;; 23 | esac 24 | else 25 | echo "'$1' does not exist" 26 | fi 27 | -------------------------------------------------------------------------------- /net/up: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # up - text/file upload 4 | # (c) Kiëd Llaentenn 5 | # See the COPYING for more information. 6 | 7 | usage() { 8 | echo "up - text/file upload 9 | (c) Kiëd Llaentenn 10 | 11 | USAGE: 12 | $ up [f|t|i|h] [args] 13 | 14 | OPTIONS: 15 | f [file] post file to 0x0.st 16 | t [file] post text from file to ix.io 17 | i post text from stdin to ix.io 18 | " 19 | } 20 | 21 | upload() { 22 | output=$(curl -s -F"file=@${1}" 0x0.st) 23 | qrencode -m 2 -s 2 -t ansiutf8 -o - "$output" 24 | printf '%s\n' "$output" 25 | } 26 | 27 | main() { 28 | case "$1" in 29 | f*) upload "$2" ;; # post file 30 | t*) cat "$2" | curl -F 'f:1=<-' ix.io ;; # post text from file 31 | i*) curl -iF 'f:1=<-' ix.io ;; # stdin 32 | *) usage ;; 33 | esac 34 | } 35 | 36 | main "$@" 37 | 38 | -------------------------------------------------------------------------------- /old/img: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # z3bra -- 2014-01-21 4 | 5 | test -z "$1" && exit 6 | 7 | W3MIMGDISPLAY="/usr/lib/w3m/w3mimgdisplay" 8 | FILENAME=$1 9 | FONTH=14 # Size of one terminal row 10 | FONTW=8 # Size of one terminal column 11 | COLUMNS=`tput cols` 12 | LINES=`tput lines` 13 | 14 | read width height <<< `echo -e "5;$FILENAME" | $W3MIMGDISPLAY` 15 | 16 | max_width=$(($FONTW * $COLUMNS)) 17 | max_height=$(($FONTH * $(($LINES - 2)))) # substract one line for prompt 18 | 19 | if test $width -gt $max_width; then 20 | height=$(($height * $max_width / $width)) 21 | width=$max_width 22 | fi 23 | if test $height -gt $max_height; then 24 | width=$(($width * $max_height / $height)) 25 | height=$max_height 26 | fi 27 | 28 | w3m_command="0;1;0;0;$width;$height;;;;;$FILENAME\n4;\n3;" 29 | 30 | tput cup $(($height/$FONTH)) 0 31 | echo -e $w3m_command|$W3MIMGDISPLAY 32 | -------------------------------------------------------------------------------- /timeleft: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # timeleft -- calculate time remaining on mpd playlist, not including finished songs 4 | # (c) Kiëd Llaentenn 5 | # See the COPYING file for copyright information. 6 | 7 | mpc playlist -f '%time%' | \ 8 | sed "1,$(($(mpc status | awk -F'[#/]' '/paused|playing/ { print $2 }')-1))d" | \ 9 | tr ':' ' ' | awk \ 10 | ' 11 | BEGIN { i = 0 } 12 | { i += $1 * 60 + $2 } 13 | END { 14 | if (int(i/3600) > 0) 15 | #print int(i/3600) "h " int((i%3600)/60) "m " int(i%60) "s" 16 | print int(i/3600) "h " int((i%3600)/60) "m" 17 | else if (int(i) > 0) 18 | #print int((i%3600)/60) "m " int(i%60) "s" 19 | print int((i%3600)/60) "m" 20 | else 21 | print "(empty)" 22 | } 23 | ' 24 | -------------------------------------------------------------------------------- /þ: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # þ - rune-ify text 4 | # 5 | # ᚻᛖ ᚳᚹᚫᚦ ᚦᚫᛏ ᚻᛖ ᛒᚢᛞᛖ ᚩᚾ ᚦᚫᛗ ᛚᚪᚾᛞᛖ ᚾᚩᚱᚦᚹᛖᚪᚱᛞᚢᛗ ᚹᛁᚦ ᚦᚪ ᚹᛖᛥᚫ 6 | # 7 | # (Old English, which transcribed into Latin reads 'He cwaeth that he 8 | # bude thaem lande northweardum with tha Westsae.' and means 'He said 9 | # that he lived in the northern land near the Western Sea.') 10 | # 11 | # (c) Kiëd Llaentenn 12 | # See the COPYING file for copyright information. 13 | # 14 | # NOTE: as far as I'm aware, there are no anglo-saxon runes 15 | # for k, q, v, x, and z. I simply substitute 'c' for 'k'. 16 | 17 | ALPH='abcdefghijklmnopqrstuvwxyz' 18 | RUNE='ᚪᛒᚳᛞᛖᚠᚷᚻᛁᛄᚳᛚᛗᚾᚩᛈ?ᚱᛋᛏᚢ?ᚹ?ᚣ?' 19 | 20 | D_TH='ᚦ' D_AE='ᚫ' D_NG='ᛝ' D_ST='ᛥ' 21 | 22 | tr '[[:upper:]]' '[[:lower:]]' \ 23 | | sed 's|x|ks|' \ 24 | | sed "s|th|$D_TH|" \ 25 | | sed "s|ae|$D_AE|" \ 26 | | sed "s|ng|$D_NG|" \ 27 | | sed "s|st|$D_ST|" \ 28 | | sed "y|$ALPH|$RUNE|" 29 | -------------------------------------------------------------------------------- /font: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # font - list and preview fonts 4 | # (c) Kied Llaentenn (@kiedtl) 5 | # See the COPYING for more information. 6 | 7 | output=${1} 8 | 9 | preview_text=$(echo " 10 | A B C D E F G H I J K L M 11 | N O P Q R S T U V W X Y Z 12 | 13 | 1 2 3 4 5 6 7 8 9 0 14 | 15 | a b c d e f g h i j k l m 16 | n o p q r s t u v w x y z 17 | 18 | () [] {} <> ? / \\ : \" ' ; 19 | ! @ # $ % ^ & * _ = + - | 20 | \` ~") 21 | 22 | [ -z "${output}" ] && { 23 | echo "${preview_text}"; 24 | exit 25 | } 26 | 27 | font=$(convert -list font | awk -F: '/^[ ]*Font: /{print substr($NF,2)}' | fzf) 28 | 29 | convert -size 532x365 xc:"#ffffff" \ 30 | -gravity center \ 31 | -pointsize 38 \ 32 | -font "${font}" \ 33 | -fill "#000000" \ 34 | -annotate +0+0 \ 35 | "${preview_text}" \ 36 | -flatten "${output}" 37 | 38 | feh "${output}" 39 | -------------------------------------------------------------------------------- /fetches/dylanaraps: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | (read -r _ _ k _ | shell: ${SHELL:-/bin/sh} 6 |  / __ \\ pkgs: $# 7 |  ( / \\ /| uptime:${u:-0m} 8 | _/\\ __)/_) memory: ${z:-?}MB / ${y:-?}MB 9 | \/-____\/ kernel: ${k:-linux} 10 | ") 2>/dev/null 11 | -------------------------------------------------------------------------------- /fetches/kiedtl-fetch1: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # fetch - rsfetch wrapper 4 | # (c) Kiëd Llaentenn 5 | 6 | # color escapes 7 | BLK="$(printf "\033[30m")" 8 | RED="$(printf "\033[31m")" 9 | GRN="$(printf "\033[32m")" 10 | YLW="$(printf "\033[33m")" 11 | BLU="$(printf "\033[34m")" 12 | PUR="$(printf "\033[35m")" 13 | CYN="$(printf "\033[36m")" 14 | WHT="$(printf "\033[37m")" 15 | RST="$(printf "\033[0m")" 16 | 17 | # build the color bars 18 | BAR="━━━━" 19 | LEN=6 20 | OUTT="$RED$BAR$GRN$BAR$YLW$BAR$BLU$BAR$PUR$BAR$CYN$BAR$RST" 21 | 22 | data= 23 | 24 | while IFS="\n" read -r info; do 25 | data="${data} $info" 26 | done </dev/null 2>&1 ; then 31 | pkgs=$(kiss l | wc -l) 32 | fi 33 | 34 | set -- ${data} 35 | 36 | echo " 37 | ${OUTT} 38 | ${BLU}os ${RST}KISS 39 | ${BLU}editor ${RST}neovim 40 | ${BLU}packages ${RST}${pkgs} 41 | ${BLU}shell ${RST}Z Shell 42 | ${OUTT} 43 | " 44 | -------------------------------------------------------------------------------- /x11/rwal: -------------------------------------------------------------------------------- 1 | #!/bin/sh -e 2 | # 3 | # http://github.com/mitchweaver/bin 4 | # 5 | # grab a pape from unsplash and rice it 6 | # 7 | # with no search terms provided, it is random 8 | # 9 | 10 | dir=/tmp/pape 11 | file=$dir/$$-pape.png 12 | mkdir -p $dir 13 | 14 | usage() { >&2 echo 'Usage: pape [-s] [-r] ' ; exit 1 ; } 15 | 16 | while [ "$1" ] ; do 17 | case $1 in 18 | -r) 19 | rice=true 20 | shift 21 | ;; 22 | -s) 23 | cp -fv $dir/last_pape.jpg ~/${file##*/} 24 | exit 25 | ;; 26 | -h) 27 | usage 28 | ;; 29 | *) 30 | url=http://source.unsplash.com/2400x1600/?$(echo $@ | tr ' ' ',') 31 | break 32 | esac 33 | done 34 | 35 | curl -L -# -C - -o $file --url ${url:-http://source.unsplash.com/random/2400x1600} 36 | convert $file ${file%png}jpg 37 | rm $file 38 | file=${file%png}jpg 39 | echo "$file" 40 | feh "$file" 41 | 42 | -------------------------------------------------------------------------------- /net/hosts: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # http://github.com/mitchweaver/bin 4 | # 5 | # update /etc/hosts, blocking ads+malware+fakenews+gambling+social 6 | # for more info see: http://github.com/StevenBlack/hosts 7 | # 8 | 9 | # if not running as root, restart script 10 | if [ $(id -u) -ne 0 ] ; then 11 | if type doas > /dev/null ; then 12 | doas $0 "$@" 13 | else 14 | sudo -E $0 "$@" 15 | fi 16 | exit $? 17 | fi 18 | 19 | curl -# -L http://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/fakenews-gambling-social/hosts > /tmp/hosts 20 | if [ $? -eq 0 ] ; then 21 | 22 | # don't kill my reddit >:( 23 | sed -E 's/.*.redd(\.)?(it)?.*.//g' /tmp/hosts > /tmp/hosts.tmp 24 | echo '0.0.0.0 ads.reddit.com' >> /tmp/hosts.tmp 25 | echo '0.0.0.0 alb.reddit.com' >> /tmp/hosts.tmp 26 | for amazon_sucks in `seq 8` ; do 27 | echo "0.0.0.0 reddit-image.s${amazon_sucks}.amazonaws.com" 28 | done >> /tmp/hosts.tmp 29 | 30 | mv -f /tmp/hosts.tmp /tmp/hosts 31 | mv -f /tmp/hosts /etc/hosts 32 | 33 | fi 34 | -------------------------------------------------------------------------------- /srv/check-battery: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # check-battery - Check battery levels and hibernate or warn user (via herbe) 4 | # (c) Kiëd Llaentenn 5 | # See the COPYING file for copyright information. 6 | 7 | make_notif_once() { 8 | mkdir -p /tmp/check_battery/ 9 | cachename=/tmp/check_battery/$1-$(date +%H) 10 | [ -f $cachename ] && return 11 | touch $cachename 12 | herbe "$2" 13 | } 14 | 15 | acpi -b | grep -v unavailable | awk -F'[,:%]' '{print $2, $3}' | { 16 | read -r status capacity 17 | 18 | if [ "$status" = Discharging -a "$capacity" -lt 2 ]; then 19 | herbe "Critical battery level (2%), hibernating. Zzz..." 20 | sudo ZZZ 21 | herbe "...yawn" 22 | elif [ "$status" = Discharging -a "$capacity" -lt 3 ]; then 23 | make_notif_once 3 "Critical battery level (<3%)." 24 | elif [ "$status" = Discharging -a "$capacity" -lt 5 ]; then 25 | make_notif_once 5 "Battery low (<5%)." 26 | elif [ "$status" = Discharging -a "$capacity" -lt 10 ]; then 27 | make_notif_once 10 "Battery low (<10%)." 28 | fi 29 | } 30 | -------------------------------------------------------------------------------- /lib/std: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # std - some nice shell functions to make my short 4 | # life just a little bit easier 5 | # 6 | # (c) Kiëd Llaentenn 7 | # See the COPYING file for copyright information. 8 | 9 | # credits: Dylan Araps 10 | # https://github.com/kisslinux/kiss 11 | # 12 | # usage: log 13 | # log 14 | # log 15 | log() ( 16 | if tty -s; then 17 | lcol='\033[1;33m' 18 | lcol2='\033[1;36m' 19 | lclr='\033[m' 20 | 21 | printf '%b%s %b%s%b %s\n' \ 22 | "$lcol" "${3:-->}" "${lclr}${2:+$lcol2}" \ 23 | "$1" "$lclr" "$2" >&2 24 | else 25 | printf '%s: %s%s%s %s\n' "${3:-$0}" \ 26 | "${2:+[}" "$1" "${2:+]}" "$2" 27 | fi 28 | ) 29 | 30 | # usage: die [text] 31 | # die [ ] 32 | die() { 33 | log "$1" "$2" "ERROR" 34 | exit 1 35 | } 36 | 37 | # usage: pause [text] 38 | # pause [ ] 39 | pause() { 40 | [ -z "$1" ] || log "$1" "$2" 41 | log "Press Enter to continue or Ctrl+C to abort here" 42 | read -r _ 43 | } 44 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019-2020 Kiëd Llaentenn 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /blks: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Daniel Crisman's ANSI color chart script from 4 | # The Bash Prompt HOWTO: 6.1. Colours 5 | # http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/x329.html 6 | # 7 | # This function echoes a bunch of color codes to the 8 | # terminal to demonstrate what's available. Each 9 | # line is the color code of one forground color, 10 | # out of 17 (default + 16 escapes), followed by a 11 | # test use of that color on all nine background 12 | # colors (default + 8 escapes). 13 | 14 | T='•••' # The text for the color test 15 | 16 | echo -e "\n def 40m 41m 42m 43m 44m 45m 46m 47m"; 17 | 18 | for FGs in ' m' ' 1m' ' 30m' '1;30m' ' 31m' '1;31m' ' 32m' \ 19 | '1;32m' ' 33m' '1;33m' ' 34m' '1;34m' ' 35m' '1;35m' \ 20 | ' 36m' '1;36m' ' 37m' '1;37m'; 21 | 22 | do FG=${FGs// /} 23 | echo -en " $FGs \033[$FG $T " 24 | 25 | for BG in 40m 41m 42m 43m 44m 45m 46m 47m; 26 | do echo -en "$EINS \033[$FG\033[$BG $T \033[0m"; 27 | done 28 | echo; 29 | done 30 | echo 31 | -------------------------------------------------------------------------------- /x11/ndmen: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # ndmen: dmenu wrapper with better defaults 4 | # usage: ndmen [INPUT] [SHELL] [W] [H] [X] [Y] 5 | # INPUT default: dmenu_path 6 | # SHELL default: /bin/sh 7 | # example: 8 | # ndmen 'cat /etc/some_file' /bin/cat 9 | # 10 | # (c) Kied Llaentenn 11 | # see the COPYING file for more info. 12 | 13 | . ~/.cache/wal/colors.sh 14 | 15 | set -- $(res '$width $height') "$@" 16 | 17 | w=$(echo "scale=0; $1 / 2.20" | bc) 18 | x=$(( $1 / 2 - $w / 2 )) 19 | y=$(( $2 / 10 )) 20 | h=$(( $2 / 80 )) 21 | shift 2 22 | 23 | p="$1" 24 | [ -z "$p" ] && p="dmenu_path" 25 | 26 | [ -z "$2" ] && s="${SHELL:-"/bin/sh"}" \ 27 | || s="cat" 28 | 29 | if [ ! -z "$WAYLAND_DISPLAY" ]; then 30 | exec ${p} | wmenu \ 31 | -N "$color0" -n "$color15" -M "$color15" -m "$color0" \ 32 | -S "$color1" -s "$color0" \ 33 | -p "${NDMEN_PROMPT:-→}" -f 'cursed 16' \ 34 | | "${s}" 35 | else 36 | exec ${p} | dmenu \ 37 | -nb "$color0" -nf "$color15" -sb "$color15" -sf "$color0" \ 38 | -p "$NDMEN_PROMPT" -fn 'cursed:size=16' -l "${h:-4}" \ 39 | -x "${x:-5}" -shf "$color8" -shb "$color15" -nhb "$color8" \ 40 | -nhf "$color15" -y "${y:-0}" -wi "${w:-3}" -F | "${s}" 41 | fi 42 | -------------------------------------------------------------------------------- /missing: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # http://github.com/mitchweaver/bin 4 | # 5 | # verifies if I have all my common programs installed 6 | # 7 | 8 | missing=0 9 | 10 | chk() { 11 | for i ; do 12 | type $i 2>/dev/null >&2 || { 13 | >&2 printf ' * %s\n' $i; 14 | missing="$((missing+1))" 15 | } 16 | done 17 | } 18 | 19 | printf 'missing:\n' 20 | 21 | # basic 22 | chk awk sed grep pgrep file less 23 | 24 | # rust utils 25 | chk exa fd rg tokei hyperfine ncdu 26 | 27 | # c programming 28 | chk gcc make git gdb scdoc patch 29 | 30 | # other languages 31 | chk bash mksh cargo zig 32 | 33 | # music 34 | chk mpd cantata bluetuith 35 | 36 | # xorg 37 | if command -v X 2>/dev/null >&2 38 | then 39 | chk startx xsel xmodmap xdotool xsetroot \ 40 | xrdb xprop 41 | 42 | # xorg programs 43 | chk feh i3 i3lock-fancy alacritty dmenu slock polybar \ 44 | zathura firefox thunar 45 | 46 | # ricing 47 | chk wal paleta 48 | fi 49 | 50 | # programs 51 | chk weechat convert nvim 52 | 53 | # networking 54 | chk ssh wpa_supplicant curl wget 55 | 56 | # monitoring 57 | chk pv htop 58 | 59 | # misc 60 | # (res is fetchutils) 61 | chk xz bzip2 gzip unzip jq gfe chmap res 62 | 63 | printf '%s not found\n' "$missing" 64 | -------------------------------------------------------------------------------- /shtat: -------------------------------------------------------------------------------- 1 | #!/bin/mksh 2 | # 3 | # shtat - primitive shell history statistics 4 | # NOTE: must be sourced to work. 5 | # 6 | # (c) Kiëd Llaentenn 7 | # See the COPYING file for copyright information. 8 | 9 | shtat() { 10 | history 0 | \ 11 | awk \ 12 | '{ 13 | commands[$2]+=1 14 | total+=1 15 | } 16 | 17 | END { 18 | for (command in commands) { 19 | percentage=(commands[command]*100)/total 20 | printf "%s,%s%%,%s\n", commands[command], percentage, command 21 | } 22 | }' | \ 23 | while IFS=, read -r count perc cmd; do 24 | [ "$cmd" = "while" ] && continue 25 | [ "$cmd" = "for" ] && continue 26 | [ "$cmd" = "if" ] && continue 27 | [ "$cmd" = "command" ] && continue 28 | [ "$cmd" = "exit" ] && continue 29 | [ "$cmd" = "." ] && continue 30 | 31 | command -v -- "$cmd" 2>/dev/null >&2 || continue 32 | 33 | grep -q / <<< "$cmd" && cmd="$(command -v -- "$cmd")" 34 | printf '%-5s %13s %s\n' "$count" "$perc" "$cmd" 35 | done | \ 36 | sort -bnr | \ 37 | nl | \ 38 | head -n "${1:-8}" 39 | } 40 | -------------------------------------------------------------------------------- /x11/mkc: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # mkc - create wal colorscheme 4 | # (c) Kiëd Llaentenn 5 | # See the COPYING file for copyright information. 6 | 7 | case "$1" in 8 | p*) 9 | paleta ~/etc/colors/peaceful 10 | 16 11 | 12 | colors= 13 | for i in 0 1 2 3 4 5 6 7 14 | do 15 | colors="$colors $(colorpicker -qod)" 16 | done 17 | 18 | echo $colors $colors 19 | ;; 20 | w*) 21 | shift 22 | cat < 6 | # See the COPYING file for copyright information. 7 | 8 | . ~/.cache/wal/colors.sh 9 | wall="$(swww query | tr : '\n' | tail -n1)" 10 | 11 | swaylock \ 12 | --show-failed-attempts --ignore-empty-password --indicator-caps-lock \ 13 | --hide-keyboard-layout --indicator-idle-visible \ 14 | --indicator-radius 128 \ 15 | --bs-hl-color "$color1" \ 16 | --caps-lock-key-hl-color "$color3" \ 17 | --inside-color "$color8" \ 18 | --inside-clear-color "$color7" \ 19 | --inside-ver-color "$color4" \ 20 | --inside-wrong-color "$color1" \ 21 | --key-hl-color "$color2" \ 22 | --layout-bg-color "$color7" \ 23 | --layout-border-color "$color15" \ 24 | --layout-text-color "$color15" \ 25 | --line-color "$color15" \ 26 | --ring-color "$color8" \ 27 | --ring-clear-color "$color5" \ 28 | --ring-caps-lock-color "$color3" \ 29 | --ring-ver-color "$color4" \ 30 | --text-color "$color7" \ 31 | --text-clear-color "$color7" \ 32 | --text-caps-lock-color "$color3" \ 33 | --text-ver-color "$color4" \ 34 | --text-wrong-color "$color1" \ 35 | --separator-color "$color7" \ 36 | --image "$wall" --font 'IBM Plex Mono' --font-size 16 37 | -------------------------------------------------------------------------------- /lib/esc: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # esc - emit VTE escape sequences 4 | # (c) Kiëd Llaentenn 5 | # See the COPYING file for copyright information. 6 | 7 | # this is a good reference, in my experience: 8 | # https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences 9 | 10 | . $(which std) 11 | 12 | [ -z "$1" ] && die "need argument" 13 | 14 | case "$1" in 15 | # Cursor {Up, Down, Forward, Backward} 16 | "CUU") printf '\033[%dA' "${2:-1}" ;; 17 | "CUD") printf '\033[%dB' "${2:-1}" ;; 18 | "CUF") printf '\033[%dC' "${2:-1}" ;; 19 | "CUB") printf '\033[%dD' "${2:-1}" ;; 20 | 21 | # Cursor {Next, Previous} Line 22 | # moves cursor X lines down or up 23 | "CNL") printf '\033[%dE' "${2:-1}" ;; 24 | "CPL") printf '\033[%dF' "${2:-1}" ;; 25 | 26 | # Cursor Horizontal Absolute Cursor, and 27 | # Vertical Line Position Absolute Cursor 28 | # 29 | # move cursor to the nth position horizonally/vertically 30 | "CHA") printf '\033[%dG' "${2:-1}" ;; 31 | "VPA") printf '\033[%dG' "${2:-1}" ;; 32 | 33 | # CUP: x y (Cursor position) 34 | # move cursor to X column of Y line 35 | # TODO: HVP: horizonal vertical position 36 | "CUP") printf '\033[%d;%dH' "${2:?need Y}" "${3:?need X}" ;; 37 | 38 | # DECSC/DECRC: save/restore cursor 39 | "DECSC") printf '\033[s' ;; 40 | "DECRC") printf '\033[u' ;; 41 | esac 42 | -------------------------------------------------------------------------------- /todo: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # todo - simple LIFO-based TODO tracker 4 | # (c) Kiëd Llaentenn 5 | # See the COPYING file for copyright information. 6 | 7 | TODOFILE="${TODOFILE:-$HOME/.cache/todo/todos}" 8 | 9 | # set default no. of TODOs to output 10 | [ -z "$1" ] && set -- 1 11 | 12 | case "$1" in 13 | # print TODOs 14 | [0-9]*) 15 | head -n"$1" "$TODOFILE" 16 | ;; 17 | 18 | # new TODO 19 | [Nn]*) 20 | shift 21 | echo "$@" >> "$TODOFILE" 22 | ;; 23 | 24 | # remove TODO 25 | [Rr]*) 26 | printf '%s' \ 27 | "$(tail -n+2 "$TODOFILE")" \ 28 | > "$TODOFILE" 29 | ;; 30 | 31 | # count TODOs 32 | [Cc]*) 33 | wc -l < "$TODOFILE" 34 | ;; 35 | 36 | # fix TODO file (merge multiple blank lines) 37 | [Ff]*) 38 | cat "$TODOFILE" | squeeze > "$TODOFILE" 39 | ;; 40 | 41 | [Ee]*) 42 | "${VISUAL:-${EDITOR:-vi}}" "$TODOFILE" 43 | ;; 44 | 45 | [Hh]*) 46 | printf 'todo [action]\n' 47 | printf 'actions:\n' 48 | printf ' [0-9] print todos\n' 49 | printf ' new new todo\n' 50 | printf ' rm remove todo\n' 51 | printf ' count count todos\n' 52 | printf ' fix fix todos\n' 53 | printf ' edit edit todo file\n' 54 | ;; 55 | 56 | *) 57 | printf '%s: %s: unknown command\n' \ 58 | "$0" "$1" >&2 59 | esac 60 | -------------------------------------------------------------------------------- /x11/wifimen: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # wifimen - wifi menu with dmenu 4 | # (c) Kiëd Llaentenn 5 | # See the COPYING file for copyright information. 6 | 7 | . $(which std) 8 | INTERFACE=$(interface) 9 | 10 | get_ssid_list() { 11 | sudo wpa_cli list_networks | tr '\t' ':' | cut -d: -f2,4 | \ 12 | grep -Ev '(network id)|(Selected)' | \ 13 | sed -e 's/\[CURRENT]/*/;s/\[DISABLED]//;s/\[TEMP-DISABLED]/!/;s/://g' 14 | } 15 | 16 | choose_ssid() { 17 | get_ssid_list | ndmen 'cat -' 'cat' | cut -f1 -d' ' 18 | } 19 | 20 | pgrep wpa_supplicant >/dev/null || ( 21 | sudo d sv restart wpa_supplicant || ( 22 | herbe "wifimen: could not start wpa_supplicant" 23 | exit 1 24 | ) 25 | ) 26 | 27 | pgrep dhcpcd >/dev/null || ( 28 | sudo d sv restart dhcpcd || ( 29 | herbe "wifimen: could not start dhcpcd" 30 | exit 1 31 | ) 32 | ) 33 | 34 | option_a="select" 35 | 36 | option_b="" 37 | if [ $(cat "/sys/class/net/${INTERFACE}/operstate") = "up" ] 38 | then 39 | option_b="reassociate" 40 | fi 41 | 42 | option_c="" 43 | if [ $(cat "/sys/class/net/${INTERFACE}/operstate") = "up" ] 44 | then 45 | option_c="disconnect" 46 | fi 47 | 48 | chosen=$(echo "$option_a\n$option_b\n$option_c" | ndmen 'cat -' 'cat' || exit 1) 49 | case "$chosen" in 50 | select) sudo wpa_cli select_network $(choose_ssid || exit 1) ;; 51 | disconnect) sudo wpa_cli disconnect ;; 52 | reconnect) sudo wpi_cli reconnect ;; 53 | reassociate) sudo wpi_cli reassociate ;; 54 | esac 55 | -------------------------------------------------------------------------------- /zn: -------------------------------------------------------------------------------- 1 | #!/bin/mksh 2 | # 3 | # zn -- create a new note 4 | # Usage: just type 'zn' 5 | # 6 | # (c) Kiëd Llaentenn 7 | # See the COPYING file for copyright information. 8 | 9 | DIR=$HOME/doc/zet/ 10 | 11 | . $(which std) 12 | export FZF_DEFAULT_OPTS="--color pointer:red --color bg+:bright-black" 13 | 14 | printf 'Title: ' 15 | title= 16 | read -r title 17 | 18 | id=$(printf '%s' "$title" | \ 19 | tr -d "\"'.,!:;+=@#$%&*\`~\\/()[]{}|" | \ 20 | tr '[:upper:]' '[:lower:]' | \ 21 | sed 's/ /-/g' | \ 22 | head -c32) 23 | fname="${id}.md" 24 | path="$DIR/$fname" 25 | [ -f "$path" ] && die "$fname already exists" 26 | printf "Creating '%s'\n" "$fname" 27 | 28 | tags=$() 29 | 30 | tags= 31 | while : 32 | do 33 | prompt="Tags: " 34 | [ -z "$tags" ] || prompt="Tags (${tags/ /}): " 35 | 36 | taglist="$(rg -I '[\^ ]#[a-z]+' $HOME/doc/zet/ | tr ' ' '\n' | tr -d '#' | sort -u)" 37 | fzfout="$(fzf --bind=enter:replace-query+print-query --reverse --prompt="$prompt" <<< "$taglist")" 38 | [ $? = 130 ] && break 39 | tags="$tags #$(tr -d '\n' <<< "$fzfout")" 40 | done 41 | 42 | tags="${tags/ /}" # remove leading space 43 | printf "Tags: %s\n" "$tags" 44 | 45 | touch "$path" 46 | printf "%s\n" "$title" >> "$path" 47 | printf "%s\n" "$title" | sed 's/./=/g' >> "$path" 48 | printf "\n" >> "$path" 49 | date "+%B %d, %Y" >> "$path" 50 | printf "\n" >> "$path" 51 | printf "%s\n" "$tags" >> "$path" 52 | printf "\n" >> "$path" 53 | 54 | ed "$path" 55 | -------------------------------------------------------------------------------- /fetches/kfetch: -------------------------------------------------------------------------------- 1 | #!/bin/dash 2 | # 3 | # kfetch - tiny system info for linux. 4 | # (c) Kied Llaentenn 5 | # see the LICENSE for more information 6 | 7 | export LC_ALL=C;. /etc/os-release;k=`uname -r`;s=`cat /proc/uptime`;s=${s%%.*};d=$((s/86400));h=$((s/3600%24));m=$((s/60%60));[ $d = 0 ]||u="${u}${d}d ";[ $h = 0 ]||u="${u}${h}h ";[ $m = 0 ]||u="${u}${m}m";while IFS=: read -r a b;do b=${b%kB};case $a in MemTotal)x=$((x+=b));t=$((t=b));;Shmem)x=$((x+=b));;MemFree|Buffers|Cached|SReclaimable)x=$((x-=b));;esac;done | uptime $u 61 | / __ \ editor ${EDITOR:-?} 62 | ( / \ /| shell ${SHELL##*/} 63 | _/\ __)/_) memory ${x}MiB / ${t}MiB 64 | \/-____\/ kernel $k 65 | " 66 | 67 | # EOF 68 | -------------------------------------------------------------------------------- /old/mandel: -------------------------------------------------------------------------------- 1 | #!/bin/csi -s 2 | #! 3 | #! mandel -- display mandelbrot sets. 4 | #! mostly stolen from Rosetta Code 5 | #! and Stack Overflow 8-) 6 | 7 | (import (chicken process-context)) 8 | (define (mklist b e) 9 | (cond ((= b e) (list b)) 10 | (else (cons b (mklist ((if (< b e) + -) b 1) e))))) 11 | 12 | (define (mandel x-size) 13 | (define y-size (floor (/ x-size 2.80952))) 14 | (define min-im -1) 15 | (define max-im 1) 16 | (define min-re -2) 17 | (define max-re 1) 18 | 19 | (define step-x (/ (- max-re min-re) x-size)) 20 | (define step-y (/ (- max-im min-im) y-size)) 21 | 22 | (for-each (lambda (y) 23 | (let ((im (+ min-im (* step-y y)))) 24 | (for-each (lambda (x) 25 | (let*((re (+ min-re (* step-x x))) 26 | (zr (exact->inexact re)) 27 | (zi (exact->inexact im))) 28 | (let loop ((n 0) (zi zi) (zr zr)) 29 | (let ((a (* zr zr)) 30 | (b (* zi zi))) 31 | (cond 32 | ((> (+ a b) 4) 33 | (display (integer->char (- 62 n)))) 34 | ((= n 30) 35 | (display (integer->char (- 62 n)))) 36 | (else 37 | (loop (+ n 1) (+ (* 2 zr zi) im) (- (+ a re) b)))))))) 38 | (mklist 0 x-size)) 39 | (print))) 40 | (mklist 0 y-size))) 41 | 42 | (cond 43 | ((null? (command-line-arguments)) 44 | (mandel 80)) 45 | (else 46 | (mandel (string->number 47 | (car (command-line-arguments)))))) 48 | -------------------------------------------------------------------------------- /old/lbar: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # lbar: the unholy lemonbar 4 | # credits: u/z-brah 5 | 6 | read -r width height < 5 | # See the COPYING file for copyright information. 6 | 7 | if [ -z "$1" ]; then 8 | # pick a random palette 9 | #colors=(~/etc/colors/palettes/*) 10 | #picked="${colors[$((RANDOM%${#colors[@]}))]}" 11 | n=$(ls ~/etc/colors/palettes/ | ndmen 'cat -' cat) 12 | set -- "$n" 13 | fi 14 | 15 | picked="$HOME/etc/colors/palettes/$1" 16 | [ -f "$picked" ] || { 17 | printf 'invalid colorscheme: "%s"\n' "$1" 18 | exit 1; 19 | } 20 | 21 | palette=($(cat $picked | tr '\n' ' ' | tr -d '#')) 22 | 23 | printf 'using %s\n' "$(basename $picked)" 24 | 25 | # set the palette and color 26 | wallpaper= 27 | if [ "${palette[19]}" ]; then 28 | wallpaper="/home/kiedtl/img/wallpapers/${palette[19]}" 29 | feh --bg-fill "${wallpaper}" & 30 | else 31 | hsetroot -solid "#${palette[1]}" & 32 | fi 33 | 34 | paleta <<< "$(tr ' ' '\n' <<< "${palette[@]}" | head -n19)" & 35 | 36 | echo " 37 | { 38 | \"wallpaper\": \"${wallpaper}\", 39 | \"alpha\": \"100\", 40 | \"special\": { 41 | \"background\": \"#${palette[1]}\", 42 | \"foreground\": \"#${palette[0]}\", 43 | \"cursor\": \"#${palette[2]}\" 44 | }, 45 | \"colors\": { 46 | \"color0\": \"#${palette[3]}\", 47 | \"color1\": \"#${palette[4]}\", 48 | \"color2\": \"#${palette[5]}\", 49 | \"color3\": \"#${palette[6]}\", 50 | \"color4\": \"#${palette[7]}\", 51 | \"color5\": \"#${palette[8]}\", 52 | \"color6\": \"#${palette[9]}\", 53 | \"color7\": \"#${palette[10]}\", 54 | \"color8\": \"#${palette[11]}\", 55 | \"color9\": \"#${palette[12]}\", 56 | \"color10\": \"#${palette[13]}\", 57 | \"color11\": \"#${palette[14]}\", 58 | \"color12\": \"#${palette[15]}\", 59 | \"color13\": \"#${palette[16]}\", 60 | \"color14\": \"#${palette[17]}\", 61 | \"color15\": \"#${palette[18]}\" 62 | } 63 | } 64 | " > /tmp/$$-the-wal-theme.json 65 | wal -qnst --theme /tmp/$$-the-wal-theme.json 66 | xr 67 | pkill -9 polybar # somehow the bottom bar stays alive w/o -9 68 | polybar -r top & 69 | polybar -r bottom & 70 | -------------------------------------------------------------------------------- /x11/rcmen: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # rcmen: menu when right click 4 | # from r/unixporn: "[dwm] plan 9 feel" by u/_viz_ 5 | # edited by kiedtl: 6 | # - changed hacksaw to crud 7 | # - BPX/BCOL make static 8 | # - add clear function 9 | # - changed crud to xrectsel 10 | # NOTE: requires bash due to use of arrays. 11 | 12 | . ~/.cache/wal/colors.sh 13 | 14 | reshape() { 15 | sleep 0.2 16 | id=$(xdotool selectwindow) 17 | #eval $(crud) 18 | read -r W H X Y <<< $(xrectsel '%w %h %x %y') 19 | 20 | xdotool windowsize ${id} ${W} ${H} 21 | xdotool windowmove ${id} ${X} ${Y} 22 | } 23 | 24 | move() { 25 | sleep 0.2 26 | id=$(xdotool selectwindow) 27 | read -r _id oX oY oW oH <<< $(xdotool getwindowgeometry $id | \ 28 | awk '{ print $2 }' | tr '\n,x' ' ') 29 | xdotool mousemove -w $id $((oW/2)) $((oH/2)) 30 | read -r X Y _ _ <<< $(xrectmov $oX $oY $oW $oH) 31 | 32 | xdotool windowmove ${id} ${X} ${Y} 33 | } 34 | 35 | new() { 36 | #fw=12 # width of term font 37 | #fh=21 # height of term font 38 | #ib=16 # size of term inner border 39 | #ob=3 # size of term windows WM border 40 | 41 | sleep 0.2 42 | read -r W H X Y <<< $(xrectsel '%w %h %x %y') 43 | #w=$(( ( W - (ib + ob)*2 ) / fw )) 44 | #h=$(( ( H - (ib + ob)*2 ) / fh )) 45 | 46 | #[ "$W" ] && st -g "${w}x${h}+${X}+${Y}" 47 | [ "$W" ] || exit 0 48 | 49 | # damn you alacritty, why not just accept a -geometry option 50 | # (and no, "-o window.position..." doesn't work, I've tried. 51 | alacritty \ 52 | -o "window.position.x = ${X}" \ 53 | -o "window.position.y = ${Y}" & 54 | sleep 0.2 55 | read -r _ pid _ <<< $(jobs -l | grep alacritty) 56 | windowid=$(xdotool search --pid $pid) 57 | sleep 0.2 58 | xdotool windowsize $windowid $W $H 59 | } 60 | 61 | delete() { 62 | sleep 0.2 63 | id=$(xdotool selectwindow) 64 | xdotool windowclose ${id} 65 | } 66 | 67 | spawn() { 68 | #eval $(xdotool getmouselocation --shell) 69 | #9menu -geometry 10x10+24+47 -popup -warp \ 70 | #-bg "$color0" -fg "$color15" \ 71 | #'new: echo new' 'delete: echo delete' 'move: echo move' 'resize: echo resize' 72 | ndmen 'echo -e new\nmove\nreshape\ndelete' 'cat' 73 | } 74 | 75 | $(spawn) 76 | exit 77 | -------------------------------------------------------------------------------- /x11/thew: -------------------------------------------------------------------------------- 1 | #!/bin/mksh 2 | # 3 | # thew - simple themes (wayland edition) 4 | # (c) Kiëd Llaentenn 5 | # See the COPYING file for copyright information. 6 | 7 | if [ -z "$1" ]; then 8 | # pick a random palette 9 | #colors=(~/etc/colors/palettes/*) 10 | #picked="${colors[$((RANDOM%${#colors[@]}))]}" 11 | n=$(ls ~/etc/colors/palettes/ | ndmen 'cat -' cat) 12 | set -- "$n" 13 | fi 14 | 15 | picked="$HOME/etc/colors/palettes/$1" 16 | [ -f "$picked" ] || { 17 | printf 'invalid colorscheme: "%s"\n' "$1" 18 | exit 1; 19 | } 20 | 21 | palette=($(cat $picked | tr '\n' ' ' | tr -d '#')) 22 | 23 | printf 'using %s\n' "$(basename $picked)" 24 | 25 | # Get outputs for swww 26 | # (I'm sure there's a better way, lol.) 27 | outputs="$(niri msg outputs | grep 'Output' | sed 's/^.*(\(.*\))/\1/' | tr '\n' ',')" 28 | 29 | # set the palette and color 30 | wallpaper= 31 | if [ "${palette[19]}" ]; then 32 | wallpaper="/home/kiedtl/img/wallpapers/${palette[19]}" 33 | swww img "${wallpaper}" -o "$outputs" & 34 | else 35 | swww clear "#${palette[1]}" -o "$outputs" & 36 | fi 37 | 38 | paleta <<< "$(tr ' ' '\n' <<< "${palette[@]}" | head -n19)" & 39 | 40 | echo " 41 | { 42 | \"wallpaper\": \"${wallpaper}\", 43 | \"alpha\": \"100\", 44 | \"special\": { 45 | \"background\": \"#${palette[1]}\", 46 | \"foreground\": \"#${palette[0]}\", 47 | \"cursor\": \"#${palette[2]}\" 48 | }, 49 | \"colors\": { 50 | \"color0\": \"#${palette[3]}\", 51 | \"color1\": \"#${palette[4]}\", 52 | \"color2\": \"#${palette[5]}\", 53 | \"color3\": \"#${palette[6]}\", 54 | \"color4\": \"#${palette[7]}\", 55 | \"color5\": \"#${palette[8]}\", 56 | \"color6\": \"#${palette[9]}\", 57 | \"color7\": \"#${palette[10]}\", 58 | \"color8\": \"#${palette[11]}\", 59 | \"color9\": \"#${palette[12]}\", 60 | \"color10\": \"#${palette[13]}\", 61 | \"color11\": \"#${palette[14]}\", 62 | \"color12\": \"#${palette[15]}\", 63 | \"color13\": \"#${palette[16]}\", 64 | \"color14\": \"#${palette[17]}\", 65 | \"color15\": \"#${palette[18]}\" 66 | } 67 | } 68 | " > /tmp/$$-the-wal-theme.json 69 | wal -qnst --theme /tmp/$$-the-wal-theme.json 70 | 71 | #pkill waybar 72 | #waybar & 73 | 74 | # Now, babysit niri 75 | 76 | IFS="=" 77 | grep -E 'color..?=' < ~/.cache/wal/colors.sh | \ 78 | tr -d "'" | \ 79 | while read color value; do 80 | sed \ 81 | -E "s/\"[^\"]+\"(.*@$color)\$/\"$value\"\\1/" \ 82 | -i ~/etc/niri/config.kdl 83 | done 84 | -------------------------------------------------------------------------------- /lib/tumbler_oauth_helper.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import urllib.parse as urlparse 3 | import oauth2 as oauth 4 | import urllib 5 | 6 | consumer_key = sys.argv[1] 7 | consumer_secret = sys.argv[2] 8 | 9 | request_token_url = 'https://www.tumblr.com/oauth/request_token' 10 | access_token_url = 'https://www.tumblr.com/oauth/access_token' 11 | authorize_url = 'https://www.tumblr.com/oauth/authorize' 12 | 13 | consumer = oauth.Consumer(consumer_key, consumer_secret) 14 | client = oauth.Client(consumer) 15 | 16 | # Step 1: Get a request token. This is a temporary token that is used for 17 | # having the user authorize an access token and to sign the request to obtain 18 | # said access token. 19 | 20 | resp, content = client.request(request_token_url, "POST", 21 | body=urlparse.urlencode({ 22 | "oauth_consumer_key": consumer_key, 23 | "oauth_callback_confirmed": "true", 24 | }) 25 | ) 26 | if resp['status'] != '200': 27 | raise Exception("Invalid response %s: %s" % (resp['status'], content)) 28 | 29 | request_token = dict(urlparse.parse_qsl(content)) 30 | 31 | print("Request Token:") 32 | print(" - oauth_token = %s" % request_token[b'oauth_token']) 33 | print(" - oauth_token_secret = %s\n" % request_token[b'oauth_token_secret']) 34 | 35 | # Step 2: Redirect to the provider. Since this is a CLI script we do not 36 | # redirect. In a web application you would redirect the user to the URL 37 | # below. 38 | 39 | print("Go to the following link in your browser:") 40 | print("%s?%s\n" % (authorize_url, urlparse.urlencode({ 41 | "oauth_token": request_token[b'oauth_token'], 42 | "oauth_callback": 'http://localhost/doctorstrange' 43 | }))) 44 | 45 | # After the user has granted access to you, the consumer, the provider will 46 | # redirect you to whatever URL you have told them to redirect to. You can 47 | # usually define this in the oauth_callback argument as well. 48 | accepted = 'n' 49 | while accepted.lower() == 'n': 50 | accepted = input('Have you authorized me? (y/n) ') 51 | oauth_verifier = input('What is the OAuth Verifier? ') 52 | 53 | # Step 3: Once the consumer has redirected the user back to the oauth_callback 54 | # URL you can request the access token the user has approved. You use the 55 | # request token to sign this request. After this is done you throw away the 56 | # request token and use the access token returned. You should store this 57 | # access token somewhere safe, like a database, for future use. 58 | token = oauth.Token( 59 | request_token[b'oauth_token'], request_token[b'oauth_token_secret'] 60 | ) 61 | token.set_verifier(oauth_verifier) 62 | client = oauth.Client(consumer, token) 63 | 64 | resp, content = client.request(access_token_url, "POST") 65 | access_token = dict(urlparse.parse_qsl(content)) 66 | 67 | print("Raw content:") 68 | print(content) 69 | print("") 70 | 71 | print("Access Token:") 72 | print(" - oauth_token = %s" % access_token[b'oauth_token']) 73 | print(" - oauth_token_secret = %s" % access_token[b'oauth_token_secret']) 74 | print("") 75 | print("You may now access protected resources using the access tokens above.\n") 76 | 77 | -------------------------------------------------------------------------------- /archive-image: -------------------------------------------------------------------------------- 1 | #!/bin/mksh 2 | # 3 | # vim: filetype=bash 4 | # 5 | # archive-image: archive a tumblr (and soon, reddit/unsplash/twitter) image post 6 | # 7 | # (c) Kiëd Llaentenn 8 | # See the COPYING file for copyright information. 9 | 10 | setexif() { 11 | blog=$1 12 | content_text=$2 13 | content_surl=$3 14 | content_tags=$4 15 | archive_date=$5 16 | filename=$6 17 | echo $filename 18 | 19 | # This needs to be UCS2 encoded... 20 | #exiftool -XPTitle="$content_summary" $filename 21 | #exiftool -XPAuthor=$blog $filename 22 | #exiftool -XPKeywords="$content_tags" $filename 23 | 24 | exiftool -Artist=$blog $filename 25 | exiftool -ImageDescription="$content_text" $filename 26 | exiftool -ImageSourceData="$content_surl" $filename 27 | exiftool -UserComment="$content_tags" $filename 28 | exiftool -DateTime="$archive_date" $filename 29 | } 30 | 31 | set -e 32 | . $(which std) 33 | 34 | T_HELPER=$HOME/bin/lib/tumbler_helper.py 35 | ARCHIVE_DIR=$HOME/arc/art/ 36 | 37 | if [ "$1" = "" ] 38 | then 39 | die "usage: $0 " 40 | fi 41 | 42 | url=$1 43 | 44 | if grep -q 'tumblr' <<< "$url" 45 | then 46 | IFS='/' read _ blog id <<< $(grep -oEi 'tumblr\.com/[a-zA-Z0-9_\-]+/[0-9]+' <<< "$url") 47 | printf 'Archiving %d from %s\n' "$id" "$blog" 48 | 49 | consumer_key="AFVyAQ9OS7urVp57OtpufMcQJK3pGlV4NcslhXORnK5kBzvt2F" 50 | consumer_key_secret="BzPIqaZJAzcjlrMIbkWMjPtCecedFLAhDU7j9XGrabgz8Y2bXv" 51 | read oauth oauth_secret < $HOME/.ssh/tumblr.secrets 52 | 53 | response=$(python3 $T_HELPER $consumer_key $consumer_key_secret $oauth $oauth_secret $blog $id) 54 | 55 | content_image=$(printf '%s' "$response" | \ 56 | jq '.content | .[] | .media | .[0] | select(.url != null) | .url' | \ 57 | tr -d '"' | tr '\n' ' ') 58 | content_text=$(printf '%s' "$response" | \ 59 | jq '.content | .[] | .text | select(. != null)' | \ 60 | tr -d '"') 61 | content_slug=$(printf '%s' "$response" | jq '.slug' | tr -d '"') 62 | content_surl=$(printf '%s' "$response" | jq '.short_url' | tr -d '"') 63 | content_summ=$(printf '%s' "$response" | jq '.summary' | tr -d '"') 64 | content_tags=$(printf '%s' "$response" | jq '.tags | .[]' | tr -d '"' | tr '\n' ' ') 65 | 66 | read -r main_tag_guess _ <<< "$content_tags" 67 | 68 | filelist="" 69 | ext="png" 70 | ctr=0 71 | for i in $content_image 72 | do 73 | rm -f /tmp/archive-image-tmp-file 74 | wget $i -O /tmp/archive-image-tmp-file 75 | IPA=" ," read -r _ ext <<< $(file --extension /tmp/archive-image-tmp-file) 76 | ctr=$((ctr+1)) 77 | filename="/tmp/tumblr-$id-${ctr}.${ext}" 78 | filelist="$filelist ${filename}" 79 | mv /tmp/archive-image-tmp-file $filename 80 | done 81 | 82 | if [ "$ext" == "gif" ] && [ "$ctr" -gt 1 ] 83 | then 84 | ctr2=0 85 | for i in $filelist 86 | do 87 | setexif "$blog" "$content_text" "$content_surl" "$content_tags" "$(date +%Y-%m-%d)" $i 88 | mv $i "${ARCHIVE_DIR}/${content_slug}-${ctr2}.${ext}" 89 | ctr2=$((ctr2+1)) 90 | done 91 | else 92 | filename=/tmp/tumblr-$id-combined.${ext} 93 | rm -f $filename 94 | if [ $ctr -gt 1 ] 95 | then 96 | convert -append $filelist $filename 97 | else 98 | mv $filelist $filename 99 | fi 100 | rm -f $filelist 101 | 102 | setexif "$blog" "$content_text" "$content_surl" "$content_tags" "$(date +%Y-%m-%d)" $filename 103 | mv $filename "${ARCHIVE_DIR}/${content_slug}.${ext}" 104 | fi 105 | elif grep -q 'reddit' <<< "$url" 106 | then 107 | die "Reddit archival unimplemented" 108 | fi 109 | -------------------------------------------------------------------------------- /fetches/mitchweaver: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # http://github.com/mitchweaver 4 | # 5 | # yet another fetch script 6 | # 7 | 8 | # shellcheck disable=2030,2034 9 | space() { 10 | df -h | \ 11 | while read -r drive size used _ perc mountpoint _ ; do 12 | # only print line if drive is a physical device 13 | case ${drive##*/} in 14 | sd*|nvme*) 15 | case $mountpoint in 16 | */boot|*/efi) 17 | # ignore 18 | ;; 19 | *) 20 | printf "│ ^%s/%s^│\n" "$used" "$size" #"$perc" 21 | esac 22 | esac 23 | done 24 | } 25 | 26 | # idea to get terminal font 27 | # get_font() { 28 | # font=$(strings <$(which st) | grep 'pixelsize=') 29 | # printf '%s\n' "${font%%:*}" 30 | # } 31 | 32 | # Get memory information by parsing /proc/meminfo. 33 | # Idea from pfetch, (dylan) 34 | # 35 | # Formula: MemUsed = MemTotal + Shmem - MemFree - Buffers - Cached - SReclaimable 36 | # Source: https://github.com/KittyKatt/screenFetch/issues/386 37 | # 38 | # Only works on Linux. 39 | # 40 | # shellcheck disable=2031 41 | mem() { 42 | # Parse the '/proc/meminfo' file splitting on ':' and 'k'. 43 | # The format of the file is 'key: 000kB' and an additional 44 | # split is used on 'k' to filter out 'kB'. 45 | while IFS=':k ' read -r key val _ ; do 46 | case $key in 47 | MemTotal|Shmem) 48 | total=$((total + val)) 49 | used=$((used + val)) 50 | ;; 51 | MemFree|Buffers|Cached|SReclaimable) 52 | used=$((used - val)) 53 | esac 54 | done /dev/null ; then os=CRUX 77 | elif command -v xbps-query >/dev/null ; then os=Void 78 | elif command -v apt-get >/dev/null ; then os=Debian ; fi 79 | printf '%s %s\n' "$os" "$(uname -r)" 80 | } 81 | 82 | pr_line() { 83 | buf=$1 84 | # SC: "i is unused" 85 | # shellcheck disable=2034 86 | for i in r i c i n g $(seq "$3") ; do 87 | buf="$buf─" 88 | done 89 | printf '%s\n' "$buf$2" 90 | } 91 | 92 | pr_host() { 93 | read -r h ") 137 | print("") 138 | print("static const uint8_t font_data[] = {"); 139 | 140 | for i = 0,127 do 141 | io.stdout:write("\t") 142 | local glyph = font.data[i] or font.data[32] 143 | 144 | -- Some bdf files leave out prefixed 0x00's. This won't 145 | -- work for us, so fill it in. 146 | for gi = 1,(font.height - #glyph) do 147 | io.stdout:write("0x00, ") 148 | end 149 | 150 | for gi = 1,#glyph do 151 | local item = glyph[gi] 152 | local data = string.format("0x%02X", item) 153 | io.stdout:write(data) 154 | io.stdout:write(", ") 155 | end 156 | 157 | local charname = "'" .. utf8.char(i) .. "'" 158 | if unprintable_names[i] then charname = unprintable_names[i] end 159 | print("// " .. charname) 160 | end 161 | 162 | print("};") 163 | print("") 164 | print("#endif") 165 | --------------------------------------------------------------------------------