Initial commit

This commit is contained in:
Victor Timofei 2023-06-03 15:15:49 +03:00
commit 401333b4ed
Signed by: vtimofei
GPG Key ID: B790DCEBE281403A
22 changed files with 259 additions and 0 deletions

6
bt-restart Executable file
View File

@ -0,0 +1,6 @@
#!/usr/bin/bash
rfkill block bluetooth
rfkill unblock bluetooth
sudo systemctl stop bluetooth.service
sudo systemctl start bluetooth.service

View File

@ -0,0 +1,13 @@
#/usr/bin/env bash
_docker-clear-log()
{
if [ "${#COMP_WORDS[@]}" != "2" ]; then
return
fi
all_container_names=$(docker ps --all --format "{{.Names}}")
COMPREPLY=($(compgen -W "$all_container_names" "${COMP_WORDS[1]}"))
}
complete -F _docker-clear-log docker-clear-log

1
completion/git-df.bash Normal file
View File

@ -0,0 +1 @@
complete -o bashdefault -o default -o nospace -F __git_wrap__git_main git-df

21
docker-clear-log Executable file
View File

@ -0,0 +1,21 @@
#!/bin/bash -e
CONTAINER=$1
if [[ -z $CONTAINER ]]; then
echo "No container specified"
exit 1
fi
if [[ "$(docker ps -aq -f name=^/"$CONTAINER"$ 2> /dev/null)" == "" ]]; then
CONTAINER="$(docker-compose ps "$CONTAINER" 2> /dev/null | awk 'END {print $1}')"
if [[ -z $CONTAINER ]]; then
echo "Container \"$1\" does not exist, exiting."
exit 1
fi
fi
LOG=$(docker inspect -f '{{.LogPath}}' "$CONTAINER" 2> /dev/null)
truncate -s 0 "$LOG"

3
docker-rm-all Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
docker ps -a | awk '{ if (NR>1) system("docker rm " $1) }'

3
docker-rm-images Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
docker images | awk '{ if (NR>1) system("docker image rm " $3) }'

13
get-layout Executable file
View File

@ -0,0 +1,13 @@
#!/bin/bash
layout=$(setxkbmap -print -verbose 7 | grep layout: | awk '{print $2}')
variant=$(setxkbmap -print -verbose 7 | grep variant: | awk '{print $2}')
if [[ $variant == "" ]]; then
output="${layout}"
else
output="${layout}-${variant}"
fi
echo $output

3
getvol Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh
pactl list sinks | grep Volume | awk 'NR==1{print $5}'

8
laptopkb-disable Executable file
View File

@ -0,0 +1,8 @@
#!/bin/bash
# Written by Eric Ma (https://www.ericzma.com)
id=$(laptopkb-get-id)
xinput float $id

8
laptopkb-enable Executable file
View File

@ -0,0 +1,8 @@
#!/bin/bash
# Written by Eric Ma (https://www.ericzma.com)
id=$(laptopkb-get-id)
xinput reattach $id 3

5
laptopkb-get-id Executable file
View File

@ -0,0 +1,5 @@
#!/bin/bash
# Written by Eric Ma (https://www.ericzma.com)
xinput list | grep 'AT Translated Set' | cut -f2 | cut -d'=' -f2

8
laptoptouch-disable Executable file
View File

@ -0,0 +1,8 @@
#!/bin/bash
# Written by Eric Ma (https://www.ericzma.com)
id=$(laptopkb-get-id)
xinput float "$(laptoptouch-get-id)"

3
laptoptouch-get-id Executable file
View File

@ -0,0 +1,3 @@
#!/usr/bin/env bash
xinput list | grep 'Touchpad' | cut -f2 | cut -d'=' -f2

3
lock_screen Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
xscreensaver-command -lock

5
mutetog Executable file
View File

@ -0,0 +1,5 @@
#!/bin/sh
pactl set-sink-mute @DEFAULT_SINK@ toggle
kill -46 $(pidof dwmblocks)

7
poweroff Executable file
View File

@ -0,0 +1,7 @@
#!/bin/bash
ans=$(printf "no\nyes" | dmenu -p "Shutdown?")
if [ "$ans" = "yes" ]; then
/bin/poweroff
fi

7
reboot Executable file
View File

@ -0,0 +1,7 @@
#!/bin/bash
ans=$(printf "no\nyes" | dmenu -p "Reboot?")
if [ "$ans" = "yes" ]; then
/usr/bin/reboot
fi

18
toggle-language Executable file
View File

@ -0,0 +1,18 @@
#!/bin/bash
layout=$(setxkbmap -print -verbose 7 | grep layout: | awk '{print $2}')
variant=$(setxkbmap -print -verbose 7 | grep variant: | awk '{print $2}')
dvorak='enabled'
if [[ $layout == "us" ]]; then
if [[ $dvorak == "enabled" ]]; then
setxkbmap gr-dvk
else
setxkbmap gr
fi
else
setxkbmap us dvp
fi
kill -45 "$(pidof dwmblocks)"

105
va2-capture Executable file
View File

@ -0,0 +1,105 @@
#!/bin/bash
set -x
monitor="HDMI1"
xrandr_out="$(xrandr)"
output="/tmp/vid.mkv"
find_device_info() {
pactl list sources \
| grep "Name: ${1}" -A3
}
parse_device_name() {
echo "${1}" \
| grep Name \
| awk '{print $2}'
}
parse_channels() {
echo "${1}" \
| grep 'Sample Specification' \
| awk '{print $4}' \
| sed 's/ch//'
}
parse_rate() {
echo "${1}" \
| grep 'Sample Specification' \
| awk '{print $5}' \
| sed 's/Hz//'
}
find_monitor_info() {
dev="${2}"
echo "${1}" \
| awk "BEGIN {found = \"false\"}
/^${dev}/ {found = \"true\"; print \$0; next}
/^[[:space:]]/ {if (found == \"true\") {print \$0} }
/^\w/ {if (found == \"true\") {exit 0}}"
}
get_monitor_size() {
dev="${2}"
echo "${1}" \
| awk "/^${dev}.*primary/ {print \$4; exit}
/^${dev}/ {print \$3; exit}" \
| sed 's/^\([[:digit:]]*x[[:digit:]]*\).*/\1/'
}
get_monitor_pos() {
dev="${2}"
echo "${1}" \
| awk "/^${dev}.*primary/ {print \$4; exit}
/^${dev}/ {print \$3; exit}" \
| sed 's/.*\([[:digit:]]+[[:digit:]]*\)/\1/' \
| sed 's/+/,/'
}
get_monitor_rate() {
echo "${1}" \
| awk '/*/ {print $2}' \
| sed 's/\([[:digit:]]\+\).*/\1/'
}
get_screen_number() {
echo "${1}" \
| awk '/Screen / {print $2; exit 0}' \
| sed 's/://'
}
get_minimum() {
echo "${*}" \
sed 's/ /\n/g' \
| awk "BEGIN {min = 1000000000}
{if (\$1 < min) {min = \$1}}
END {print min}"
}
odev_info=$(find_device_info "alsa_output")
odev=$(parse_device_name "${odev_info}")
odev_c=$(parse_channels "${odev_info}")
odev_r=$(parse_rate "${odev_info}")
idev_info=$(find_device_info "alsa_input")
idev=$(parse_device_name "${idev_info}")
idev_c=$(parse_channels "${idev_info}")
idev_r=$(parse_rate "${idev_info}")
min_sound_r=$(get_minimum "${odev_r}" "${idev_r}")
mon_info=$(find_monitor_info "${xrandr_out}" "${monitor}")
mon_s=$(get_monitor_size "${mon_info}" "${monitor}")
mon_p=$(get_monitor_pos "${mon_info}" "${monitor}")
mon_r=$(get_monitor_rate "${mon_info}")
screen=$(get_screen_number "${xrandr_out}")
ffmpeg -f pulse -ac "${odev_c}" -ar "${odev_r}" -i "${odev}" \
-f pulse -ac "${idev_c}" -ar "${idev_r}" -i "${idev}" \
-filter_complex amix=inputs=2 \
-f x11grab -s "${mon_s}" -r "${mon_r}" -probesize 100M -i "${DISPLAY}.${screen}+${mon_p}" \
-vcodec libx264 -preset veryfast -crf 18 \
-acodec libmp3lame -ar "${min_sound_r}" \
"${output}"

5
voldown Executable file
View File

@ -0,0 +1,5 @@
#!/bin/sh
pactl set-sink-volume @DEFAULT_SINK@ -5%
kill -46 $(pidof dwmblocks)

9
volinfo Executable file
View File

@ -0,0 +1,9 @@
#!/bin/sh
muted="$(pactl list sinks | grep "Mute" | awk '{print $2}')"
if [ "$muted" = 'no' ]; then
echo " $(/home/vtimofei/scripts/getvol)"
else
echo " $(/home/vtimofei/scripts/getvol)"
fi

5
volup Executable file
View File

@ -0,0 +1,5 @@
#!/bin/sh
pactl set-sink-volume @DEFAULT_SINK@ +5%
kill -46 $(pidof dwmblocks)