alpha
Login
or
Join now
j3s.sh
/
dotfiles
Star
0
Fork
0
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
my dotz
Star
0
Fork
0
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
Overview
Issues
Pulls
Pipelines
Add some dylanaraps stuff
author
j3s
date
6 years ago
(Feb 1, 2020, 1:21 PM -0600)
commit
65050831
65050831c57c1a4e04b9aa800b9ad42bb5856163
parent
132b31b9
132b31b92685d209a906035f1498522501d5ea75
+125
-1
4 changed files
Expand all
Collapse all
Unified
Split
bin
bud
n
scr
xdg-open
+109
bin/bud
Reviewed
···
1
1
+
#!/bin/sh -f
2
2
+
#
3
3
+
# pywalesque posix sh alternative.
4
4
+
5
5
+
img() {
6
6
+
[ -d "$1" ] && {
7
7
+
set +f
8
8
+
set -f -- "$1/"*
9
9
+
shift "$(shuf -i "1-$#" -n 1)"
10
10
+
}
11
11
+
12
12
+
[ -f "${img:=$1}" ] || exit 1
13
13
+
14
14
+
printf '%s\n' "$img"
15
15
+
}
16
16
+
17
17
+
hex2rgb() {
18
18
+
set -- "${1##\#}"
19
19
+
20
20
+
r=${1%%????}
21
21
+
g=${1##??}
22
22
+
g=${g%%??}
23
23
+
b=${1##????}
24
24
+
25
25
+
r=$((0x$r))
26
26
+
g=$((0x$g))
27
27
+
b=$((0x$b))
28
28
+
}
29
29
+
30
30
+
mod() {
31
31
+
hex2rgb "$2"
32
32
+
33
33
+
# The operator is stored in a variable
34
34
+
# which makes shellcheck freak out.
35
35
+
# shellcheck disable=1102,2086
36
36
+
{
37
37
+
r=$((r $3 $4))
38
38
+
g=$((g $3 $4))
39
39
+
b=$((b $3 $4))
40
40
+
}
41
41
+
42
42
+
r=$((r > 255 ? 255 : r < 0 ? 0 : r))
43
43
+
g=$((g > 255 ? 255 : g < 0 ? 0 : g))
44
44
+
b=$((b > 255 ? 255 : b < 0 ? 0 : b))
45
45
+
46
46
+
export "$1=$(printf '%02x%02x%02x' "$r" "$g" "$b")"
47
47
+
}
48
48
+
49
49
+
col() {
50
50
+
cache_file=$(printf %s "$img" | base64)
51
51
+
52
52
+
# Backticks need to be used here to fix bugs in
53
53
+
# some specific POSIX shells.
54
54
+
#
55
55
+
# Word splitting is also intentional and safe here.
56
56
+
# shellcheck disable=2046,2006
57
57
+
if [ -f "$cache_dir/$cache_file" ]; then
58
58
+
paleta < "$cache_dir/$cache_file" &
59
59
+
60
60
+
else
61
61
+
set -- `\
62
62
+
convert "$img" \
63
63
+
-alpha off \
64
64
+
-resize 64x64 \
65
65
+
-posterize 16 \
66
66
+
-fill white \
67
67
+
-colorize 30% \
68
68
+
-modulate 125,175,100 \
69
69
+
-unique-colors \
70
70
+
txt:- |
71
71
+
while IFS='# ' read -r _ _ col _; do
72
72
+
i=$((i+1))
73
73
+
[ "$i" -lt 11 ] && continue
74
74
+
[ "$i" -gt 16 ] && continue
75
75
+
printf '%s\n' "$col"
76
76
+
done
77
77
+
`
78
78
+
79
79
+
# These variables are dynamically defined,
80
80
+
# ignore undeclared variable warnings.
81
81
+
# shellcheck disable=2154
82
82
+
{
83
83
+
mod bg "$2" / 4
84
84
+
mod fg "$2" + 150
85
85
+
mod co "$bg" + 125
86
86
+
87
87
+
set -- "$bg" "$@" "$fg" "$co" "$@" "$fg"
88
88
+
}
89
89
+
90
90
+
printf '%s\n' "$@" | paleta &
91
91
+
printf '%s\n' "$@" > "$cache_dir/$cache_file"
92
92
+
fi
93
93
+
}
94
94
+
95
95
+
main() {
96
96
+
mkdir -p "${cache_dir:=${XDG_CACHE_HOME:=${HOME}/.cache}/bud}"
97
97
+
98
98
+
img "$1"
99
99
+
100
100
+
display \
101
101
+
-page 3200x \
102
102
+
-sample 3200x \
103
103
+
-window root \
104
104
+
"$img" &
105
105
+
106
106
+
col &
107
107
+
}
108
108
+
109
109
+
main "$1"
+2
bin/n
Reviewed
···
1
1
#!/bin/sh
2
2
+
#
3
3
+
# Open notes file & take notes
2
4
3
5
notefile="$HOME/sync/notes.md"
4
6
printf '\n' >> "$notefile"
+13
bin/scr
Reviewed
···
1
1
+
#!/bin/sh
2
2
+
#
3
3
+
# Take a screenshot
4
4
+
5
5
+
scr_dir=~/pix/screenshots
6
6
+
7
7
+
date=$(date +%F)
8
8
+
time=$(date +%I-%M-%S)
9
9
+
file=$scr_dir/$date/$date-$time.jpg
10
10
+
11
11
+
mkdir -p "$scr_dir/$date"
12
12
+
import -window root "$file"
13
13
+
cp -f "$file" "$scr_dir/current.jpg"
+1
-1
bin/xdg-open
Reviewed
···
1
1
#!/bin/sh
2
2
case "${1%%:*}" in
3
3
http|https|*.pdf)
4
4
-
exec qutebrowser "$1"
4
4
+
exec firefox "$1"
5
5
;;
6
6
mailto)
7
7
exec aerc "$1"