├── Makefile
├── README.md
├── install.sh
└── scripts
├── bat
├── bri
├── ccc
├── cky
├── clo
├── clr
├── cpy
├── dmn
├── drt
├── dts
├── grs
├── hnt
├── irc
├── kbd
├── loc
├── logfeed
├── med
├── mks
├── mon
├── mrk
├── omg
├── pac
├── popterm
├── puh
├── rnm
├── scl
├── scr
├── shw
├── sqh
├── stx
├── tdo
├── tin
├── ttt
├── vol
├── wpp
├── xep
└── ytd
/Makefile:
--------------------------------------------------------------------------------
1 | PREFIX ?= $(HOME)
2 |
3 | .SILENT:
4 |
5 | all:
6 | @echo Run \'make install\' to install scripts.
7 |
8 | install:
9 | ./install.sh "install"
10 |
11 | uninstall:
12 | ./install.sh "uninstall"
13 |
14 | diff:
15 | ./install.sh "diff"
16 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
fehawen's :wastebasket: scripts n' stuff
2 |
--------------------------------------------------------------------------------
/install.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #
4 | # install.sh
5 | #
6 |
7 | i() {
8 | mkdir -p "$prefix/$dest"
9 |
10 | for file in "$src"/*; do
11 | cp -v "$file" "$prefix/$dest/"
12 | done
13 | }
14 |
15 | u() {
16 | [ -d "$prefix/$dest" ] || exit 1
17 |
18 | for file in "$src"/*; do
19 | rm -v "$prefix/$dest/${file##*/}"
20 | done
21 | }
22 |
23 | d() {
24 | [ -d "$prefix/$dest" ] || exit 1
25 |
26 | for file in "$src"/*; do
27 | printf '\033[1;37mDiff:\033[m %s\n' "${file##*/}"
28 | diff "$file" "$prefix/$dest/${file##*/}" && {
29 | printf 'No difference.\n'
30 | }
31 |
32 | printf '\n'
33 | done
34 | }
35 |
36 | main() {
37 | prefix=$HOME
38 | src=scripts
39 | dest=bin
40 |
41 | case $1 in
42 | install) i ;;
43 | uninstall) u ;;
44 | diff) d ;;
45 | esac
46 | }
47 |
48 | main "$@"
49 |
--------------------------------------------------------------------------------
/scripts/bat:
--------------------------------------------------------------------------------
1 | #!/bin/sh -e
2 |
3 | #
4 | # bat - get battery capacity and status.
5 | # author: https://github.com/dylanaraps
6 | #
7 |
8 | bat_dir=/sys/class/power_supply/BAT0
9 |
10 | read -r capacity < "$bat_dir/capacity"
11 | read -r status < "$bat_dir/status"
12 |
13 | printf '%s%% (%s)\n' "$capacity" "$status"
14 |
--------------------------------------------------------------------------------
/scripts/bri:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #
4 | # bri - brightness control
5 | #
6 |
7 | command -v xbacklight >/dev/null || {
8 | printf '%s: %s\n' "${0##*/}" "Please install 'xbacklight'."
9 | exit 1
10 | }
11 |
12 | if [ -z "$1" ]; then
13 | xbacklight -get
14 | elif [ "$1" -gt 100 ]; then
15 | xbacklight -set 100
16 | elif [ "$1" -lt 5 ]; then
17 | xbacklight -set 5
18 | else
19 | xbacklight -set "$1"
20 | fi
21 |
--------------------------------------------------------------------------------
/scripts/ccc:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #
4 | # ccc
5 | #
6 |
7 | printf '\n'
8 |
9 | for i in 0 1 2 3 4 5 6 7; do
10 | printf '\033[10%sm \033[m ' "$i"
11 | done
12 |
13 | printf '\n\n'
14 |
--------------------------------------------------------------------------------
/scripts/cky:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #
4 | # cky - conky
5 | #
6 |
7 | # shellcheck disable=SC1090
8 | [ -f ~/.cache/rpg/colors.sh ] && . ~/.cache/rpg/colors.sh
9 |
10 | killall -q conky
11 |
12 | printf '%s' "$(cat << CONF
13 | conky.config = {
14 | alignment = 'top_left',
15 | background = true,
16 | default_color = '${color7:=#FFFFFF}',
17 | color1 = '${color1:=#FFFFFF}',
18 | color2 = '${color2:=#FFFFFF}',
19 | color3 = '${color3:=#FFFFFF}',
20 | color4 = '${color4:=#FFFFFF}',
21 | color5 = '${color5:=#FFFFFF}',
22 | color6 = '${color6:=#FFFFFF}',
23 | double_buffer = true,
24 | font = 'Cyberpunks:pixelsize=50:style=regular',
25 | font1 = 'Cyberpunks:pixelsize=160:style=regular',
26 | font2 = 'IcoFont:pixelsize=65:style=regular',
27 | font3 = 'Cyberpunks:pixelsize=60:style=italic',
28 | draw_shades = false,
29 | draw_outline = false,
30 | draw_borders = false,
31 | gap_x = 90,
32 | gap_y = 70,
33 | out_to_console = false,
34 | out_to_ncurses = false,
35 | out_to_stderr = false,
36 | out_to_x = true,
37 | own_window = false,
38 | own_window_type = 'override',
39 | own_window_title = 'conky',
40 | own_window_class = 'Conky',
41 | own_window_transparent = true,
42 | own_window_argb_visual = true,
43 | own_window_argb_value = 0,
44 | update_interval = 20,
45 | use_xft = true,
46 | uppercase = false,
47 | }
48 |
49 | conky.text = [[
50 | \${color3}\${font1}\${time %H:%M}\${font3}
51 | \${color2}\${time %A %d %B}
52 |
53 | \${color3}\${voffset 7}\${font2}\${color}\${voffset -7}\${font} \${swap} / \${swapmax}
54 | \${color4}\${voffset 7}\${font2}\${color}\${voffset -7}\${font} \${mem} / \${memmax}
55 | \${color6}\${voffset 7}\${font2}\${color}\${voffset -7}\${font} \${fs_used /} / \${fs_size /}
56 | \${color5}\${voffset 7}\${font2}\${color}\${voffset -7}\${font} \${wireless_essid wlp2s0}
57 | \${color1}\${voffset 7}\${font2}\${color}\${voffset -7}\${font} \${battery}
58 |
59 | ]];
60 | CONF
61 | )" > ~/.conkyrc
62 |
63 | while pgrep -x conky > /dev/null; do (:;:); done
64 |
65 | conky -c ~/.conkyrc -d
66 |
--------------------------------------------------------------------------------
/scripts/clo:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #
4 | # clo - clone github repo, so lazy
5 | #
6 |
7 | [ $# -lt 2 ] && {
8 | printf '%s\n' "Usage: clo [username] [repository] ssh (optional)"
9 | exit 1
10 | }
11 |
12 | if [ "$3" = "ssh" ]; then
13 | src="git@github.com:$1/$2.git"
14 | else
15 | src="https://github.com/$1/$2.git"
16 | fi
17 |
18 | git clone "$src"
19 |
--------------------------------------------------------------------------------
/scripts/clr:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #
4 | # clr
5 | #
6 |
7 | for i in 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15; do
8 | printf '\033[48;5;%sm \033[m' "$i"
9 |
10 | [ "$i" = 7 ] && printf '\n'
11 | done
12 |
13 | printf '\n\n'
14 |
--------------------------------------------------------------------------------
/scripts/cpy:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #
4 | # cpy
5 | #
6 |
7 | [ "$1" ] || exit 1
8 |
9 | [ -f "$1" ] || {
10 | printf 'Not a file: %s\n' "$1"
11 | exit 1
12 | }
13 |
14 | xclip -selection clipboard < "$1"
15 |
--------------------------------------------------------------------------------
/scripts/dmn:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | dmenu_run -i \
4 | -nb "#babbbd" \
5 | -nf "#24292e" \
6 | -sb "#24292e" \
7 | -sf "#babbbd" \
8 | -fn "SFMono-15"
9 |
--------------------------------------------------------------------------------
/scripts/drt:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #
4 | # drt - dirty repo teller
5 | #
6 |
7 | log() {
8 | printf '%s: %s\n' "$1" "${2##*/}"
9 | }
10 |
11 | main() {
12 | [ -z "$DRT_PATH" ] && {
13 | printf '%s\n' "DRT_PATH is not set."
14 | exit
15 | }
16 |
17 | set -f
18 |
19 | IFS=':'
20 |
21 | # shellcheck disable=2086
22 | set -- $DRT_PATH
23 |
24 | for dir in "$@"; do
25 | (
26 | [ -d "$dir" ] || {
27 | log "Not a directory" "$dir"
28 | }
29 |
30 | cd "$dir" 2> /dev/null || {
31 | log "Failed to change directory to" "$dir"
32 | exit
33 | }
34 |
35 | command git rev-parse --is-inside-work-tree 1>/dev/null 2>/dev/null || {
36 | log "Not a git directory" "$dir"
37 | exit
38 | }
39 |
40 | [ -z "$(git status --short 2> /dev/null)" ] || log "dirty" "$dir"
41 | )
42 | done
43 |
44 | set +f
45 | }
46 |
47 | main
48 |
--------------------------------------------------------------------------------
/scripts/dts:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #
4 | # dts - date timestamp
5 | #
6 |
7 | [ "$1" ] || {
8 | printf '%s\n' "usage: dts [yyyy-mm-dd], dts [yyyy-mm-dd hh:mm:ss]"
9 | exit 1
10 | }
11 |
12 | date --date="$1" +"%s"
13 |
--------------------------------------------------------------------------------
/scripts/grs:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #
4 | # grs - git(hub) remote swap
5 | #
6 |
7 | [ "$1" ] || {
8 | printf 'GitHub username required.\n'
9 | exit 1
10 | }
11 |
12 | command git rev-parse --is-inside-work-tree 1>/dev/null 2>/dev/null || {
13 | printf 'Not a git directory.\n'
14 | exit 1
15 | }
16 |
17 | git_user="$1"
18 | git_root="$(git rev-parse --show-toplevel)"
19 | remote_repo="${2:-${git_root##*/}}"
20 | ssh_url="git@github.com:${git_user}/${remote_repo}.git"
21 | https_url="https://github.com/${git_user}/${remote_repo}.git"
22 |
23 | if command git remote get-url --all origin | grep -q "$https_url"; then
24 | remote_url="$ssh_url"
25 | else
26 | remote_url="$https_url"
27 | fi
28 |
29 | printf 'Change remote url to \033[1;39m%s\033[m ? [y/n]: ' "$remote_url"
30 |
31 | read -r answer
32 |
33 | case $answer in
34 | 'y'*|'Y'*) ;;
35 | *) printf 'Quitting...\n'; exit ;;
36 | esac
37 |
38 | command git remote set-url origin "$remote_url"
39 | command git remote -v
40 |
--------------------------------------------------------------------------------
/scripts/hnt:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #
4 | # hnt
5 | #
6 |
7 | [ "$1" ] || exit 1
8 |
9 | grep \
10 | --exclude-dir=node_modules \
11 | --exclude-dir=coverage \
12 | --exclude-dir=.fusebox \
13 | --exclude-dir=.next \
14 | --exclude-dir=dist \
15 | --exclude-dir=.git \
16 | -wroni "$1" . \
17 | | sort -u \
18 | | grep -iv "^$1" \
19 | | sed "/^$/d" \
20 | | grep -i --color=always "$1"
21 |
--------------------------------------------------------------------------------
/scripts/irc:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # Read logs from #kisslinux irc channel with colorized output.
4 | #
5 | # Usage: irc, irc -d [yyyymmdd], irc -s [search string]
6 |
7 | prin() {
8 | printf '%s \033[3%s;1m%10s\033[m %s\n' "$1" "$2" "${3:0:10}" "$4"
9 | }
10 |
11 | fetch() {
12 | search="${s:-""}"
13 | date="${d:-$(date +%Y%m%d)}"
14 |
15 | while read -r t u m; do
16 | u=${u%>}
17 | u=${u#<}
18 | t="${t%:*}"
19 |
20 | c="$((${#u} % 6 + 1))"
21 |
22 | o="$(printf %s "$m" | \
23 | fold -s -w $((${scrsize##* } - 11)) | \
24 | sed -e '2,$s|^| |g')"
25 |
26 | case $search in
27 | '')
28 | prin "$t" "$c" "$u" "$o"
29 | ;;
30 | *)
31 | if [[ "$m" =~ $search ]] || [[ "$u" =~ $search ]]; then
32 | prin "$t" "$c" "$u" "$o"
33 | fi
34 | ;;
35 | esac
36 | done <<< "$(curl -s "https://freenode.logbot.info/kisslinux/$date/raw")"
37 | }
38 |
39 | args() {
40 | while getopts :s:d: opt; do case $opt in
41 | \?)
42 | printf 'irc \n\n'
43 | printf -- '-s \n'
44 | printf -- '-d \n'
45 | printf -- '-h (help)\n'
46 | ;;
47 |
48 | :) printf 'Option -%s requires an argument\n' "$OPTARG" >&2 ;;
49 | *) declare -g "$opt=$OPTARG" ;;
50 | esac; [[ $opt =~ \?|: ]] && exit; done
51 | }
52 |
53 | main() {
54 | # shellcheck disable=SC2034
55 | read -r scrsize < <(stty size)
56 |
57 | args "$@"
58 | fetch
59 | }
60 |
61 | main "$@"
62 |
--------------------------------------------------------------------------------
/scripts/kbd:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #
4 | # kbd - 4x12 ortholinear keyboard layout
5 | #
6 |
7 | printf '%s\n' "
8 | DEFAULT
9 | ┌──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┐
10 | │ Esc │ Q │ W │ E │ R │ T │ Y │ U │ I │ O │ P │ Å │
11 | │ │ │ │ │ │ │ │ │ │ │ │ │
12 | ├──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
13 | │ Tab │ A │ S │ D │ F │ G │ H │ J │ K │ L │ Ö │ Ä │
14 | │ │ │ │ │ │ │ │ │ │ │ │ │
15 | ├──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
16 | │ Shift│ Z │ X │ C │ V │ B │ N │ M │ , │ . │ - │ Shift│
17 | │ │ │ │ │ │ │ │ │ │ │ │ │
18 | ├──────┼──────┼──────┼──────┼──────┼──────┴──────┼──────┼──────┼──────┼──────┼──────┤
19 | │ Ctrl │Layer4│ Alt │ GUI │Layer1│ Space │Layer2│Layer3│Alt Gr│ Caps │ Ctrl │
20 | │ │ │ │ │ │ │ │ │ │ │ │
21 | └──────┴──────┴──────┴──────┴──────┴─────────────┴──────┴──────┴──────┴──────┴──────┘
22 |
23 | LAYER 1
24 | ┌──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┐
25 | │Insert│ ! │ \" │ # │ ¤ │ % │ & │ / │ ( │ ) │ = │ ? │
26 | │ │ │ │ │ │ │ │ │ │ │ │ │
27 | ├──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
28 | │Delete│ Brows│ Page │ Page │ Brows│ Brows│ Left │ Down │ Up │ Right│ Home │ End │
29 | │ │ back │ down │ up │ forw │ refr │ │ │ │ │ │ │
30 | ├──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
31 | │ Shift│ [ │ ] │ { │ } │ │ │ │ │ │ │ Shift│
32 | │ │ │ │ │ │ │ │ │ │ │ │ │
33 | ├──────┼──────┼──────┼──────┼──────┼──────┴──────┼──────┼──────┼──────┼──────┼──────┤
34 | │ Ctrl │ │ Alt │ GUI │ ▒▒▒▒ │ Space │Bckspc│ Enter│Alt Gr│ Caps │ Ctrl │
35 | │ │ │ │ │ ▒▒▒▒ │ │ │ │ │ │ │
36 | └──────┴──────┴──────┴──────┴──────┴─────────────┴──────┴──────┴──────┴──────┴──────┘
37 |
38 | LAYER 2
39 | ┌──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┐
40 | │Insert│ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │ 0 │ + │
41 | │ │ │ │ │ │ │ │ │ │ │ │ │
42 | ├──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
43 | │Delete│ ' │ \" │ \` │ ´ │ ~ │ / │ \ │ │ │ ^ │ * │
44 | │ │ │ │ │ │ │ │ │ │ │ │ │
45 | ├──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
46 | │ Shift│ < │ > │ | │ │ │ │ │ │ │ │ Shift│
47 | │ │ │ │ │ │ │ │ │ │ │ │ │
48 | ├──────┼──────┼──────┼──────┼──────┼──────┴──────┼──────┼──────┼──────┼──────┼──────┤
49 | │ Ctrl │ │ Alt │ GUI │ │ Space │ ▒▒▒▒ │ │Alt Gr│ Caps │ Ctrl │
50 | │ │ │ │ │ │ │ ▒▒▒▒ │ │ │ │ │
51 | └──────┴──────┴──────┴──────┴──────┴─────────────┴──────┴──────┴──────┴──────┴──────┘
52 |
53 | LAYER 3
54 | ┌──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┐
55 | │Insert│ ¡ │ @ │ £ │ $ │ € │ ¥ │ { │ [ │ ] │ } │ \ │
56 | │ │ │ │ │ │ │ │ │ │ │ │ │
57 | ├──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
58 | │Delete│ │ │ € │ │ │ │ │ │ │ │ │
59 | │ │ │ │ │ │ │ │ │ │ │ │ │
60 | ├──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
61 | │ Shift│ │ │ │ │ │ │ │ │ │ │ Shift│
62 | │ │ │ │ │ │ │ │ │ │ │ │ │
63 | ├──────┼──────┼──────┼──────┼──────┼──────┴──────┼──────┼──────┼──────┼──────┼──────┤
64 | │ Ctrl │ │ Alt │ GUI │ │ Space │ │ ▒▒▒▒ │Alt Gr│ Caps │ Ctrl │
65 | │ │ │ │ │ │ │ │ ▒▒▒▒ │ │ │ │
66 | └──────┴──────┴──────┴──────┴──────┴─────────────┴──────┴──────┴──────┴──────┴──────┘
67 |
68 | LAYER 4
69 | ┌──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┐
70 | │ F1 │ F2 │ F3 │ F4 │ F5 │ F6 │ F7 │ F8 │ F9 │ F10 │ F11 │ F12 │
71 | │ │ │ │ │ │ │ │ │ │ │ │ │
72 | ├──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
73 | │ Tab │ RGB │ RGB │ RGB │ │ │ Mute │ Vol -│ Vol +│ Bri -│ Bri +│ │
74 | │ │ Togg │ Mod -│ Mod 0│ │ │ │ │ │ │ │ │
75 | ├──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
76 | │ Shift│ RGB │ RGB │ RGB │ RGB │ RGB │ RGB │ RGB │ RGB │AGnorm│AGswap│ Shift│
77 | │ │ Hue -│ Hue +│ Sat -│ Sat +│ Bri -│ Bri +│ Eff -│ Eff +│ │ │ │
78 | ├──────┼──────┼──────┼──────┼──────┼──────┴──────┼──────┼──────┼──────┼──────┼──────┤
79 | │ Ctrl │ ▒▒▒▒ │ Alt │ GUI │ │ Space │ │ │Alt Gr│ Caps │ Ctrl │
80 | │ │ ▒▒▒▒ │ │ │ │ │ │ │ │ │ │
81 | └──────┴──────┴──────┴──────┴──────┴─────────────┴──────┴──────┴──────┴──────┴──────┘
82 | "
83 |
--------------------------------------------------------------------------------
/scripts/loc:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #
4 | # loc - lines of code
5 | #
6 |
7 | [ -f "$1" ] || exit 1
8 |
9 | while IFS= read -r line || [ -n "$line" ]; do
10 | lines=$((lines+1))
11 | [ -z "$line" ] || {
12 | sloc=$((sloc+1))
13 | }
14 | done < "$1"
15 |
16 | printf '%s\n' "$lines lines ($sloc sloc)"
17 |
--------------------------------------------------------------------------------
/scripts/logfeed:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #
4 | # logfeed
5 | #
6 |
7 | i=0
8 |
9 | journalctl --merge --lines="${1:-20}" | while IFS=' ' read -r _ _ _ _ _ msg; do
10 | [ "$i" != 0 ] && {
11 | printf '\033[1;31m%s\033[m %s\n' "│" "$msg"
12 | }
13 |
14 | i=$((i+1))
15 | done
16 |
--------------------------------------------------------------------------------
/scripts/med:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #
4 | # med - play me some media
5 | #
6 |
7 | case $1 in
8 | a|audio)
9 | [ ! -s ~/.mpd/pid ] && mpd ~/.mpdrc
10 | exec ncmpcpp -c ~/.ncmpcpprc
11 | ;;
12 | v|video)
13 | exec mpv --geometry=1280x720 \
14 | --shuffle \
15 | --x11-name=no-title \
16 | -- ~/media/video/ 1>/dev/null 2>/dev/null &
17 | ;;
18 | *)
19 | printf 'Usage: med a|audio|v|video\n'
20 | exit
21 | ;;
22 | esac
23 |
--------------------------------------------------------------------------------
/scripts/mks:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | [ "$1" ] || {
4 | printf 'No name for new shell executable provided.\n'
5 | exit 1
6 | }
7 |
8 | [ -f "$1" ] && {
9 | printf 'File %s already exists.\n' "'$1'"
10 | exit 1
11 | }
12 |
13 | shebang='#!/bin/sh'
14 |
15 | [ "$2" = "bash" ] && {
16 | shebang='#!/usr/bin/env bash'
17 | }
18 |
19 | printf '%s\n\n#\n# %s\n#' "$shebang" "$1" > "$1"
20 | chmod +x "$1"
21 |
22 | [ -z "$EDITOR" ] && {
23 | printf 'Unable to open file %s, EDITOR not set.\n' "'$1'"
24 | exit
25 | }
26 |
27 | $EDITOR "$1"
28 |
--------------------------------------------------------------------------------
/scripts/mon:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #
4 | # mon - set output to external monitor(s)
5 | # usage: mon, mon [auto]
6 | #
7 |
8 | command -v xrandr >/dev/null || {
9 | printf 'err: command "xrandr" not found.\n'
10 | exit 1
11 | }
12 |
13 | [ "$1" = "auto" ] && {
14 | xrandr --auto
15 | exit 0
16 | }
17 |
18 | log() {
19 | printf 'Using display(s): %s\n' "$*"
20 | }
21 |
22 | dpy_a="$(xrandr | grep "primary" | awk '{print $1}')"
23 | dpy_b="$(xrandr | grep -w "connected" | awk '{if(NR>1)print $1}' | head -1)"
24 | dpy_c="$(xrandr | grep -w "connected" | awk '{if(NR>2)print $1}' | head -1)"
25 | dpy_d="$(xrandr | grep -w "connected" | awk '{if(NR>3)print $1}' | head -1)"
26 |
27 | if [ -n "$dpy_b" ] && [ -n "$dpy_c" ] && [ -n "$dpy_d" ]; then
28 | log "$dpy_b" "$dpy_c" "$dpy_d"
29 |
30 | xrandr \
31 | --output "$dpy_a" --off \
32 | --output "$dpy_b" --auto \
33 | --output "$dpy_c" --auto --right-of "$dpy_b" \
34 | --output "$dpy_d" --auto --right-of "$dpy_c"
35 | elif [ -n "$dpy_b" ] && [ -n "$dpy_c" ]; then
36 | log "$dpy_b" "$dpy_c"
37 |
38 | xrandr \
39 | --output "$dpy_a" --off \
40 | --output "$dpy_b" --auto \
41 | --output "$dpy_c" --auto --right-of "$dpy_b"
42 | elif [ -n "$dpy_b" ]; then
43 | log "$dpy_b"
44 |
45 | xrandr \
46 | --output "$dpy_a" --off \
47 | --output "$dpy_b" --auto
48 | else
49 | log "$dpy_a [internal/auto]"
50 | xrandr --auto
51 | fi
52 |
--------------------------------------------------------------------------------
/scripts/mrk:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #
4 | # mrk
5 | #
6 |
7 | [ "$1" ] || exit 1
8 |
9 | find . \
10 | -not -path "*node_modules*" \
11 | -not -path "*.fusebox*" \
12 | -not -path "*.next*" \
13 | -not -path "*dist*" \
14 | -not -path "*.git*" \
15 | -iname "*$1*" \
16 | | sort -u \
17 | | grep -i --color=always "$1"
18 |
--------------------------------------------------------------------------------
/scripts/omg:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #
4 | # omg - oh my god
5 | #
6 |
7 | log() {
8 | printf '%s\n' "$@"
9 | }
10 |
11 | lines() {
12 | files=$((files+1))
13 |
14 | while IFS= read -r line || [ -n "$line" ]; do
15 | loc=$((loc+1))
16 | [ -z "$line" ] || {
17 | sloc=$((sloc+1))
18 | }
19 | done < "$1"
20 | }
21 |
22 | iterate() {
23 | dirs=$((dirs+1))
24 |
25 | for item in "${1%%/}"/*; do
26 | [ -f "$item" ] && lines "$item"
27 | [ -d "$item" ] && iterate "$item"
28 | done
29 | }
30 |
31 | main() {
32 | [ -d "$1" ] || exit 1
33 |
34 | loc=0; sloc=0; dirs=0; files=0
35 |
36 | iterate "$1"
37 |
38 | log "$files files" \
39 | "$dirs directories" \
40 | "$loc lines ($sloc sloc)"
41 | }
42 |
43 | main "$@"
44 |
--------------------------------------------------------------------------------
/scripts/pac:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #
4 | # pac - get duration in days since last `pacman -Syu`
5 | #
6 |
7 | command -v pacman >/dev/null || {
8 | printf '%s: %s\n' "${0##*/}" "Please install 'pacman'."
9 | exit 1
10 | }
11 |
12 | last_update=$(grep Running\ \'pacman\ -Syu /var/log/pacman.log \
13 | | tail -1 \
14 | | awk '{print $1, $2}' \
15 | | sed 's/[][]//g' \
16 | | cut -dT -f1)
17 |
18 | update_timestamp=$(date -d "${last_update}" +%s)
19 | current_timestap=$(date +%s)
20 |
21 | difference=$((current_timestap - update_timestamp))
22 |
23 | duration=$(( difference / 86400 ))
24 |
25 | suffix="days"
26 | [ $duration = 1 ] && suffix="day"
27 |
28 | output="$duration $suffix ago"
29 |
30 | printf '%s\n' "$output"
31 |
--------------------------------------------------------------------------------
/scripts/popterm:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #
4 | # popterm - i3 popup terminal
5 | #
6 |
7 | w=$((($(xrandr --listmonitors | grep \+ | awk '{print $3}' | cut -d/ -f1) / 100) * 60))
8 | h=$((($(xrandr --listmonitors | grep \+ | awk '{print $3}' | cut -dx -f2 | cut -d/ -f1) / 100) * 60))
9 |
10 | if i3-msg -t get_tree | grep -q "popup"; then
11 | msg="[instance=\"popup\"] resize set $w $h;"
12 | msg="$msg [instance=\"popup\"] scratchpad show;"
13 | msg="$msg [instance=\"popup\"] move position center"
14 |
15 | i3-msg "$msg"
16 | else
17 | i3-msg "exec --no-startup-id xterm -name popup"
18 | sleep 1
19 | fi
20 |
--------------------------------------------------------------------------------
/scripts/puh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #
4 | # puh - push ur head
5 | #
6 |
7 | log() {
8 | printf '%s => %s: %s\n' "${0##*/}" "${1##*/}" "$2"
9 | }
10 |
11 | main() {
12 | [ -z "$DRT_PATH" ] && {
13 | printf '%s\n' "DRT_PATH is not set."
14 | exit
15 | }
16 |
17 | set -f
18 |
19 | IFS=':'
20 |
21 | # shellcheck disable=2086
22 | set -- $DRT_PATH
23 |
24 | for dir in "$@"; do
25 | (
26 | [ -d "$dir" ] || {
27 | log "$dir" "Not a directory."
28 | }
29 |
30 | cd "$dir" 2> /dev/null || {
31 | log "$dir" "Failed to cd to directory."
32 | exit
33 | }
34 |
35 | command git rev-parse --is-inside-work-tree 1>/dev/null 2>/dev/null || {
36 | log "$dir" "Not a git directory."
37 | exit
38 | }
39 |
40 | if command git status | grep "ahead" 1>/dev/null; then
41 | log "$dir" "Pushing..."
42 | git push
43 | else
44 | log "$dir" "Nothing to push."
45 | fi
46 | )
47 | done
48 |
49 | set +f
50 | }
51 |
52 | main
53 |
--------------------------------------------------------------------------------
/scripts/rnm:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #
4 | # rnm - rename all files in a dir
5 | #
6 | # example: rnm ~/wallpapers wall_
7 | # result: rename all files to wall_[index].[extension]
8 |
9 | [ -d "$1" ] || {
10 | printf 'Not a directory: %s\n' "$1"
11 | exit 1
12 | }
13 |
14 | [ "$2" ] || {
15 | printf 'Second arg for name required\n'
16 | exit 1
17 | }
18 |
19 | dir=$1
20 | new=$2
21 |
22 | (
23 | cd "$dir" > /dev/null || {
24 | printf 'Failed to change directory to: %s\n' "$1"
25 | exit 1
26 | }
27 |
28 | set +f
29 | set -f -- *
30 |
31 | for file in "$@"; do
32 | i=$((i+1))
33 | [ -f "$file" ] && mv -fv "$file" "${new}${i}.${file##*\.}"
34 | done
35 | )
36 |
--------------------------------------------------------------------------------
/scripts/scl:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | #
4 | # scl - change scaling (resolution) for external monitor(s).
5 | #
6 |
7 | command -v xrandr >/dev/null || {
8 | printf '%s: %s\n' "${0##*/}" "Please install 'xrandr'."
9 | exit 1
10 | }
11 |
12 | external_output="$(xrandr | grep -w "connected" | awk '{if(NR>1)print $1}')"
13 |
14 | if [[ -z "$external_output" ]]; then
15 | printf '%s\n' "No external monitors found."
16 | exit 1
17 | fi
18 |
19 | default_width="$(xrandr | grep "\*" | awk '{print $1}' | cut -dx -f1)"
20 | default_height="$(xrandr | grep "\*" | awk '{print $1}' | cut -dx -f2)"
21 |
22 | confirm() {
23 | echo -e "\nCALCULATED CONFIGURATION:\n${1}\n\n"
24 |
25 | read -r -p "Execute xrandr scaling? [y/N] " answer
26 | if [[ "$answer" != y ]] && [[ "$answer" != Y ]]; then
27 | echo "Scaling declined."
28 | echo "Exiting..."
29 | exit
30 | else
31 | echo "Executing..."
32 | $1
33 | echo "Done."
34 | fi
35 | }
36 |
37 | resolution() {
38 | if [[ "$1" == "default" ]]; then
39 | echo "${default_width}x${default_height}"
40 | else
41 | width="$((default_width * $1 / 10))"
42 | height="$((default_height * $1 / 10))"
43 |
44 | echo "${width}x${height}"
45 | fi
46 | }
47 |
48 | scale() {
49 | if [[ "$1" == "default" ]]; then
50 | config="xrandr --output ${external_output} --scale 1x1 --panning ${default_width}x${default_height}"
51 | confirm "${config}"
52 | else
53 | float="$(printf %.1f "${1}e-1")"
54 | scale="${float}x${float}"
55 |
56 | panning="$(resolution "${1}")"
57 |
58 | config="xrandr --output ${external_output} --scale ${scale} --panning $panning"
59 | confirm "${config}"
60 | fi
61 | }
62 |
63 | customize() {
64 | if [[ "$1" == "verbose" ]]; then
65 | echo -e "\nEnter scaling value to calculate configuration."
66 | echo "NOTE: Value must be at least 1, with no more than 1 decimal."
67 | echo -e "Type 'quit' to exit.\n"
68 | fi
69 |
70 | read -r -p "Value: " answer
71 | if [[ "$answer" == "quit" ]]; then
72 | echo "Exiting..."
73 | exit 0
74 | fi
75 |
76 | declare sanitized="${answer//[.,]/}"
77 |
78 | if [[ $sanitized == 0* ]]; then
79 | echo -e "\nERROR: Value must be at least 1"
80 | echo -e "Try again.\n"
81 | customize
82 | elif [[ ${#sanitized} -gt 2 ]]; then
83 | echo -e "\nERROR: Value can only have 1 decimal"
84 | echo -e "Try again.\n"
85 | customize
86 | else
87 | scale "$sanitized"
88 | fi
89 | }
90 |
91 | declare -a actions=(
92 | "default"
93 | 12
94 | 14
95 | 16
96 | )
97 |
98 | declare -a options=(
99 | "${external_output} at $(resolution "default") (default)"
100 | "${external_output} at $(resolution 12)"
101 | "${external_output} at $(resolution 14)"
102 | "${external_output} at $(resolution 16)"
103 | "Custom Value"
104 | "Quit"
105 | )
106 |
107 | COLUMNS=12
108 |
109 | PS3="Please select an option: "
110 |
111 | select OPT in "${options[@]}"
112 | do
113 | case $OPT in
114 | "Custom Value")
115 | customize "verbose"
116 | break
117 | ;;
118 | "Quit")
119 | echo "Exiting..."
120 | break
121 | ;;
122 | *)
123 | scale "${actions[$((REPLY - 1))]}"
124 | break
125 | ;;
126 | esac
127 | done
128 |
--------------------------------------------------------------------------------
/scripts/scr:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #
4 | # scr - screenshot
5 | #
6 |
7 | d="$(date +%Y%m%d)"
8 | t="$(date +%H%M%S)"
9 | s=~/pictures/screenshots
10 |
11 | mkdir -p "$s/$d"
12 |
13 | f="$s/$d/$d-$t.png"
14 |
15 | import -window root "$f"
16 |
--------------------------------------------------------------------------------
/scripts/shw:
--------------------------------------------------------------------------------
1 | #!/bin/sh -f
2 |
3 | #
4 | # shw - posix sh `wal` alternative
5 | #
6 | # Based on an old script by Dylan Araps:
7 | # https://raw.githubusercontent.com/dylanaraps/bin/cdaa7b58c917fd9d86d2d5bbb45cad0dcd783408/bud
8 | #
9 |
10 | die() {
11 | printf '%s\n' "$@"
12 | exit 1
13 | }
14 |
15 | exists() {
16 | command -v "$1" >/dev/null
17 | }
18 |
19 | is_img() {
20 | mime_type=$(file -bi "$1")
21 |
22 | case $mime_type in
23 | image/*) return 0 ;;
24 | *) return 1 ;;
25 | esac
26 | }
27 |
28 | random_img() {
29 | set +f
30 | set -f -- "$1/"*
31 |
32 | shift "$(($$ * PPID % $#))"
33 |
34 | while ! is_img "$1" && [ "$2" ]; do shift; done
35 |
36 | [ -f "${img:=$1}" ] || die "Failed to select a random img."
37 | }
38 |
39 | add_sequence() {
40 | seqs="$seqs]$1;$2\\";
41 |
42 | c=${1##*;}
43 |
44 | case $1 in
45 | *";"*)
46 | [ "${c}" -eq 0 ] && {
47 | printf '%s\n' \
48 | "*background: $2" \
49 | "*.background: $2" >> "$xresource_file"
50 | }
51 |
52 | [ "${c}" -eq 7 ] && {
53 | printf '%s\n' \
54 | "*foreground: $2" \
55 | "*.foreground: $2" \
56 | "*cursorColor: $2" \
57 | "*.cursorColor: $2" >> "$xresource_file"
58 | }
59 |
60 | [ "${c}" -lt 16 ] && {
61 | printf '%s\n' "color${c}=\"$2\"" >> "$colors_file"
62 |
63 | printf '%s\n' \
64 | "*color${c}: $2" \
65 | "*.color${c}: $2" >> "$xresource_file"
66 | }
67 | ;;
68 | esac
69 | }
70 |
71 | make_sequences() {
72 | for line in $palette; do
73 | color="${line:=#000000}"
74 |
75 | add_sequence "4;${i:=0}" "$color"
76 |
77 | [ "$i" = 0 ] && {
78 | # 11: Background color
79 | # 17: Highlight background Color
80 | # 257: Reversed cursor color
81 | # 258: Background color
82 | add_sequence "11" "$color"
83 | add_sequence "17" "$color"
84 | add_sequence "4;257" "$color"
85 | add_sequence "4;258" "$color"
86 |
87 | # Unless VTE
88 | # 708: Border color
89 | [ "$VTE_VERSION" ] || add_sequence "708" "$color"
90 | }
91 |
92 | [ "$i" = 15 ] && {
93 | # 10: Foreground color
94 | # 12: Cursor foreground color
95 | # 13: Mouse foreground color
96 | # 19: Highlight foreground Color
97 | # 256: Cursor color
98 | # 259: Foreground color
99 | add_sequence "10" "$color"
100 | add_sequence "12" "$color"
101 | add_sequence "13" "$color"
102 | add_sequence "19" "$color"
103 | add_sequence "4;256" "$color"
104 | add_sequence "4;259" "$color"
105 | }
106 |
107 | : $((i+=1))
108 | done
109 | }
110 |
111 | xrdb_merge() {
112 | exists "xrdb" && {
113 | [ -f "$xresource_file" ] && xrdb -merge "$xresource_file"
114 | }
115 | }
116 |
117 | print_current() {
118 | printf 'Using image: %s\n\n' "$img"
119 |
120 | for i in 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15; do
121 | printf '\033[48;5;%sm \033[m ' "$i"
122 |
123 | [ "$i" = 7 ] && printf '\n\n'
124 | done
125 |
126 | printf '\n\n'
127 |
128 | exit
129 | }
130 |
131 | activate_palette() {
132 | set +f
133 | set -f -- /dev/pts/[0-9]*
134 | for tty in "$@"; do
135 | [ -w "$tty" ] && printf %b "$seqs" > "$tty" &
136 | done
137 |
138 | printf %b "$seqs" > "$sequence_file"
139 |
140 | xrdb_merge
141 | }
142 |
143 | hex2rgb() {
144 | set -- "${1##\#}"
145 |
146 | r=${1%%????}
147 | g=${1##??}
148 | g=${g%%??}
149 | b=${1##????}
150 |
151 | r=$((0x$r))
152 | g=$((0x$g))
153 | b=$((0x$b))
154 | }
155 |
156 | mod() {
157 | hex2rgb "$2"
158 |
159 | # The operator is stored in a variable
160 | # which makes shellcheck freak out.
161 | # shellcheck disable=1102,2086
162 | {
163 | r=$((r $3 $4))
164 | g=$((g $3 $4))
165 | b=$((b $3 $4))
166 | }
167 |
168 | r=$((r > 255 ? 255 : r < 0 ? 0 : r))
169 | g=$((g > 255 ? 255 : g < 0 ? 0 : g))
170 | b=$((b > 255 ? 255 : b < 0 ? 0 : b))
171 |
172 | export "$1=$(printf '#%02x%02x%02x' "$r" "$g" "$b")"
173 | }
174 |
175 | convert_colors() {
176 | args="-alpha off -normalize -resize 64x64 -posterize 16"
177 | args="$args -modulate 125,175,100 -fill white -unique-colors"
178 |
179 | [ -z "$light" ] && args="$args -colorize 25%"
180 | [ -n "$light" ] && args="$args -colorize 15%"
181 |
182 | # shellcheck disable=2046,2086,2006
183 | set -- `\
184 | convert "$img" $args txt:- |
185 |
186 | while IFS='# ' read -r _ _ col _; do
187 | i=$((i+1))
188 |
189 | [ "$i" -lt 11 ] && continue
190 | [ "$i" -gt 16 ] && continue
191 |
192 | printf '%s\n' "#$col"
193 | done
194 | `
195 |
196 | # shellcheck disable=2154
197 |
198 | {
199 | mod bg "$2" "/" 8
200 | mod fg "$2" "+" 125
201 | mod co "$bg" "+" 35
202 |
203 | [ -n "$light" ] && {
204 | mod bg "$2" "*" 6
205 | mod fg "$2" "/" 4
206 | mod co "$bg" "-" 85
207 | }
208 |
209 | set -- "$bg" "$@" "$fg" "$co" "$@" "$fg"
210 | }
211 |
212 | palette=$*
213 | }
214 |
215 | set_wallpaper() {
216 | [ -f "$1" ] && {
217 | if exists "hsetroot"; then
218 | hsetroot -root -cover "$1" 1>/dev/null
219 | elif exists "feh"; then
220 | feh --bg-fill "$1"
221 | fi
222 | }
223 | }
224 |
225 | restore() {
226 | (cat "$sequence_file" 2>/dev/null &)
227 | exit
228 | }
229 |
230 | init() {
231 | # shellcheck disable=1090
232 | [ -f "$colors_file" ] && . "$colors_file"
233 |
234 | set_wallpaper "${wallpaper:=""}"
235 |
236 | xrdb_merge
237 |
238 | restore
239 | }
240 |
241 | run() {
242 | [ "$1" = "light" ] && light=1
243 |
244 | random_img "${SHW_LIB%%/}"
245 |
246 | :> "$xresource_file"
247 |
248 | printf '%s\n' "wallpaper=\"$img\"" > "$colors_file"
249 |
250 | convert_colors
251 |
252 | make_sequences
253 |
254 | activate_palette
255 |
256 | set_wallpaper "$img"
257 |
258 | print_current
259 | }
260 |
261 | main() {
262 | mkdir -p "${cache_dir:=$HOME/.cache/shw}"
263 | colors_file="$cache_dir/colors.sh"
264 | xresource_file="$cache_dir/colors.Xresources"
265 | sequence_file="$cache_dir/sequences"
266 |
267 | [ -n "$SHW_LIB" ] || die "SHW_LIB is not set."
268 | [ -d "$SHW_LIB" ] || die "$SHW_LIB is not a directory."
269 |
270 | case $1 in
271 | init) init ;;
272 | restore) restore ;;
273 | *) run "$1" ;;
274 | esac
275 | }
276 |
277 | main "$@"
278 |
--------------------------------------------------------------------------------
/scripts/sqh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #
4 | # sqh - reset current git branch, specifying [base] for merge-base branch
5 | # usage: sqh [base]
6 | #
7 |
8 | [ "$1" ] || exit 1
9 |
10 | branch="$(git rev-parse --abbrev-ref HEAD)"
11 |
12 | read -r "Reset branch '$branch' using merge-base branch '$1'? [y/N] " answer
13 |
14 | if [ "$answer" != "y" ]; then
15 | printf 'Declined...\nExiting.\n'
16 | exit 0
17 | else
18 | git reset "$(git merge-base "$1" "$branch")"
19 | fi
20 |
--------------------------------------------------------------------------------
/scripts/stx:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #
4 | # stx - startx
5 | #
6 |
7 | xinitrc() {
8 | xrdb ~/.Xresources &
9 |
10 | # shellcheck disable=SC1090
11 | [ -f ~/.cache/rpg/colors.sh ] && . ~/.cache/rpg/colors.sh
12 |
13 | xsetroot -solid "${color8:=#777777}"
14 |
15 | xset +fp ~/.fonts
16 | xset b off
17 | xset m 1/1
18 | setxkbmap -layout se &
19 |
20 | exec sowm
21 | }
22 |
23 | trap "DISPLAY=:0 xinitrc" USR1
24 |
25 | (
26 | trap '' USR1
27 |
28 | exec Xorg \
29 | -ardelay 200 \
30 | -arinterval 50 \
31 | -nolisten tcp \
32 | :0 vt1
33 | ) &
34 |
35 | wait
36 |
--------------------------------------------------------------------------------
/scripts/tdo:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #
4 | # tdo - todo helper
5 | #
6 |
7 | cd_or_exit() {
8 | cd "$TODO_DIR" || exit 1
9 | }
10 |
11 | todo_push() {
12 | (
13 | cd_or_exit
14 |
15 | git add .
16 | git commit -m "Bump @ $(date '+%Y/%m/%d %H:%M')"
17 | git push
18 | )
19 | }
20 |
21 | todo_pull() {
22 | (
23 | cd_or_exit
24 | git pull
25 | )
26 | }
27 |
28 | todo_read() {
29 | less "$todo_file"
30 | }
31 |
32 | todo_edit() {
33 | vim "$todo_file"
34 | }
35 |
36 | main() {
37 | case $1 in
38 | push) opt="push" ;;
39 | pull) opt="pull" ;;
40 | read) opt="read" ;;
41 | edit) opt="edit" ;;
42 | esac
43 |
44 | [ -z "$opt" ] && {
45 | printf "Usage: tdo push|pull|read|edit\n"
46 | exit
47 | }
48 |
49 | [ -z "$TODO_DIR" ] && {
50 | printf "TODO_DIR is not set.\n"
51 | exit 1
52 | }
53 |
54 | todo_file=${TODO_DIR%%/}/TODO
55 |
56 | [ -f "$todo_file" ] || {
57 | printf "No 'TODO' file found in TODO_DIR.\n"
58 | exit 1
59 | }
60 |
61 | todo_"$opt"
62 | }
63 |
64 | main "$@"
65 |
--------------------------------------------------------------------------------
/scripts/tin:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #
4 | # tin - pastebin helper
5 | #
6 |
7 | command -v nc >/dev/null || {
8 | printf '%s: %s\n' "${0##*/}" "Please install 'nc' (netcat)."
9 | exit 1
10 | }
11 |
12 | [ -f "$1" ] || exit 1
13 |
14 | nc termbin.com 9999 < "$1"
15 |
--------------------------------------------------------------------------------
/scripts/ttt:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #
4 | # ttt - tty theme
5 | #
6 |
7 | printf '%b' "\e]P0192D36
8 | \e]P1FF9726
9 | \e]P226E4FF
10 | \e]P3FF9726
11 | \e]P426E4FF
12 | \e]P5FF9726
13 | \e]P626E4FF
14 | \e]P7A3EBF5
15 | \e]P8497284
16 | \e]P9FF9726
17 | \e]PA26E4FF
18 | \e]PBFF9726
19 | \e]PC26E4FF
20 | \e]PDFF9726
21 | \e]PE26E4FF
22 | \e]PFA3EBF5
23 | \ec"
24 |
--------------------------------------------------------------------------------
/scripts/vol:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #
4 | # vol - volume control
5 | #
6 |
7 | command -v pamixer >/dev/null || {
8 | printf '%s: %s\n' "${0##*/}" "Please install 'pamixer'."
9 | exit 1
10 | }
11 |
12 | if [ -z "$1" ]; then
13 | pamixer --get-volume-human
14 | elif [ "$1" -gt 100 ]; then
15 | pamixer --set-volume 100
16 | elif [ "$1" -lt 1 ]; then
17 | pamixer --set-volume 1
18 | else
19 | pamixer --set-volume "$1"
20 | fi
21 |
--------------------------------------------------------------------------------
/scripts/wpp:
--------------------------------------------------------------------------------
1 | #!/bin/sh -f
2 |
3 | #
4 | # wpp - wallpaper
5 | #
6 |
7 | die() {
8 | printf '\033[1;31m%s\033[m\n' "$*"
9 | exit 1
10 | }
11 |
12 | img() {
13 | set +f
14 | set -f -- "${1%%/}/"*
15 | shift "$(shuf -i "0-$#" -n 1)"
16 |
17 | while [ ! -f "$1" ] && [ "$2" ]; do shift; done
18 |
19 | [ -f "${img:=$1}" ] || {
20 | die "Failed to select wallpaper."
21 | }
22 | }
23 |
24 | main() {
25 | command -v feh >/dev/null || {
26 | die "feh is not installed."
27 | }
28 |
29 | [ -z "$WPP_LIB" ] && {
30 | die "WPP_LIB is not set."
31 | }
32 |
33 | img "$WPP_LIB"
34 |
35 | feh --bg-fill "$img" &
36 |
37 | printf 'Using wallpaper: %s\n' "${img##*/}"
38 | }
39 |
40 | main
41 |
--------------------------------------------------------------------------------
/scripts/xep:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #
4 | # xep
5 | #
6 |
7 | [ "$1" = "run" ] && {
8 | DISPLAY=:1 "$2"
9 | exit 0
10 | }
11 |
12 | [ "$1" = "white" ] && {
13 | DISPLAY=:1 xsetroot -solid "#ffffff"
14 | exit 0
15 | }
16 |
17 | [ "$1" = "black" ] && {
18 | DISPLAY=:1 xsetroot -solid "#000000"
19 | exit 0
20 | }
21 |
22 | (Xephyr -br -ac -noreset -screen 1440x810 :1 &) 2>/dev/null
23 |
--------------------------------------------------------------------------------
/scripts/ytd:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #
4 | # ytd - youtube-dl
5 | #
6 |
7 | case $1 in
8 | a|audio)
9 | yt-dlp \
10 | --add-metadata \
11 | -f "bestaudio[ext=m4a]" \
12 | -o "$HOME/media/music/%(title)s.%(ext)s" \
13 | "$2"
14 |
15 | exit
16 | ;;
17 | v|video)
18 | yt-dlp \
19 | -f "bestvideo[ext=mp4][height<1200]+bestaudio[ext=m4a]/best[ext=mp4][height<1200]/best" \
20 | -o "$HOME/media/video/%(title)s.%(ext)s" \
21 | "$2"
22 |
23 | exit
24 | ;;
25 | *)
26 | printf 'Usage: ytd a|audio|v|video url\n'
27 | exit
28 | ;;
29 | esac
30 |
--------------------------------------------------------------------------------