big update

This commit is contained in:
ange 2024-12-27 11:43:30 +00:00
parent 833e967aee
commit 72c73f9b18
Signed by: ange
GPG key ID: 9E0C4157BB7BEB1D
30 changed files with 132 additions and 60 deletions

View file

@ -2,15 +2,22 @@
declare -A aliases
aliases=(
[arch]=archlinux/archlinux:base
[debian]=debian:12-slim
[arch]=docker.io/archlinux/archlinux:base
[debian]=docker.io/debian:12-slim
[kaniko]=gcr.io/kaniko-project/executor:debug
)
if [ -z "$1" ]; then
exit 1
fi
img="${aliases[$1]:-$1:latest}"; shift
if [ -n "${aliases[$1]}" ]; then
img="${aliases[$1]}"
else
img="docker.io/$1"
[[ "$img" == *:* ]] || img+=:latest
fi
shift
set -x
podman run --rm -it -v "$PWD:/mnt/" -w /mnt/ "docker.io/$img" "$@"
podman run --rm -it -v "$PWD:/mnt/" -w /mnt/ "$img" "$@"

10
.local/bin/ffcapture Executable file
View file

@ -0,0 +1,10 @@
#!/bin/bash -e
output="$HOME/Videos/ffcapture$(date '+%Y%m%d_%H%M%S').mp4"
ffmpeg \
-framerate 30 \
-f x11grab -i "$DISPLAY.0" -c:v libx265 \
"$output"
# -f pulse -i # sink

18
.local/bin/giteadelimg Executable file
View file

@ -0,0 +1,18 @@
#!/bin/bash
read -rsp "PASSWD: " PASSWD; echo
read -rp "OWNER: " OWN
read -rp "NAME: " NAME
TOK="$(jq -rR '@uri' <<< "$PASSWD")"
API="https://ange:$TOK@git.gmoker.com/api/v1/packages"
PKG="$(curl "$API/$OWN" | jq -r ".[] | select(.name == \"$NAME\").version")"
echo "$PKG"
read -rp "Continue?"
while read -r pkg; do
(set -x
curl -XDELETE "$API/$OWN/container/$(jq -rR '@uri' <<< "$NAME")/$pkg"
)
done <<< "$PKG"

View file

@ -1,32 +1,18 @@
#!/bin/bash -e
function get_current() {
local cur; cur="$(cat "$1/brightness")"
local max; max="$(cat "$1/max_brightness")"
STEPS=16
DIR="$(printf '%s\n' /sys/class/backlight/* | head -n1)"
echo "$((cur * 100 / max))"
}
function set_light() {
local max; max="$(cat "$1/max_brightness")"
echo "$((CUR * max / 100))" > "$1/brightness"
}
DIRS=(/sys/class/backlight/*)
CUR="$(get_current "${DIRS[0]}")"
CUR="$(cat "$DIR/brightness")"
MAX=$(cat "$DIR/max_brightness")
case "${1:0:1}" in
'') echo "$CUR"; exit ;;
'+'|'-') CUR="$(($CUR + $1 - $CUR % $1 + $CUR % $1 * 10 / $1 / 5 * $1))" ;;
'+'|'-') CUR="$(((CUR / STEPS + $1) * STEPS))" ;;
*) CUR="$1" ;;
esac
echo "$CUR"
[ "$CUR" -lt 0 ] && CUR=0
[ "$CUR" -gt 100 ] && CUR=100
[ "$CUR" -lt 0 ] && CUR=0
[ "$CUR" -gt "$MAX" ] && CUR="$MAX"
for d in "${DIRS[@]}"; do
set_light "$d"
done
echo "$CUR" > "$DIR/brightness"

View file

@ -77,7 +77,7 @@ function update_net() {
}
function update_time() {
time="$(TZ=Asia/Jakarta date '+%R %Z') - $(TZ=Europe/Paris date '+%R %Z') - $(TZ=Asia/Makassar date '+%R %Z') - $(date -u '+%a %m-%d %R')"
time="$(TZ=Asia/Makassar date '+%R %Z') - $(date -u '+%a %m-%d %R')"
}
function reload() {

24
.local/bin/vm Executable file
View file

@ -0,0 +1,24 @@
#!/bin/bash -e
ISO="$1"
DISK="$HOME/${ISO%.*}.qcow2"
MAXMEM="$(free -g | awk '/Mem:/{print $2 - 2 * $3}')G"
OVMF_CODE=/usr/share/edk2/x64/OVMF_CODE.4m.fd
OVMF_VARS=/tmp/OVMF_VARS.4m.fd
set -x
[ -f "$OVMF_VARS" ] || cp -f /usr/share/edk2/x64/OVMF_VARS.4m.fd "$OVMF_VARS"
[ -f "$DISK" ] || qemu-img create -f qcow2 "$DISK" 20G
qemu-system-x86_64 \
-accel kvm \
-M q35 \
-monitor stdio \
-cpu host \
-m "2G,maxmem=$MAXMEM" \
-vga virtio \
-audio pipewire,model=hda \
-nic model=virtio-net-pci,type=user \
-drive "if=pflash,format=raw,file=$OVMF_CODE,readonly=on" \
-drive "if=pflash,format=raw,file=$OVMF_VARS" \
-drive "if=virtio,file=$DISK" \
-drive "file=$ISO,media=cdrom,readonly=on"

View file

@ -20,7 +20,7 @@ function update_vol() {
+*|-*)
CUR="$(($CUR + $1 - $CUR % $1 + $CUR % $1 * 10 / $1 / 5 * $1))"
[ "$CUR" -lt 0 ] && CUR=0
[ "$CUR" -gt 200 ] && CUR=200
[ "$CUR" -gt 150 ] && CUR=150
;;
*)
CUR="$1"

24
.local/bin/vpn Executable file
View file

@ -0,0 +1,24 @@
#!/bin/bash -e
function off() {
local ifs
read -ra ifs < <(wg show interfaces) || true
for i in "${ifs[@]}"; do
wg-quick down "$i"
done
}
[ "$EUID" != 0 ] && { pkexec bash -c "DISPLAY='$DISPLAY' XAUTHORITY='$XAUTHORITY' $0 $*"; exit; }
[ "$1" == off ] && { off; exit; }
if [ -n "$DISPLAY" ]; then
if="$(basename -s.conf /etc/wireguard/*.conf | /usr/local/bin/dmenu)"
else
select if in $(basename -s.conf /etc/wireguard/*.conf); do
break
done
fi
off
wg-quick up "$if"