Files
dotfiles/mybin/ru
Sebastian Moser e6a35ee756 stuff
2026-02-17 22:30:17 +01:00

173 lines
3.3 KiB
Bash
Executable File

#!/bin/bash
if [ "$1" == "sync-school" ]
then
~/work/config/scripts/sync-school.sh
elif [ "$1" == "rm-last-char" ]
then
truncate -s-1 $2
# total rubish
# cat $1 | xxd -ps | sed '$ s/.$//' $2 | xxd -r -ps > /tmp/1234; mv /tmp/1234 $2
elif [ "$1" == "rm-tab-cur" ]
then
ssh tab "rm /sdcard/note/CUR/*"
elif [ "$1" == "du" ]
then
du -d 1 -h $2 | sort -h -r
elif [ "$1" == "g" ]
then
ping 1.1.1.1
elif [ "$1" == "davinci-resolve-convert-videos" ]
then
FFMPEG_ACCEL_ARGS="-hwaccel vaapi -hwaccel_device /dev/dri/renderD128"
KEEP=true
PRORES=$2
if [[ "$1" == "d" ]]
then
KEEP=false
fi
if [ -d "$PWD/vid" ];
then
cd vid
mkdir -p "$PWD/for-davinci"
files=()
for x in *.mp4; do
files+=("${x%%/*}")
done
for file in "${files[@]}"
do
echo "handling file: $file"
if [ -f "$PWD/for-davinci/${file%.*}$PRORES.mov" ]
then
rm "$PWD/for-davinci/${file%.*}$PRORES.mov"
fi
echo "PRORES: $PRORES"
[[ "$PRORES" != "-prores" ]] && ffmpeg $FFMPEG_ACCEL_ARGS -i "$PWD/$file" -c:v mpeg4 -c:a mp3 "${PWD}/for-davinci/${file%.*}.mov"
[[ "$PRORES" == "-prores" ]] && ffmpeg $FFMPEG_ACCEL_ARGS -i "$PWD/$file" -c:v prores_ks -c:a pcm_s16le "${PWD}/for-davinci/${file%.*}-prores.mov"
[[ "$KEEP" == "false" ]] && rm "$file"
done
fi
elif [ "$1" == "mnt-wechner" ]
then
rclone mount --vfs-cache-mode full -vvvv onedrive-school:projekt-autobatterie ~/work/htl/projekt/wechner/mnt
elif [ "$1" == "mnt-host" ]
then
if [[ "$1" == "-r" ]]
then
host=$3
sshfs $host:/ ~/mnt
else
host=$2
sshfs $host: ~/mnt
fi
elif [ "$1" == "mnt-school" ]
then
rclone mount --vfs-cache-mode full -vvvv onedrive-school: ~/mnt
elif [ "$1" == "wstunnel" ]
then
wstunnel -L 55555:127.0.0.1:49388 ws://sebastian.dns.army:49389
elif [ "$1" == "speed-test-nixos-iso" ]
then
wget -O /tmp/speed-test.iso "https://channels.nixos.org/nixos-24.11/latest-nixos-gnome-x86_64-linux.iso"
rm /tmp/speed-test.iso
elif [ "$1" == "speed-test-upload" ]
then
host=$2
echo upload to $host
cat /dev/random | pv | ssh $host "cat > /dev/null"
elif [ "$1" == "speed-test-download" ]
then
host=$2
echo download from $host
ssh $host "cat /dev/random" | pv > /dev/null
elif [ "$1" == "p" ]
then
ping orf.at
elif [ "$1" == "mnt-files-local" ]
then
sudo mount -t cifs //192.168.1.2/files /home/me/files -o x-gvfs-hide,rw,defaults,nofail,credentials=/home/me/work/here/secrets/rpi-share-files,uid=1000,iocharset=utf8,gid=1000
elif [ "$1" == "mnt-files-remote" ]
then
sshfs -o default_permissions,idmap=user,uid=1000,gid=1000 files:/home/files/storage/files /home/me/files
#fusermount -u /home/sebastian/files
#fusermount -u /home/sebastian/lan
elif [ "$1" == "mnt-lan-remote" ]
then
sshfs -o default_permissions,idmap=user,uid=1000,gid=1000 files:/home/files/storage/lan /home/me/lan
elif [ "$1" == "mnt-lan-local" ]
then
sudo mount -t cifs //192.168.1.2/lan /home/me/lan -o x-gvfs-hide,username=guest,defaults,nofail,guest,uid=1000,gid=1000,iocharset=utf8
elif [ "$1" == "bat" ]
then
now=$(cat /sys/class/power_supply/BAT1/charge_now)
full=$(cat /sys/class/power_supply/BAT1/charge_full)
stat=$(python -c "print( round($now / float($full) *100) )")
echo BAT0 at: ${stat}%
elif [ "$1" == "bstat" ]
then
cat /sys/class/power_supply/BAT1/status
elif [ "$1" == "hibernate" ]
then
swaylock
sudo systemctl hibernate
elif [ "$1" == "suspend" ]
then
sudo systemctl suspend
fi