Compare commits

..

5 Commits

Author SHA1 Message Date
1dbe16c903 pdfmerge 2023-05-25 22:08:53 +02:00
1a9a4dee6d md 2023-04-12 13:03:20 +02:00
6294649b5a pulseaudio echo canceling after device cahnge 2021-11-28 19:10:22 +01:00
e2f1478fec better format 2021-11-28 19:08:26 +01:00
c3ea47b305 posix complain 2021-07-09 15:25:06 +02:00
7 changed files with 164 additions and 64 deletions

50
backup
View File

@ -1,38 +1,18 @@
#!/bin/bash #!/bin/bash
tempDir=/tmp/backup cd /media/hdd1/data
mountRemote() { if [[ -d .snapshots/rclone ]]; then
rclone mount schulev: "$tempDir" --daemon echo "last backup not finnished" > /dev/stderr
} exit 1
umountRemote() {
umount "$tempDir"
}
case $1 in
restore)
mountRemote
find "$tempDir" -type f | xargs -n 1 tar -xf
umountRemote
;;
backup)
mountRemote
declare -A hashes
while IFS= read -r file; do
hash="$(echo -n "$file" | openssl dgst -binary -sha256 | openssl base64 | sed -e 's/\//@/g')"
hashes[s]=0
file_hash="$tempDir/$hash"
hashes[$hash]=0
if [[ ! -f "$file_hash" || $(tar -df "$file_hash") ]]; then
tar -cf "$file_hash" "$file"
fi fi
done < <(find -type f,l; find -type d -empty) getfacl -R * > mrgeorgen/backup/perms
cd "$tempDir" SNAPSHOT="/media/hdd1/data-snapshots/rclone"
for file in *; do btrfs su sn /media/hdd1/data "$SNAPSHOT"
if [ ! -v hashes[$file] ]; then cd "$SNAPSHOT"
rm "$file" rclone sync -l --retries 10 --tpslimit 10 --user-agent "ISV|rclone|rclone/v1.42" . schulev: --exclude "/mrgeorgen/Medien/**" --exclude "/.snapshots/**" --exclude /.snapshots/ --exclude "/mrgeorgen/backup/natur/**" --exclude /mrgeorgen/backup/natur/ --exclude "/mrgeorgen/.cache/minecraft-mod-packager/**" |&
grep -v "Can't transfer non file/directory" | (
err=`cat`
if [[ $(echo "$err" |grep "ERROR : Attempt 10/10 failed with") ]]; then
echo "$err" > /dev/stderr
fi fi
done )
umountRemote btrfs su de "$SNAPSHOT"
;;
*)
echo "use backup or restore as argument"
;;
esac

View File

@ -1,4 +1,8 @@
#!/bin/sh #!/bin/sh
adb forward tcp:4747 tcp:4747 adb forward tcp:4747 tcp:4747
droidcam-cli 127.0.0.1 4747 while true; do
echo $! > ~/.pid/droidcam.pid droidcam-cli 127.0.0.1 4747 &
sleep 240
kill $!
sleep 3
done

View File

@ -1,4 +1,4 @@
#!/bin/sh #!/bin/sh
pid=`cat ~/.pid/droidcam.pid` pid=`cat ~/.pid/droidcam.pid`
kill -2 $pid kill $pid
rm ~/.pid/droidcam.pid rm ~/.pid/droidcam.pid

119
md
View File

@ -1,37 +1,112 @@
#!/bin/sh #!/bin/sh
ending() {
echo "$1" |awk -F . '{print $NF}'
}
checkMetadata() { checkMetadata() {
ffprobe "$1" 2>&1 | grep -e artist -e title ffprobe "$1" 2>&1 | grep -ie artist -e title
while true; do while true; do
read -p "correct metadata? [Y] | [n]: " yn printf "correct metadata? [Y] | [n]: "
read -r yn < /dev/tty
case "$yn" in case "$yn" in
[Yy]* ) return 0;;
[Nn]* ) return 1;; [Nn]* ) return 1;;
* ) echo "Please answer yes or no.";; * ) return 0;;
esac esac
done done
} }
cd ~/Medien/Musik/2020
download_dir="$(mktemp -d)" download_dir="$(mktemp -d)"
file_name="$(youtube-dl "ytsearch:$1 lyrics" \ temp_dir="$(mktemp -d)"
--extract-audio \ downloadSong() {
filepath="$(youtube-dl "ytsearch:$1 lyrics" \
-f bestaudio/best \
--output "$download_dir/%(title)s.%(ext)s" \ --output "$download_dir/%(title)s.%(ext)s" \
--metadata-from-title "%(artist)s - %(title)s" \ --metadata-from-title "%(artist)s - %(title)s" \
--audio-quality 0 \
--audio-format mp3 \
--embed-thumbnail \
--add-metadata \ --add-metadata \
|awk '$1 == "[ffmpeg]" && $2 == "Destination:" {print substr($0, index($0,$3))}')" |awk '$1 == "[download]" && $2 == "Destination:" {print substr($0, index($0,$3))}')"
r128gain "$file_name" 2> /dev/null case "$filepath" in
temp_dir="$(mktemp -d)" *.webm)
temp_file="$temp_dir/0.mp3" new_filename="${filepath%.*}".opus
cp "$file_name" "$temp_file" ffmpeg -i "$filepath" -codec copy "$new_filename" 2> /dev/null
idntag "$temp_file" filepath="$new_filename"
temp_file=$(echo "$temp_dir"/*) ;;
if checkMetadata "$temp_file"; then *.m4a)
mv "$temp_file" . ;;
elif checkMetadata "$file_name"; then *)
mv "$file_name" . echo "unsupported file type" > /dev/stderr
exit 1
;;
esac
r128gain "$filepath" 2> /dev/null
echo "$filepath"
}
changeMetadata() {
filepath="$1"
artist="$2"
title="$3"
dir="$4"
case "$filepath" in
*.opus)
metadata_track=":s:a:0"
title_tag="TITLE"
artist_tag="ARTIST"
;;
*.m4a)
title_tag="title"
artist_tag="artist"
;;
esac
metadata="-metadata$metadata_track"
output_path="$dir/$artist-$title.$(ending "$filepath")"
ffmpeg -i "$filepath" -codec copy "$metadata" "$title_tag=$title" "$metadata" \
"$artist_tag=$artist" "$output_path" 2> /dev/null
echo "$output_path"
}
while getopts "a:t:mp" c; do
case $c in
a) artist="$OPTARG";;
t) title="$OPTARG";;
m)
dir="$MUSIC_DIR/$(date +%Y)"
mkdir -p "$dir"
;;
p) print_path=0;;
*) echo "invalid flag" > /dev/stderr;;
esac
done
shift $(("$OPTIND" - 1))
if [ ! "$dir" ]; then
dir="$(pwd)"
fi
if [ "$artist" ] && [ "$title" ]; then
echo 1
filepath="$(downloadSong "$artist" "$title")"
output_path="$(changeMetadata "$filepath" "$artist" "$title" "$dir")"
if [ "$print_path" ]; then
echo "$output_path"
fi
else else
echo "enter it manually" for song in "$@"; do
filepath="$(downloadSong "$song")"
filename="$(basename "$filepath")"
if checkMetadata "$filepath"; then
mv "$filepath" "$dir"
if [ "$print_path" ]; then
echo "$dir/$filename"
fi
else
printf "artist: "
read -r artist
printf "title: "
read -r title
output_path="$(changeMetadata "$filepath" "$artist" "$title" "$dir")"
if [ "$print_path" ]; then
echo "$output_path"
fi
fi
done
fi fi
rm -rf "$temp_dir" "$download_dir" rm -rf "$temp_dir" "$download_dir"
mpc update > /dev/null

2
pdfmerge Normal file
View File

@ -0,0 +1,2 @@
gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=3.pdf -dBATCH -sPAPERSIZE=a4 -dFIXEDMEDIA -dPDFFitPage Bewerbung_Celine_Zinkel\
\(3\).pdf Zwischenprufung\ 4.\ S.pdf Abizeugnis.pdf

38
pulse-sink-change Executable file
View File

@ -0,0 +1,38 @@
#!/usr/bin/python3
import asyncio
import signal
from contextlib import suppress
import pulsectl_asyncio
import time
import subprocess
#import pulsectl
#print('Event types:', pulsectl.PulseEventTypeEnum)
#print('Event facilities:', pulsectl.PulseEventFacilityEnum)
#print('Event masks:', pulsectl.PulseEventMaskEnum)
last_reload = 0
async def listen():
async with pulsectl_asyncio.PulseAsync('event-printer') as pulse:
async for event in pulse.subscribe_events('all'):
global last_reload
if (event.facility == "sink_input" and event.index == 20 or event.facility == "server" and event.index == -1) and event.t == "change" and time.time() - last_reload >= 2:
last_reload = time.time()
subprocess.call(["pacmd", ".include", "/etc/pulse/default.pa.d/10-noise-cancellation.pa"])
async def main():
# Run listen() coroutine in task to allow cancelling it
listen_task = asyncio.create_task(listen())
# register signal handlers to cancel listener when program is asked to terminate
for sig in (signal.SIGTERM, signal.SIGHUP, signal.SIGINT):
loop.add_signal_handler(sig, listen_task.cancel)
# Alternatively, the PulseAudio event subscription can be ended by breaking/returning from the `async for` loop
with suppress(asyncio.CancelledError):
await listen_task
# Run event loop until main_task finishes
loop = asyncio.get_event_loop()
loop.run_until_complete(main())

View File

@ -2,3 +2,4 @@
file=~/Bilder/screenshots/$(date +%m_%d_%y_%T).png file=~/Bilder/screenshots/$(date +%m_%d_%y_%T).png
import -window root "$file" import -window root "$file"
xclip -sel clip -t image/png "$file" xclip -sel clip -t image/png "$file"
echo "$file"