commit e70d6063e5b95280c845dda86fee1bc1f80fcfb5 Author: Bogomil Vasilev Date: Tue Aug 28 13:50:46 2018 +0300 initial commit diff --git a/bluetooth_sync_audio.sh b/bluetooth_sync_audio.sh new file mode 100755 index 0000000..4b904ac --- /dev/null +++ b/bluetooth_sync_audio.sh @@ -0,0 +1,21 @@ +#!/bin/bash +# fix bluetooth sound synchronization +# Source: https://blog.sleeplessbeastie.eu/2016/05/09/how-to-fix-bluetooth-sound-synchronization/ +# References: http://askubuntu.com/questions/145935/get-rid-of-0-5s-latency-when-playing-audio-over-bluetooth-with-a2d + +LANG=C + +for card in $(pactl list cards short | awk '$2 ~ /^bluez_card/ { print $1 }'); do + # Print device name + echo -n "Found device: " + pactl list cards | awk -v card="#${card}" -v ORS="\n" -v FS="\n" -v RS="" 'split($1,var," ") var[1] ~ /Card/ && var[2] == card { print }' | awk -v FS=" = " '/device.description/ { print $2}' | tr -d \" + + # Print profiles + pactl list cards | awk -v card="#${card}" -v ORS="\n" -v FS="\n" -v RS="" -e 'split($1,var," ") var[1] ~ /Card/ && var[2] == card { print }' | awk '/Profiles/,/Active/ {gsub(/^\t/,"",$0); print}' + + echo "Set profile: Headset Head Unit (HSP/HFP)" + pactl set-card-profile ${card} headset_head_unit + + echo "Set profile: Advanced Audio Distribution Profile (A2DP)" + pactl set-card-profile ${card} a2dp_sink +done diff --git a/checkpatch_project.sh b/checkpatch_project.sh new file mode 100755 index 0000000..308768c --- /dev/null +++ b/checkpatch_project.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +#checkpatch --no-tree -f +checkpatch="/usr/lib/modules/$(uname -r)/build/scripts/checkpatch.pl" + +if [ -z "$1" ]; then + project_dir="$PWD" +elif [ -d "$1" ]; then + project_dir="$1" +else + source_file="$1" +fi + +if [ -z "$project_dir" ]; then + "${checkpatch}" --no-tree -f "${source_file}" +else + find "${project_dir}" -regex '.*\.\(c\|h\)' -exec "${checkpatch}" --no-tree -f '{}' + +fi + diff --git a/ffmpeg/ultrafast_x264_mp4.sh b/ffmpeg/ultrafast_x264_mp4.sh new file mode 100755 index 0000000..b0affee --- /dev/null +++ b/ffmpeg/ultrafast_x264_mp4.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +# Capture screen script +prefix=`date +"%G.%m.%d_%H.%M.%S"` + +ffmpeg -y -f x11grab \ + -video_size 1920x1080 \ + -r 30 \ + -i $DISPLAY \ + -f pulse \ + -ac 2 \ + -i default \ + -c:v libx264 \ + -crf 0 \ + -pix_fmt yuv420p \ + -preset ultrafast \ + -threads 0 \ + $prefix.mp4 +# -f alsa \ +# -i hw:2,1 \ +#-an \ diff --git a/flac_to_mp3.sh b/flac_to_mp3.sh new file mode 100755 index 0000000..c5a4b36 --- /dev/null +++ b/flac_to_mp3.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +IFS=$'\n' +list=$(find "${1}" -iname "*flac") +for i in $list ; do + ffmpeg -i "$i" -acodec libmp3lame -b:a 192k "$(dirname $i)/$(basename "${i/.flac}").mp3" + printf "Removing: $i\n" + rm -f "$i" +done + diff --git a/headphone_profile_toggle.sh b/headphone_profile_toggle.sh new file mode 100755 index 0000000..7881172 --- /dev/null +++ b/headphone_profile_toggle.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +SINKS=$(pacmd list-sinks) +DEVICE="bluez_card.04_52_C7_C0_ED_BE" +IFS=$'\r' + +case $(echo "$SINKS" | grep 'bluetooth.protocol' | awk '{print $3}') in + "\"a2dp_sink\"") pacmd set-card-profile $DEVICE headset_head_unit 1>/dev/null 2>&1 + ;; + "\"headset_head_unit\"") pacmd set-card-profile $DEVICE a2dp_sink 1>/dev/null 2>&1 + ;; +esac + diff --git a/mp3_name_shuffle.sh b/mp3_name_shuffle.sh new file mode 100755 index 0000000..b0acae6 --- /dev/null +++ b/mp3_name_shuffle.sh @@ -0,0 +1,109 @@ +#!/bin/bash +# Author: smirky@smirky.net +# Created on: 09.06.2017 +# Last modifier: smirky@smirky.net +# Last modified: 23.03.2018 + +# Some 'sane' defaults +unset verbose +unset restore +unset music_dir +old_state_file='' +version="20180323" + +print_version() { + printf "Version: %s\\n" "${version}" +} + +print_usage() { + printf "Usage: %s -d DIRECTORY [-r STATE_FILE] [-V]\\n" "${0}" +} + +print_help() { + print_usage + printf "Rename all mp3 files in a directory with ability to restore. + + -d, --directory DIRECTORY specify the work path + -r, --restore STATE_FILE restore a previous state of file names + -V, --verbose output verbose details while running + -h, --help display this help and exit + -v, --version output version information and exit\\n" +} + +vprintf() { + if [ "${verbose}" ]; then + printf "%s\\n" "$@" + fi +} + +OPTS=$(getopt -o d:r:Vhv --long directory:,restore:,verbose,help,version -n 'parse-options' -- "$@") + +while true; do + case "$1" in + -v | --version ) print_version && exit;; + -h | --help ) print_help && exit;; + -V | --verbose ) verbose=true; shift;; + -r | --restore ) restore=true && old_state_file="$2"; shift 2;; + -d | --directory ) music_dir="$2"; shift 2;; + -- ) shift; break;; + * ) print_usage; exit;; + esac + if [ "$1" == "" ]; then + break + fi +done +if [ -z "${music_dir}" ]; then + print_usage + exit 1 +fi + +if [ ! -d "${music_dir}" ]; then + printf "%s doesn't exist!\\n" "${music_dir}" + exit 1 +fi + +if [ ! -w "${music_dir}" ]; then + printf "No permissions to write in %s !\\n" "${music_dir}" + exit 1 +fi + +state_dir="${music_dir}/_STATES_" +if [ ! -d "${state_dir}" ]; then + vprintf "Creating: ${state_dir}" + mkdir "${state_dir}" +fi + +new_state_file="${state_dir}/$(date +'%Y.%m.%d_%H:%M:%S')" +vprintf "Generating state file: ${new_state_file}" +touch "${new_state_file}" + +if [ $restore ]; then + if [ ! -f "${old_state_file}" ]; then + printf "No such STATE_FILE: %s !\\n" "${old_state_file}" + rm "${new_state_file}" + exit 1 + fi + IFS=$'\t' + while read -r old current + do + vprintf "mv \"${music_dir}/${current}\" \"${music_dir}/${old}\"" + mv "${music_dir}/${current}" "${music_dir}/${old}" + printf "%s\\t%s\\n" "${old}" "${current}" >> "${new_state_file}" + done < "${old_state_file}" + exit +fi + +vprintf "Generating mp3 file list..." +cd "${music_dir}" || return +IFS=$'\n' +list=$(find . -type f -iname "*.mp3" -printf '%P\n') +cd - 1>/dev/null || return + +for i in ${list} ; do + new_name="$(head -c 500 /dev/urandom | tr -dc 'a-zA-Z0-9_-' | fold -w 30 | head -n 1).mp3" + vprintf "mv \"${music_dir}/$i\" \"${music_dir}/${new_name}\"" + mv "${music_dir}/${i}" "${music_dir}/${new_name}" + printf "%s\\t%s\\n" "${i}" "${new_name}" >> "${new_state_file}" +done +vprintf "Done!" + diff --git a/mp3_resample.sh b/mp3_resample.sh new file mode 100755 index 0000000..c8dc542 --- /dev/null +++ b/mp3_resample.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +IFS=$'\n' +list=$(find "${1}" -iname "*mp3") + +resample() +{ + echo "${i}" + bitrate=$(mp3info -r a -p "%r" "${i}"|sed 's/\..*$//') + ffmpeg -i "${i}" -b:a "${bitrate}k" "${i}.mp3" + mv "${i}.mp3" "${i}" + echo "${i}.mp3" +} + +for i in ${list} ; do + resample "${i}" +done + diff --git a/screenshot_to_url_local.sh b/screenshot_to_url_local.sh new file mode 100755 index 0000000..1b2e02f --- /dev/null +++ b/screenshot_to_url_local.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +if [ -z "$DISPLAY" ]; then + DISPLAY=:0 +fi + +scrot '%Y-%m-%d-%H:%M:%S.png' -e "mv \$f ~http/screenshots/. && echo https://www.smirky.net/screenshots/\$f | xclip -selection clip-board" diff --git a/screenshot_to_url_remote.sh b/screenshot_to_url_remote.sh new file mode 100755 index 0000000..ca1c48e --- /dev/null +++ b/screenshot_to_url_remote.sh @@ -0,0 +1,8 @@ +#!/bin/bash +file=$(date +"%Y-%m-%d-%T.png") +maim -s "/tmp/$file" -b 1 +# link=$(proxychains4 curl -s -F file=@"/tmp/$file" https://www.smirky.net/upload/upload.php | grep https | cut -d\" -f2 2>/dev/null) +link=$(curl -s -F file=@"/tmp/$file" https://www.smirky.net/upload/upload.php | grep https | cut -d\" -f2 2>/dev/null) +rm -f "/tmp/$file" +notify-send "$link" +printf "%s" "$link" | xclip -selection clip-board