From 48a1df052b6e12cc18e16583c0714da01ac904c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Mei=C3=9Fner?= <936176+t-nil@users.noreply.github.com> Date: Sat, 25 May 2024 12:45:07 +0200 Subject: [PATCH] (merging random old changes) --- bubblewrap/keepass-diff.sh | 2 +- bubblewrap/shell.sh | 2 +- helpers/_error.function.fish | 2 +- memory_usage.sh | 13 ++++++++---- mount_8tb.sh | 2 +- onedrive.sh | 8 ++++++-- rainbow_screen.py | 13 ++++++------ video/av1an.fish | 40 +++++++++++++++++++++++++++++------- vmaf.fish | 12 ++++++++++- vpn_uni.sh | 4 +++- 10 files changed, 73 insertions(+), 25 deletions(-) diff --git a/bubblewrap/keepass-diff.sh b/bubblewrap/keepass-diff.sh index 7ae05f0..e8c33f0 100755 --- a/bubblewrap/keepass-diff.sh +++ b/bubblewrap/keepass-diff.sh @@ -51,4 +51,4 @@ exec bwrap --ro-bind /usr /usr \ ###### # # shell for testing - --setenv argv "$argv" -- fish +# --setenv argv "$argv" -- fish diff --git a/bubblewrap/shell.sh b/bubblewrap/shell.sh index 442bf2b..de37173 100755 --- a/bubblewrap/shell.sh +++ b/bubblewrap/shell.sh @@ -34,6 +34,6 @@ exec bwrap --ro-bind /usr /usr \ --setenv PS1 "bwrap-demo$ " \ --file 11 /etc/passwd \ --file 12 /etc/group \ - /bin/sh) \ + /bin/sh \ 11< <(getent passwd $UID 65534) \ 12< <(getent group $(id -g) 65534) diff --git a/helpers/_error.function.fish b/helpers/_error.function.fish index 3f4e8a9..ecf5efa 100644 --- a/helpers/_error.function.fish +++ b/helpers/_error.function.fish @@ -6,6 +6,6 @@ function _error --description 'Call with `_error <msg> <var1> <var2> … <var_n> set out $out {$i}="$$i" end - begin; echo set_color brred; echo -n $argv[1]; set_color red; echo ' ('(string join ', ' $out)')'; set_color normal; end 1>&2 + begin; set_color brred; echo -n $argv[1]; set_color red; echo ' ('(string join ', ' $out)')'; set_color normal; end 1>&2 exit 1 end diff --git a/memory_usage.sh b/memory_usage.sh index 66437fd..ada357c 100755 --- a/memory_usage.sh +++ b/memory_usage.sh @@ -1,8 +1,13 @@ #!/usr/bin/env fish -argparse --exclusive c,p --max-args 1 'c/command' 'p/pid' -- $argv +argparse --exclusive c,p 'c/command=' 'p/pid=' -- $argv -set -q _flag_command ; and set psargs -eC $argv[2] -ps -eo pid,size,command | grep $1 -ps -eo size,command | grep $1 | awk '{ hr=$1/1024 ; sum += hr} END {print sum " MiB"}' +set -q _flag_command; and set psargs -C $_flag_command +set -q _flag_pid; and set psargs --pid $_flag_pid + +set -q psargs; or begin; echo "must provide --command or --pid"; exit 1; end + +#echo $psargs +ps -o rss,pid,cmd,rss $psargs +ps -o rss $psargs | awk '{ hr=$1/1024 ; sum += hr} END {print sum " MiB"}' diff --git a/mount_8tb.sh b/mount_8tb.sh index cdd50e2..afbd372 100755 --- a/mount_8tb.sh +++ b/mount_8tb.sh @@ -1,4 +1,4 @@ id -sudo cryptsetup luksOpen --key-file /root/8tb_keyfile /dev/disk/by-uuid/b94a609d-d734-4cae-bc6a-2f4dcff47afd luks-b94a609d-d734-4cae-bc6a-2f4dcff47afd || exit 1 +sudo cryptsetup luksOpen --key-file /root/8tb_keyfile /dev/disk/by-uuid/b94a609d-d734-4cae-bc6a-2f4dcff47afd luks-b94a609d-d734-4cae-bc6a-2f4dcff47afd sudo vgchange -ay BackupGroup || exit 2 udisksctl mount --block-device /dev/disk/by-uuid/5b4b9e59-eaef-4189-bb4c-42d81f9b94ee || exit 3 diff --git a/onedrive.sh b/onedrive.sh index 8bea746..52b69bf 100755 --- a/onedrive.sh +++ b/onedrive.sh @@ -19,8 +19,12 @@ set restic_args -r=rclone:onedrive_ohm:/backup/restic \ --password-command="cat $HOME/Documents/__wichtig__/passwords/restic_onedrive_ohm" if [ $argv[1] = 'restic' ] - restic $restic_args $argv[2..] + sudo -E restic $restic_args $argv[2..] +else if [ $argv[1] = 'share' ] + [ (count $argv) = 2 ] || begin; echo "Need one param after share…"; exit 1; end; + + sudo -E rclone copy $argv[2] onedrive_ohm:share/ || begin; echo "Rclone copy failed; aborting"; exit 1; end; + sudo -E rclone link onedrive_ohm:share/(basename $argv[2]); [ $pipestatus[1] -eq 0 ] || begin; echo "Rclone link failed; aborting"; rclone delete onedrive_ohm:share/(basename $argv[2]); end; else exec $argv end - diff --git a/rainbow_screen.py b/rainbow_screen.py index 0b1c53e..7c5d9b3 100755 --- a/rainbow_screen.py +++ b/rainbow_screen.py @@ -42,14 +42,15 @@ def sine_wave(phase, offset): return (math.sin(math.radians(phase + offset)) + 1) / 2 -def rainbow_cycle(duration, phases): - phase_shift = 360 / phases # dividing the circle into equal phases +def rainbow_cycle(duration): + n_phases = 3 + phase_shift = 360 / n_phases # dividing the circle into equal phases phase = 0 while True: r = sine_wave(phase, 0) # red led has no phase shift - g = sine_wave(phase, phase_shift * 2) # green led is shifted by 2 phases - b = sine_wave(phase, phase_shift * 4) # blue led is shifted by 4 phases + g = sine_wave(phase, phase_shift * 1) # green led is shifted by 1 phase + b = sine_wave(phase, phase_shift * 2) # blue led is shifted by 2 phases for monitor in monitors: change_gamma(f"{r:.2f}", f"{g:.2f}", f"{b:.2f}", monitors) @@ -60,12 +61,12 @@ def rainbow_cycle(duration, phases): if __name__ == "__main__": monitors = get_monitors() # Replace with your monitor name - duration = 0.1 # Duration for each color in seconds + duration = 0.05 # Duration for each color in seconds pprint(monitors) try: - rainbow_cycle(duration, 6) + rainbow_cycle(duration) except KeyboardInterrupt: change_gamma("1.0", "1.0", "1.0", monitors) # Reset to normal gamma values print("\nScript ended by user.") diff --git a/video/av1an.fish b/video/av1an.fish index f6a3c22..7c0ddb8 100755 --- a/video/av1an.fish +++ b/video/av1an.fish @@ -2,23 +2,49 @@ . (dirname (status current-filename))/../helpers/_error.function.fish -for var in input scene_max_sec preset n_workers target_vmaf min_q max_q n_probes probes_slow probes_fps_div +set EXTRA_ARGS_DELIM … + +for var in out_dir input scene_len preset extra_args n_workers target_vmaf min_q max_q n_probes probes_slow probes_fps_div set -q $var || _error 'Parameter not set' $var echo $var\t=\ $$var end -for i in $input +set input (string split \n $input); echo '(count $input):' (count $input) + +set scene_start_stop (string split … $scene_len) +if [ (count $scene_start_stop) -eq 2 ] + set scene_max_sec $scene_start_stop[2] + set scene_min (math $scene_start_stop[1] \* 24) + + set extra_args keyint=250''$EXTRA_ARGS_DELIM''$extra_args +else if [ (count $scene_start_stop) -eq 1 ] + set scene_max_sec $scene_start_stop + set scene_min 24 +end + +set args_conv (string split --no-empty -- $EXTRA_ARGS_DELIM $extra_args | string replace --regex -- '(.*)=(.*)' '--$1 $2' | string join ' ') +[ -n "$extra_args" ] && set extra_args $EXTRA_ARGS_DELIM''$extra_args +echo $args_conv - [ (count $probes_slow) -eq 0 ] && set out_prob 'fast' || begin; set out_prob 'slow'; set probes_slow '--probe-slow'; end - set output {$input} \ +[ $probes_slow = "yes" ] && begin; set out_prob 'slow'; set probes_slow '--probe-slow'; end +[ $probes_slow = "no" ] && begin; set out_prob 'fast'; set -e probes_slow; end + + + +for i in $input + set output {$i} \ 'av1an' \ - 's'$scene_max_sec \ + 's'$scene_len \ 'svt' \ - 'p'$preset \ + 'p'$preset''$extra_args \ 'vmaf'$target_vmaf \ 'min'$min_q'_max'$max_q \ 'probe=n'$n_probes'_'$out_prob'_mod'$probes_fps_div'_' set output (string join '_' $output).mkv + + set output $out_dir'/'$output + mkdir -p $out_dir || _error 'Couldn\'t `mkdir -p` output dir: dirname of ' output out_dir i + echo output: $output - nice -n 19 av1an -i $i -l $output -s {$i}.scenes_{$scene_max_sec}s -w $n_workers -e svt-av1 -v '--input-depth 10 --preset '$preset' --tune 0 --lp 4 --keyint -1 --tile-rows 0 --tile-columns 1' -m lsmash --chunk-order random --vmaf --vmaf-res 1920x1080 --vmaf-threads 4 --target-quality $target_vmaf --probes $n_probes $probes_slow --probing-rate $probes_fps_div --min-q $min_q --max-q $max_q -o $output ; end + nice -n 19 av1an -i $i --keep --temp $out_dir'/.tmp_'(basename $output) -l $output -s $out_dir'/'{$i}.scenes_{$scene_len} --extra-split-sec $scene_max_sec --min-scene-len $scene_min -w $n_workers -e svt-av1 -v '--preset '$preset' --tune 0 --lp 2 --tile-rows 0 --tile-columns 0 --lookahead 120 '$args_conv -m lsmash --chunk-order random --vmaf --vmaf-res 1920x1080 --vmaf-threads 2 --target-quality $target_vmaf --probes $n_probes $probes_slow --probing-rate 1 --min-q $min_q --max-q $max_q -o $output ; end diff --git a/vmaf.fish b/vmaf.fish index ab5015f..ac2187b 100755 --- a/vmaf.fish +++ b/vmaf.fish @@ -14,6 +14,16 @@ ffmpeg -i $vid -i $ORIG -filter_complex \ -f null - &| tee $vid"'$REPORT_EXT'" ' | string collect) +#------------------------------------------------------------------------------ +# +# Start +# +#------------------------------------------------------------------------------ + +# adjust niceness to idle +renice 19 --pid $fish_pid +ionice --class 3 --pid $fish_pid + set HELPERS (dirname (status current-filename))/helpers/ . $HELPERS/_error.function.fish . $HELPERS/_defer.function.fish (status filename) @@ -35,7 +45,7 @@ for f in $VIDEO_FILES_PRE end end -set VIDS_SELECTED (string split \n $VIDEO_FILES_NEW | fzf --prompt $FZF_PROMPT --multi || _error 'canceled by Ctrl+C' VIDEO_FILES_PRE VIDEO_FILES_NEW) +set VIDS_SELECTED (string split \n $VIDEO_FILES_NEW | fzf --prompt $FZF_PROMPT --query (basename $ORIG) --multi || _error 'canceled by Ctrl+C' VIDEO_FILES_PRE VIDEO_FILES_NEW) set args_tmp (mktemp --suffix .fish); _defer ffmpeg_args "rm -rf $args_tmp" chmod +x $args_tmp diff --git a/vpn_uni.sh b/vpn_uni.sh index c706620..9f8be31 100755 --- a/vpn_uni.sh +++ b/vpn_uni.sh @@ -3,7 +3,7 @@ VPN_USER=meissnerfl73755 VPN_PASSWORD_FILE=$(dirname $0)/pws/vpn_uni #VPN_PASSWORD_FILE=/home/ra1n/scripts/pws/vpn_uni -VPN_SERVER=vpn.ohmportal.de +VPN_SERVER=vpn2.ohmportal.de _uid=1000 echo $(dirname $0) @@ -28,6 +28,8 @@ args=( # set protocol to globalprotect - probably don't change this # --resolve fstest.th-nuernberg.de:141.75.149.143 # --servercert 'pin-sha256:lm+C0Qgm7ZTPMLZ7KJlRLk5teQGc9qhmGfZavlRv3eQ=' + + --disable-ipv6 ) -- GitLab