initial commit
This commit is contained in:
21
bluetooth_sync_audio.sh
Executable file
21
bluetooth_sync_audio.sh
Executable file
@@ -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
|
||||
19
checkpatch_project.sh
Executable file
19
checkpatch_project.sh
Executable file
@@ -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
|
||||
|
||||
21
ffmpeg/ultrafast_x264_mp4.sh
Executable file
21
ffmpeg/ultrafast_x264_mp4.sh
Executable file
@@ -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 \
|
||||
10
flac_to_mp3.sh
Executable file
10
flac_to_mp3.sh
Executable file
@@ -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
|
||||
|
||||
13
headphone_profile_toggle.sh
Executable file
13
headphone_profile_toggle.sh
Executable file
@@ -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
|
||||
|
||||
109
mp3_name_shuffle.sh
Executable file
109
mp3_name_shuffle.sh
Executable file
@@ -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!"
|
||||
|
||||
18
mp3_resample.sh
Executable file
18
mp3_resample.sh
Executable file
@@ -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
|
||||
|
||||
7
screenshot_to_url_local.sh
Executable file
7
screenshot_to_url_local.sh
Executable file
@@ -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"
|
||||
8
screenshot_to_url_remote.sh
Executable file
8
screenshot_to_url_remote.sh
Executable file
@@ -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
|
||||
Reference in New Issue
Block a user