fix: .local/bin -> bin to avoid user pkg managers
This commit is contained in:
parent
87549c183f
commit
8f364ce723
8 changed files with 1 additions and 1 deletions
116
bin/dkprune
Executable file
116
bin/dkprune
Executable file
|
@ -0,0 +1,116 @@
|
|||
#!/bin/bash
|
||||
|
||||
function usage() {
|
||||
cat << EOF
|
||||
Usage: $0 [-hcCviIna]
|
||||
Prune Docker resources.
|
||||
If no option provided, defaults to -Cvn
|
||||
Options:
|
||||
-h Show this help and exits
|
||||
-c Remove stopped containers
|
||||
-C Remove all containers
|
||||
-v Remove unused volumes
|
||||
-i Remove build images
|
||||
-I Remove unused images
|
||||
-n Remove unused networks
|
||||
-a All of the above, equivalent of -CvIn
|
||||
EOF
|
||||
exit 0
|
||||
}
|
||||
|
||||
function add_opt() {
|
||||
local RESULT
|
||||
|
||||
RESULT="$1"
|
||||
for o in "$@"; do
|
||||
if [ "$((RESULT & o))" == 0 ]; then
|
||||
RESULT="$((RESULT + o))"
|
||||
fi
|
||||
done
|
||||
echo "$RESULT"
|
||||
}
|
||||
|
||||
if ! [ -w '/var/run/docker.sock' ] && [ "$EUID" != 0 ]; then
|
||||
exec sudo -- "$0" "$@"
|
||||
fi
|
||||
|
||||
c=1
|
||||
# C=2
|
||||
v=4
|
||||
i=8
|
||||
# I=16
|
||||
n=32
|
||||
# a="$((c + C + v + I + n))"
|
||||
|
||||
CLEAN=0
|
||||
while getopts hcCviIna o; do
|
||||
case "$o" in
|
||||
h)
|
||||
usage
|
||||
;;
|
||||
c)
|
||||
CLEAN="$(add_opt "$CLEAN" "$c")"
|
||||
;;
|
||||
C)
|
||||
CLEAN="$(add_opt "$CLEAN" "$c")"
|
||||
CON_OPT="-f"
|
||||
;;
|
||||
v)
|
||||
CLEAN="$(add_opt "$CLEAN" "$v")"
|
||||
;;
|
||||
i)
|
||||
CLEAN="$(add_opt "$CLEAN" "$i")"
|
||||
;;
|
||||
I)
|
||||
CLEAN="$(add_opt "$CLEAN" "$i")"
|
||||
IMG_OPT='-a'
|
||||
;;
|
||||
n)
|
||||
CLEAN="$(add_opt "$CLEAN" "$n")"
|
||||
;;
|
||||
a)
|
||||
CLEAN="$(add_opt "$CLEAN" "$c" "$v" "$i" "$n")"
|
||||
CON_OPT="-f"
|
||||
IMG_OPT='-a'
|
||||
;;
|
||||
*)
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ "$CLEAN" == 0 ]; then
|
||||
CLEAN="$((c + v + n))"
|
||||
CON_OPT="-f"
|
||||
fi
|
||||
|
||||
VALUES=(
|
||||
"$((c + i + v + n))"
|
||||
"$((c + i + n))"
|
||||
"$v"
|
||||
"$i"
|
||||
"$n"
|
||||
)
|
||||
|
||||
CON='container'
|
||||
PRUNE='prune -f'
|
||||
COMMANDS=(
|
||||
"docker system $PRUNE $IMG_OPT --volumes"
|
||||
"docker system $PRUNE $IMG_OPT"
|
||||
"docker volume $PRUNE"
|
||||
"docker image $PRUNE $IMG_OPT"
|
||||
"docker network $PRUNE"
|
||||
)
|
||||
|
||||
if [ "$((CLEAN & "$c"))" == "$c" ]; then
|
||||
docker "$CON" ls -aq | xargs docker "$CON" rm "$CON_OPT" 2> /dev/null
|
||||
fi
|
||||
|
||||
for idx in "${!VALUES[@]}"; do
|
||||
mask="${VALUES[$idx]}"
|
||||
|
||||
if [ "$((CLEAN & mask))" == "$mask" ]; then
|
||||
bash -c "${COMMANDS[$idx]}"
|
||||
CLEAN="$((CLEAN - mask))"
|
||||
fi
|
||||
done
|
9
bin/mouse_360
Executable file
9
bin/mouse_360
Executable file
|
@ -0,0 +1,9 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# counts target = 8182 ~ 25cm
|
||||
|
||||
sleep 3
|
||||
for _ in {0..1023}; do
|
||||
xdotool mousemove_relative 8 0
|
||||
done
|
17
bin/scanpdf
Executable file
17
bin/scanpdf
Executable file
|
@ -0,0 +1,17 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
usage() {
|
||||
echo "USAGE: $0 FILE.pdf"
|
||||
exit 0
|
||||
}
|
||||
|
||||
if [ "$1" == '-h' ] || [[ "$1" != *.pdf ]]; then
|
||||
usage
|
||||
fi
|
||||
|
||||
DEVICE='pixma:04A9178A_31A16C'
|
||||
FORMAT='png'
|
||||
RES=300
|
||||
|
||||
scanimage -d "$DEVICE" --format="$FORMAT" --resolution "$RES" | convert - "$1"
|
10
bin/set-ddc-light
Executable file
10
bin/set-ddc-light
Executable file
|
@ -0,0 +1,10 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
CUR_LIGHT="$(set-light "$@")"
|
||||
|
||||
SCREENS="$(sudo ddcutil detect | awk '$1 == "Display" {print $2}')"
|
||||
|
||||
for i in $SCREENS; do
|
||||
sudo ddcutil -d "$i" setvcp 10 "$CUR_LIGHT"
|
||||
done
|
43
bin/set-light
Executable file
43
bin/set-light
Executable file
|
@ -0,0 +1,43 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
shopt -s extglob nullglob
|
||||
|
||||
set_brightness() {
|
||||
MAX="$(cat "$1"/max_brightness)"
|
||||
FILE="$1"/brightness
|
||||
VAL="$(($2 * MAX / 100 + 1))"
|
||||
|
||||
[ "$VAL" -lt 0 ] && VAL=0
|
||||
[ "$VAL" -gt "$MAX" ] && VAL="$MAX"
|
||||
echo "$VAL" > "$FILE"
|
||||
}
|
||||
|
||||
CUR_FILE=/var/tmp/current_brightness
|
||||
|
||||
set +e
|
||||
CUR="$(cat "$CUR_FILE" || echo 50)"
|
||||
set -e
|
||||
|
||||
CUR="$((CUR - CUR % "$1"))"
|
||||
|
||||
case "${1:0:1}" in
|
||||
'')
|
||||
exit 1
|
||||
;;
|
||||
'+'|'-')
|
||||
NEW="$((CUR + "$1"))"
|
||||
;;
|
||||
*)
|
||||
NEW="$1"
|
||||
;;
|
||||
esac
|
||||
|
||||
[ "$NEW" -lt 0 ] && NEW=0
|
||||
[ "$NEW" -gt 100 ] && NEW=100
|
||||
|
||||
for dev in /sys/class/backlight/*; do
|
||||
set_brightness "$dev" "$NEW"
|
||||
done
|
||||
|
||||
echo "$NEW" > "$CUR_FILE"
|
||||
echo "$NEW"
|
47
bin/set-vol
Executable file
47
bin/set-vol
Executable file
|
@ -0,0 +1,47 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# TODO: multiple fast invocation cause volume not to be updated
|
||||
|
||||
PACTL_SINK='@DEFAULT_SINK@'
|
||||
SINK="$PACTL_SINK"
|
||||
|
||||
function get_vol() {
|
||||
VOL="$(pactl get-sink-volume "$SINK" 2> /dev/null)"
|
||||
|
||||
if [ -n "$VOL" ]; then
|
||||
CMD='pactl set-sink-volume'
|
||||
else
|
||||
CMD='amixer sset'
|
||||
SINK='Master'
|
||||
|
||||
VOL="$(amixer sget "$SINK")"
|
||||
fi
|
||||
}
|
||||
|
||||
set +e
|
||||
get_vol
|
||||
set -e
|
||||
|
||||
VOL="$(echo "$VOL" | grep -Po '\d+(?=%)' | head -n 1)"
|
||||
VOL="$((VOL - VOL % "$1"))"
|
||||
|
||||
case "${1:0:1}" in
|
||||
'')
|
||||
exit 1
|
||||
;;
|
||||
'+'|'-')
|
||||
VOL="$((VOL + "$1"))"
|
||||
;;
|
||||
*)
|
||||
VOL="$1"
|
||||
;;
|
||||
esac
|
||||
|
||||
[ "$VOL" -lt 0 ] && VOL=0
|
||||
[ "$VOL" -gt 100 ] && VOL=100
|
||||
|
||||
$CMD "$SINK" "$VOL%" > /dev/null
|
||||
pactl set-sink-mute "$PACTL_SINK" 0
|
||||
|
||||
echo "$VOL"
|
19
bin/ttydestroyer
Executable file
19
bin/ttydestroyer
Executable file
|
@ -0,0 +1,19 @@
|
|||
#!/bin/bash
|
||||
|
||||
usage() {
|
||||
echo "Usage: $0 /dev/pts/{tty_nb}"
|
||||
exit 0
|
||||
}
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
set "$(tty)"
|
||||
elif ! [ -w "$1" ]; then
|
||||
usage
|
||||
fi
|
||||
|
||||
(set -e
|
||||
|
||||
asciiquarium &
|
||||
cmatrix -ab &
|
||||
while true; do sl; done &
|
||||
) | lolcat > "$1"
|
Loading…
Add table
Add a link
Reference in a new issue