Move .local/bin to .bin

This commit is contained in:
Tobias Reisinger 2022-04-08 15:04:35 +02:00
parent b8dd204681
commit 76f407954f
Signed by: serguzim
GPG key ID: 13AD60C237A28DFE
16 changed files with 58 additions and 38 deletions

23
.bin/archlinux-update Executable file
View file

@ -0,0 +1,23 @@
#!/usr/bin/sh
paru -Syu
if [ $? -eq 0 ]; then
echo "UPDATE SUCCEDEED"
else
echo "UPDATE FAILED"
exit 1
fi
echo "==================================================================="
sudo checkservices
if [ $? -eq 0 ]; then
echo "CHECKSERVICES SUCCEDEED"
else
echo "CHECKSERVICES FAILED"
exit 1
fi

43
.bin/backlight Executable file
View file

@ -0,0 +1,43 @@
#!/bin/bash
set -e
path="/sys/class/backlight/intel_backlight"
current_abs=$(cat "$path/actual_brightness")
max_abs=$(cat "$path/max_brightness")
percent=$(( max_abs / 100 ))
current=$(( current_abs / percent ))
new="$current"
change=$2
if [ "$1" = "-get" ]
then
echo "$current"
exit 0
fi
if [ "$1" = "-inc" ]
then
new=$(( current + change ))
fi
if [ "$1" = "-dec" ]
then
new=$(( current - change ))
fi
if [ "$1" = "-set" ]
then
new=$2
fi
if [ "$new" -lt 10 ]
then
new=10
fi
if [ "$new" -gt 100 ]
then
new=100
fi
echo "$(( new * percent ))" | tee "$path/brightness"

32
.bin/edit Executable file
View file

@ -0,0 +1,32 @@
#!/usr/bin/sh
set -e
edit_directory="$HOME/.cache/edit/"
filehash=$(readlink -fn "$1" | md5sum | awk '{ print $1 }')
filedirectory="$edit_directory/$filehash/"
mkdir -p "$filedirectory"
basename=$(basename "$1")
filepath=$(realpath -s "$filedirectory/$basename")
user=$(id -un)
group=$(id -gn)
echo "Editing $1 in $filepath as $user:$group"
sudo test -e "$1" && (
sudo cp -i "$1" "$filepath"
sudo chown "$user":"$group" "$filepath"
) || (
touch "$filepath"
)
$EDITOR "$filepath"
sudo cp "$filepath" "$1"
rm "$filepath"
rm -rd "$filedirectory"

107
.bin/git-fire Executable file
View file

@ -0,0 +1,107 @@
#!/usr/bin/env sh
# The MIT License (MIT)
# Copyright (c) 2015 - 2019 Nimit Kalra <nimit@utexas.edu>
# Permission is hereby granted, free of charge, to any person obtaining a copy
# Of this software and associated documentation files (the "Software"), to deal
# In the Software without restriction, including without limitation the rights
# To use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# Copies of the Software, and to permit persons to whom the Software is
# Furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in all
# Copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
# Setup.
VERSION="0.2.3"
version() {
printf "git-fire version %s\n" "$VERSION"
git --version
}
# Helpers.
current_branch() {
basename "$(git symbolic-ref HEAD)"
}
current_epoch() {
date +%s
}
user_email() {
git config user.email
}
new_branch() {
echo "fire-${1:-$(current_branch)}-$(user_email)-$(current_epoch)"
}
fire() {
initial_branch="$(current_branch)"
git checkout -b "$(new_branch)"
# cd to git root directory
cd "$(git rev-parse --show-toplevel)"
git add -A
if [ -z "$1" ]; then
message="Fire! Branch $(current_branch)."
else
message="$*"
fi
git commit -m "$message" --no-verify
for remote in $(git remote); do
git push --no-verify --set-upstream "${remote}" "$(current_branch)" || true
done
if [ "$(git stash list)" != '' ]; then
for sha in $(git rev-list -g stash); do
git push --no-verify origin "$sha":refs/heads/"$(current_branch $initial_branch)"-stash-"$sha"
done
fi
printf "\n\nLeave building!\n"
}
display_help() {
cat <<-EOF
usage:
git fire [options] [COMMAND] [args]
commands:
git fire Add, commit, and push to remote in case of a fire
git fire <message> Execute git fire with <message> for commit message
options:
-V, --version Output current version of git-fire
-h, --help Display this help information
EOF
exit 0
}
case $1 in
-V|--version) version; exit 0 ;;
-h|--help) display_help; exit 0 ;;
esac
fire "$@"

3
.bin/gpg2-decrypt Executable file
View file

@ -0,0 +1,3 @@
#!/usr/bin/env bash
gpg2 --output ${1%".gpg"} --decrypt $1

3
.bin/gpg2-encrypt Executable file
View file

@ -0,0 +1,3 @@
#!/usr/bin/env bash
gpg2 --output $1.gpg --encrypt $1

17
.bin/menu-shutdown Executable file
View file

@ -0,0 +1,17 @@
#!/bin/sh
action=$(echo -e "Shutdown\nReboot\nLogout" | $MENU)
case "$action" in
"Shutdown")
systemctl poweroff -i
;;
"Reboot")
systemctl reboot
;;
"Logout")
systemctl --user exit
;;
*)
;;
esac

4
.bin/passgen Executable file
View file

@ -0,0 +1,4 @@
#!/usr/bin/env sh
xkcdpass_res=$(xkcdpass --numwords=13 --case=capitalize)
echo ${xkcdpass_res}

5
.bin/rankmirrors-personal-pref Executable file
View file

@ -0,0 +1,5 @@
#!/bin/env sh
echo "#Server = https://archive.archlinux.org/repos/$(date +"%Y/%m/%d")/\$repo/os/\$arch"
curl -Ls "https://archlinux.org/mirrorlist/?country=AT&country=BE&country=CZ&country=DK&country=FI&country=FR&country=DE&country=IT&country=LU&country=NL&country=PL&protocol=https&ip_version=4" | sed -e 's/^#Server/Server/' -e '/^#/d' | rankmirrors

47
.bin/screenshot Executable file
View file

@ -0,0 +1,47 @@
#!/usr/bin/env sh
s3_bucket=public.serguzim.me/screenshots
s3_host=https://sos-de-fra-1.exo.io
path=/tmp/screenshot.png
file=$(date "+%F_%H-%M-%S").png
clip_image()
{
xclip -t image/png $1 -selection clipboard
}
upload_image()
{
echo -n "$s3_host/$s3_bucket/$file" | xclip -selection primary
s3cmd put -P $1 s3://$s3_bucket/$file
notify-send -a "Screenshot" "Uploaded screenshot to s3"
}
main_no_upload()
{
if flameshot gui -r > $path
then
clip_image $path
fi
}
main()
{
if [ -n "$1" ] && [ -e "$1" ]
then
convert $1 $path
clip_image $path
upload_image $path
else
if flameshot gui -r > $path
then
clip_image $path
upload_image $path
fi
fi
}
case $1 in
no_upload) main_no_upload ;;
*) main $1 ;;
esac

57
.bin/start_audio Executable file
View file

@ -0,0 +1,57 @@
#!/usr/bin/env sh
start_audio_jack () {
wait-for-service --user "puseaudio.socket"
systemctl --user stop pulseaudio.service
systemctl --user stop pulseaudio.socket
sleep 1
jack_control ds alsa
jack_control dps device hw:U192k
jack_control dps rate 48000
jack_control dps nperiods 4
jack_control dps period 256
jack_control start
sleep 1
systemctl --user start pulseaudio
sleep 1
alsa_out -d hw:PCH -j "Speaker" -c 2 &
#alsa_out -d "hdmi:CARD=HDMI,DEV=5" -j "Speaker" -c 2 &
sleep 1
jack_connect "PulseAudio JACK Sink":front-left Speaker:playback_1
jack_connect "PulseAudio JACK Sink":front-right Speaker:playback_2
if [ -x "$(command -v jack-matchmaker)" ]
then
jack-matchmaker -e \
Mopidy:out_jackaudiosink0_1 Speaker:playback_1 \
Mopidy:out_jackaudiosink0_2 Speaker:playback_2 &
fi
sleep 3
}
start_audio_pipewire () {
wait-for-service --user "pipewire.service"
wait-for-service --user "wireplumber.service"
sleep 5
pw-link 'default-sink:monitor_FL' 'alsa_output.usb-BEHRINGER_UMC202HD_192k-00.analog-stereo:playback_FL'
pw-link 'default-sink:monitor_FR' 'alsa_output.usb-BEHRINGER_UMC202HD_192k-00.analog-stereo:playback_FR'
pw-link 'default-sink:monitor_FL' 'alsa_output.pci-0000_00_1f.3.analog-stereo:playback_FL'
pw-link 'default-sink:monitor_FR' 'alsa_output.pci-0000_00_1f.3.analog-stereo:playback_FR'
}
case $1 in
jack) start_audio_jack ;;
pipewire) start_audio_pipewire ;;
*) echo "'$1' is not valid" ;;
esac

3
.bin/vim-find Executable file
View file

@ -0,0 +1,3 @@
#!/usr/bin/env bash
vim $(find $@)

3
.bin/vim-grep Executable file
View file

@ -0,0 +1,3 @@
#!/usr/bin/env bash
vim $(grep $@)

15
.bin/wait-for-service Executable file
View file

@ -0,0 +1,15 @@
#!/usr/bin/env sh
user=""
target="$1"
if [ "$1" = "--user" ]; then
user="--user"
target="$2"
fi
until systemctl $user is-active --quiet "$target"
do
sleep 0.5
done