diff options
| author | marcellus <msimon_fr@hotmail.com> | 2024-02-02 22:13:34 +0100 |
|---|---|---|
| committer | marcellus <msimon_fr@hotmail.com> | 2024-02-02 22:13:34 +0100 |
| commit | 3ddbe04c5a8b01fe00221339dcfc5489b2b032db (patch) | |
| tree | 24abfc50f4a926ce22e047637617fbc5cd3eae67 /scripts | |
| parent | 1b7402b9e0d623cab9284aada81fb5429cf662e7 (diff) | |
various: read the diff
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/dmenuoff | 4 | ||||
| -rwxr-xr-x | scripts/dmenurecord | 153 | ||||
| -rwxr-xr-x | scripts/glitchlock | 55 | ||||
| -rwxr-xr-x | scripts/music | 2 | ||||
| -rwxr-xr-x | scripts/snowjob | 40 |
5 files changed, 251 insertions, 3 deletions
diff --git a/scripts/dmenuoff b/scripts/dmenuoff index e278c8a..2be5a99 100755 --- a/scripts/dmenuoff +++ b/scripts/dmenuoff @@ -7,9 +7,9 @@ ROOTCMD="${ROOTCMD:-$(command -v doas || command -v sudo)}" case "$QUERY" in "lock") - slock ;; + glitchlock ;; "poweroff") "$ROOTCMD" poweroff ;; "reboot") "$ROOTCMD" reboot ;; -esac
\ No newline at end of file +esac diff --git a/scripts/dmenurecord b/scripts/dmenurecord new file mode 100755 index 0000000..cc39567 --- /dev/null +++ b/scripts/dmenurecord @@ -0,0 +1,153 @@ +#!/bin/sh +# dmenu for recordings with ffmpeg +# dependencies: pipewire-pulse/pulseaudio, ffmpeg, dmenu, slop +# Original: https://github.com/whoisYoges/record-with-ffmpeg + +set -e + +videodir="${XDG_VIDEOS_DIR:-$HOME/Videos}/ffmpeg/" +audiodir="$videodir" +title="$(date +ffmpeg-"%Y-%m-%d-%H-%M-%S")" +recordingresolution="$(xrandr | sed -n 's/\s*\([0-9]\+x[0-9]\+\).*\*.*/\1/p')" +outputresolution="$recordingresolution" +display="$DISPLAY" +fps="30" +crf="22" # 18 +codecvideo="libx264" +codecaudio="libmp3lame" +preset="veryfast" +videoext="mp4" +audioext="wav" + +# use pactl list source to check the infos +monitoraudioinput="alsa_output.pci-0000_00_1b.0.analog-stereo.monitor" +microphoneaudioinput="alsa_input.pci-0000_00_1b.0.analog-stereo" +monitoraudiochannel="2" +microphoneaudiochannel="2" +monitoraudiofrequency="48000" +microphoneaudiofrequency="48000" +outputaudiofrequency="44100" + +internalAudioOnly() { + ffmpeg \ + -f pulse -ac "$monitoraudiochannel" -ar "$monitoraudiofrequency" -i "$monitoraudioinput" \ + -acodec "$codecaudio" -ar "$outputaudiofrequency" -q:a 1 "$title.$audioext" +} + +microphoneOnly() { + ffmpeg \ + -f pulse -ac "$microphoneaudiochannel" -ar "$microphoneaudiofrequency" -i "$microphoneaudioinput" \ + -acodec "$codecaudio" -ar "$outputaudiofrequency" -q:a 1 "$title.$audioext" +} + +internalAudioAndMicrophone() { + ffmpeg \ + -f pulse -ac "$monitoraudiochannel" -ar "$monitoraudiofrequency" -i "$monitoraudioinput" \ + -f pulse -ac "$microphoneaudiochannel" -ar "$microphoneaudiofrequency" -i "$microphoneaudioinput" \ + -filter_complex amix=inputs=2 \ + -acodec "$codecaudio" -ar "$outputaudiofrequency" -q:a 1 "$title.$audioext" +} + +videoWithoutAudio() { + ffmpeg \ + -f x11grab -r "$fps" -s "$recordingresolution" -i "$display" \ + -vcodec "$codecvideo" -preset "$preset" -crf "$crf" \ + -pix_fmt yuv420p -s "$outputresolution" "$title.$videoext" +} + +videoWithInternalAudio() { + ffmpeg \ + -f pulse -ac "$monitoraudiochannel" -ar "$monitoraudiofrequency" -i "$monitoraudioinput" \ + -f x11grab -r "$fps" -s "$recordingresolution" -i "$display" \ + -vcodec "$codecvideo" -preset "$preset" -crf "$crf" \ + -acodec "$codecaudio" -ar "$outputaudiofrequency" -q:a 1 \ + -pix_fmt yuv420p -s "$outputresolution" "$title.$videoext" +} + +videoWithMicrophone() { + ffmpeg \ + -f pulse -ac "$microphoneaudiochannel" -ar "$microphoneaudiofrequency" -i "$microphoneaudioinput" \ + -f x11grab -r "$fps" -s "$recordingresolution" -i "$display" \ + -vcodec "$codecvideo" -preset "$preset" -crf "$crf" \ + -acodec "$codecaudio" -ar "$outputaudiofrequency" -q:a 1 \ + -pix_fmt yuv420p -s "$outputresolution" "$title.$videoext" +} + +videoWithMicrophoneAndInternalAudio() { + ffmpeg \ + -f pulse -ac "$monitoraudiochannel" -ar "$monitoraudiofrequency" -i "$monitoraudioinput" \ + -f pulse -ac "$microphoneaudiochannel" -ar "$microphoneaudiofrequency" -i "$microphoneaudioinput" \ + -filter_complex amix=inputs=2 \ + -f x11grab -r "$fps" -s "$recordingresolution" -i "$display" \ + -vcodec "$codecvideo" -preset "$preset" -crf "$crf" \ + -acodec "$codecaudio" -ar "$outputaudiofrequency" -q:a 1 \ + -pix_fmt yuv420p -s "$outputresolution" "$title.$videoext" +} + +audio() { + choice=${1:-$(printf "Quit +1 Internal audio +2 Microphone +3 Both" | dmenu -i -p "Audio")} + + case $choice in + Quit) return 0 ;; + 1*) cd "$audiodir" && internalAudioOnly ;; + 2*) cd "$audiodir" && microphoneOnly ;; + 3*) cd "$audiodir" && internalAudioAndMicrophone ;; + *) return 1 ;; + esac +} + +video() { + choice=${1:-$(printf "Quit +1 Without audio +2 With internal audio +3 With mic +4 With both" | dmenu -i -p "Video")} + + case $choice in + Quit) return 0 ;; + 1*) cd "$videodir" && videoWithoutAudio ;; + 2*) cd "$videodir" && videoWithInternalAudio ;; + 3*) cd "$videodir" && videoWithMicrophone ;; + 4*) cd "$videodir" && videoWithMicrophoneAndInternalAudio ;; + *) return 1 ;; + esac +} + +setSelectionVal() { + X=$1 Y=$2 W=$3 H=$4 + [ $((W % 2)) -eq 1 ] && W=$((W + 1)) + [ $((H % 2)) -eq 1 ] && H=$((H + 1)) + recordingresolution="$W"x"$H" + outputresolution="$recordingresolution" + display="$display"+"$X","$Y" +} + +videosel() { + slop=$(slop -q -f "%x %y %w %h") || return 1 + # shellcheck disable=SC2086 + setSelectionVal $slop + video "$1" +} + +main() { + [ ! -d "$audiodir" ] && mkdir -p "$audiodir" + [ ! -d "$videodir" ] && mkdir -p "$videodir" + + choice=${1:-$(printf "Quit +1 Audio +2 Video +3 Video Selection" | dmenu -i -p "Mode")} + + case $choice in + Quit) return 0 ;; + 1*) audio "$2" ;; + 2*) video "$2" ;; + 3*) videosel "$2" ;; + *) return 1 ;; + esac +} + +main "$@"
\ No newline at end of file diff --git a/scripts/glitchlock b/scripts/glitchlock new file mode 100755 index 0000000..16016a9 --- /dev/null +++ b/scripts/glitchlock @@ -0,0 +1,55 @@ +#!/bin/bash +# ┏━┓┳ o┏┓┓┏━┓┳ ┳┳ ┏━┓┏━┓┳┏ +# ┃ ┳┃ ┃ ┃ ┃ ┃━┫┃ ┃ ┃┃ ┣┻┓ +# ┇━┛┇━┛┇ ┇ ┗━┛┇ ┻┇━┛┛━┛┗━┛┇ ┛ +# +# author: xero <x@xero.nu> http://xero.nu +# requires: i3lock-color, imagemagick, scrot + +maim /tmp/lock.png +convert /tmp/lock.png /tmp/lock.jpg +file=/tmp/lock.jpg + +function datamosh() { + fileSize=$(wc -c < "$file") + headerSize=1000 + skip=$(shuf -i "$headerSize"-"$fileSize" -n 1) + count=$(shuf -i 1-10 -n 1) + for i in $(seq 1 $count);do byteStr=$byteStr'\x'$(shuf -i 0-255 -n 1); done; + printf $byteStr | dd of="$file" bs=1 seek=$skip count=$count conv=notrunc >/dev/null 2>&1 +} + +steps=$(shuf -i 40-70 -n 1) +for i in $(seq 1 $steps);do datamosh "$file"; done + +GLITCHICON=${GLITCHICON:=""} +PARAM=(--bar-indicator --bar-orientation horizontal --bar-direction 1 --redraw-thread -t "" \ + --bar-step 50 --bar-total-width 250 --bar-base-width 50 --bar-max-height 100 --bar-periodic-step 50 \ + --bar-color 00000077 --keyhl-color 00666666 --ringver-color cc87875f --wrong-color ffff0000 \ + --verif-text="" --wrong-text="" --noinput-text="" ) + +LOCK=() +while read LINE +do + if [[ "$LINE" =~ ([0-9]+)x([0-9]+)\+([0-9]+)\+([0-9]+) ]]; then + W=${BASH_REMATCH[1]} + H=${BASH_REMATCH[2]} + Xoff=${BASH_REMATCH[3]} + Yoff=${BASH_REMATCH[4]} + if [ ! -z "$GLITCHICON" ]; then + IW=`identify -ping -format '%w' $GLITCHICON` + IH=`identify -ping -format '%h' $GLITCHICON` + MIDXi=$(($W / 2 + $Xoff - $IW / 2)) + MIDYi=$(($H / 2 + $Yoff - $IH / 2)) + LOCK+=($GLITCHICON -geometry +$MIDXi+$MIDYi -composite) + fi + fi +done <<<"$(xrandr)" + +convert /tmp/lock.jpg /tmp/lock.png >/dev/null 2>&1 +rm /tmp/lock.jpg +file=/tmp/lock.png + +convert "$file" "${LOCK[@]}" "$file" + +i3lock -f --indicator -k --time-color="458588ff" --date-color="458588ff" --verif-text="Vérification\n..." --wrong-text="Bonjour non." --noinput-text="Pas de putes internes" -i "$file" > /dev/null 2>&1 diff --git a/scripts/music b/scripts/music index 8cc1dea..677f673 100755 --- a/scripts/music +++ b/scripts/music @@ -36,5 +36,5 @@ if [ -z "$SHUFFLE" ] && [ -d "$MUSIC" ] || printf '%s' "$MUSIC" | grep -q playli fi printf 'stop\n' | socat - /tmp/mpvsocket 2> /dev/null -mpv --vid=auto --input-ipc-server=/tmp/mpvsocket --loop-playlist\ +mpv --vid=no --input-ipc-server=/tmp/mpvsocket --loop-playlist\ --ytdl-format=ba --script="$SCRIPT" --shuffle="$SHUFFLE" "$MUSIC" diff --git a/scripts/snowjob b/scripts/snowjob new file mode 100755 index 0000000..6c98251 --- /dev/null +++ b/scripts/snowjob @@ -0,0 +1,40 @@ +#!/bin/bash + +LINES=$(tput lines) +COLUMNS=$(tput cols) + +declare -A snowflakes +declare -A lastflakes + +clear + +function move_flake() { + i="$1" + + if [ "${snowflakes[$i]}" = "" ] || [ "${snowflakes[$i]}" = "$LINES" ]; then + snowflakes[$i]=0 + else + if [ "${lastflakes[$i]}" != "" ]; then + printf "\033[%s;%sH \033[1;1H " ${lastflakes[$i]} $i + fi + fi + + printf "\033[%s;%sH\u274$[($RANDOM%6)+3]\033[1;1H" ${snowflakes[$i]} $i + + lastflakes[$i]=${snowflakes[$i]} + snowflakes[$i]=$((${snowflakes[$i]}+1)) +} + +while : +do + i=$(($RANDOM % $COLUMNS)) + + move_flake $i + + for x in "${!lastflakes[@]}" + do + move_flake "$x" + done + + sleep 0.1 +done
\ No newline at end of file |
