cumulative update

This commit is contained in:
Arthur Khachaturov 2024-06-19 11:51:19 +03:00
parent 3ecbac352e
commit c360fc2339
71 changed files with 3281 additions and 380 deletions

View file

@ -1,8 +0,0 @@
#!/bin/bash
read -p "Date: " date
export GIT_AUTHOR_DATE="${date}"
export GIT_COMMITTER_DATE="${date}"
git $@

72
.local/scripts/_venv Normal file
View file

@ -0,0 +1,72 @@
VENV_FOLDER=".venv"
OPERATION=c
deactivate_() {
if [ ! -z "${VIRTUAL_ENV}" ]; then
deactivate
fi
}
create_or_activate() {
if [ -z "${VIRTUAL_ENV}" ]; then
if [ -d "${VENV_FOLDER}" ]; then
source ./${VENV_FOLDER}/bin/activate
else
python3 -m venv "${VENV_FOLDER}"
source ./${VENV_FOLDER}/bin/activate
fi
else
deactivate
fi
}
remove() {
deactivate_
if [ -d "${VENV_FOLDER}" ]; then
rm -r "${VENV_FOLDER}"
fi
}
while [ "$#" -gt 0 ]; do
case "$1" in
'-c'|"--create")
OPERATION=c
;;
'-r'|"--remove")
OPERATION=r
;;
'-d'|"--deactivate")
deactivate_
return
;;
'-h'|"--help")
echo "venv [OPTION] [VENV_FOLDER]"
echo
echo "ARGUMENTS:"
echo "\t VENV_FOLDER \t\t Folder containing virtual environment"
echo
echo "OPTIONS:"
echo "\t -c, --create \t\t Create virtual environment"
echo "\t -d, --deactivate \t Exit virtual environment"
echo "\t -r, --remove \t\t Deactivate and remove virtual environment"
echo "\t -h, --help \t\t Print this message"
return
;;
*)
VENV_FOLDER="$1"
;;
esac
shift
done
case "${OPERATION}" in
c) create_or_activate;;
r) remove;;
esac
# vim: set ft=sh

45
.local/scripts/cast Executable file
View file

@ -0,0 +1,45 @@
#!/bin/bash
PIDFILE="${XDG_RUNTIME_DIR}/mkchromecast.pid"
WIDTH=1440
HEIGHT=1080
ASPECT_OFFSET=240
OUTPUT_NAME='DVI-I-1-1'
command() {
echo "ffmpeg -ac 2 -ar 44100 -frame_size 2048 -fragment_size 2048 -f pulse -ac 2 -i Mkchromecast.monitor -f x11grab -r 30 -s ${WIDTH}x${HEIGHT} -i :0.0+$1,0 -vcodec libx264 -preset veryfast -tune zerolatency -maxrate 10000k -bufsize 20000k -pix_fmt yuv420p -g 60 -f mp4 -vf scale=1280:720 -movflags frag_keyframe+empty_moov -ar 44100 -acodec libvorbis pipe:1"
}
set -x
cleanup() {
xrandr --output DVI-I-1-1 --off
pid="$(cat ${PIDFILE})"
rm "${PIDFILE}"
pkill -35 dwmblocks
kill -INT "${pid}"
}
run() {
xrandr --setprovideroutputsource 1 0
xrandr --addmode DVI-I-1-1 1920x1080
xrandr --output ${OUTPUT_NAME} --mode 1920x1080 --rate 60 --right-of eDP-1
echo $$ > "${PIDFILE}"
pkill -35 dwmblocks
offset=$(( "$(xrandr | grep DVI | cut -d ' ' -f 3 | cut -d '+' -f 2)" + ${ASPECT_OFFSET} ))
systemd-inhibit --what=handle-lid-switch sleep 2592000 &
exec mkchromecast --video --command "$(command ${offset})"
}
if [ "$1" = "-k" ]; then
cleanup
exit 0
fi
if [ -f "${PIDFILE}" ]; then
cleanup || run
else
run
fi

3
.local/scripts/dmenu_askpass Executable file
View file

@ -0,0 +1,3 @@
#!/bin/bash
echo $(dmenu -p "$1" -nf '#3a3a3a' <&-)

34
.local/scripts/dual_monitor Executable file
View file

@ -0,0 +1,34 @@
#!/bin/bash
MODELINE=$(cvt 4120 1440 144 | tail -1 | cut -d " " -f 2- | tr -d '"')
RES="$(echo $MODELINE | cut -d ' ' -f 1 | tr -d '\"')"
OUTPUT="DVI-I-1-1"
create() {
xrandr --newmode $(echo $MODELINE)
xrandr --addmode ${OUTPUT} "${RES}"
xrandr --output ${OUTPUT} --mode "${RES}"
}
remove() {
xrandr --output ${OUTPUT} --off
xrandr --delmode ${OUTPUT} "${RES}"
xrandr --rmmode "${RES}"
}
create_or_remove() {
if [ ! -z "$(xrandr | grep ${RES} | grep '*')" ]; then
remove
else
create
fi
}
case "$1" in
'-c'|'--create') create
;;
'-d'|'--delete') remove
;;
*) create_or_remove
;;
esac

14
.local/scripts/gdt Executable file
View file

@ -0,0 +1,14 @@
#!/bin/bash
if [ ! -d .git ]; then
echo "missing .git dir!"
exit 1
fi
echo "Last commit: $(git log | grep 'Date' | cut -d ' ' -f 4- | head -1)"
read -p "Date: " date
export GIT_AUTHOR_DATE="${date}"
export GIT_COMMITTER_DATE="${date}"
git "$@"

44
.local/scripts/vpn Executable file
View file

@ -0,0 +1,44 @@
#!/bin/bash
IFNAME="wg_swe"
while [ "$#" -gt 0 ]; do
case "$1" in
'd'|'-d'|'--dpi') DPI="_d"
;;
'm'|'msk') IFNAME='wg_msk'
;;
'-v'|'--verbose') VERBOSE=1
;;
'--visual') USE_TERMINAL=1
;;
*) echo "Wrong argument!"; exit 1
;;
esac
shift
done
if [ -z "${VERBOSE}" ]; then
exec &>/dev/null
else
set -x
fi
UP_NAME="$(ip link show | grep 'wg' | cut -d ' ' -f 2 | sed 's/://')"
sudo_a() {
dmenu -p "$1" <&-
}
if [ ! -z "${USE_TERMINAL}" ]; then
LAUNCH_CMD=(sudo -A -p "Password:")
fi
if [ -z "${UP_NAME}" ]; then
IFNAME="${IFNAME}${DPI}"
${LAUNCH_CMD[@]} wg-quick up ${IFNAME}
else
${LAUNCH_CMD[@]} wg-quick down ${UP_NAME}
fi
pkill -36 dwmblocks

39
.local/scripts/xr Executable file
View file

@ -0,0 +1,39 @@
#!/bin/bash
# supress stderr
exec 2> /dev/null
change_dpi() {
sed -i -E "s/Xft\.dpi: .*?/Xft\.dpi: $1/g" ~/.Xresources
sed -i -E "s/Xcursor\.size: .*?/Xcursor\.size: $2/g" ~/.Xresources
sed -i -E "s/gtk-cursor-theme-size=.*?/gtk-cursor-theme-size=$2/g" ~/.config/gtk-3.0/settings.ini
sed -i -E "s/gtk-cursor-theme-size=.*?/gtk-cursor-theme-size=$2/g" ~/.gtkrc-2.0
echo "Xft/DPI $(expr $1 \* 1024)" > ~/.xsettingsd
echo "Gtk/CursorThemeSize $2" >> ~/.xsettingsd
xrdb -merge ~/.Xresources
killall -HUP dwm
killall -HUP xsettingsd
}
EXT_MON="$(xrandr | grep -ow "\(DP-[0-9]\) connected" | cut -d " " -f 1)"
INT_MODELINE=$(cvt 1560 1040 90 | grep "Modeline" | cut -d " " -f 2- | tr -d '"')
INT_RES="$(echo $INT_MODELINE | cut -d ' ' -f 1 | tr -d '\"')"
if [[ -z "${EXT_MON}" ]]; then
xrandr --delmode eDP-1 "${INT_RES}"
xrandr --rmmode "${INT_RES}"
xrandr --output eDP-1 --pos 0x0 --mode "3120x2080" --rate 90 --primary --output DP-1 --off --output DP-2 --off --output DP-3 --off --output DP-4 --off
change_dpi 192 48
else
xrandr --rmmode "${INT_RES}"
xrandr --newmode $(echo $INT_MODELINE)
xrandr --addmode eDP-1 "${INT_RES}"
xrandr --output eDP-1 --pos 2560x400 --mode "${INT_RES}" --output ${EXT_MON} --pos 0x0 --mode "2560x1440" --rate 144 --primary
change_dpi 96 24
fi
${HOME}/.config/X11/autostart

View file

@ -1,139 +0,0 @@
### Languages
# C++
*.d
*.slo
*.lo
*.o
*.obj
*.gch
*.pch
*.so
*.dylib
*.dll
*.mod
*.smod
*.lai
*.la
*.a
*.lib
*.exe
*.out
*.app
# Python
__pycache__/
*.py[cod]
*$py.class
*.so
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
*.manifest
*.spec
pip-log.txt
pip-delete-this-directory.txt
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/
*.mo
*.pot
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
instance/
.webassets-cache
.scrapy
docs/_build/
.pybuilder/
target/
.ipynb_checkpoints
profile_default/
ipython_config.py
.pdm.toml
__pypackages__/
celerybeat-schedule
celerybeat.pid
*.sage.py
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
.spyderproject
.spyproject
.ropeproject
/site
.mypy_cache/
.dmypy.json
dmypy.json
.pyre/
.pytype/
cython_debug/
poetry.toml
.ruff_cache/
pyrightconfig.json
### IDE
# JetBrains
.idea
*.iws
.idea_modules/
atlassian-ide-plugin.xml
.idea/replstate.xml
.idea/sonarlint/
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
.idea/httpRequests
.idea/caches/build_file_checksums.ser
# VSCode
.vscode/*
.history/
*.vsix
.ionide
# CMake
cmake-build-*/
.cache/
CMakeLists.txt.user
CMakeCache.txt
CMakeFiles
CMakeScripts
Testing
Makefile
cmake_install.cmake
install_manifest.txt
compile_commands.json
CTestTestfile.cmake
_deps
*-prefix/

@ -1 +0,0 @@
Subproject commit 99469c4a9b1ccf77fade25842dc7bafbc8ce9946

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

18
.local/statusbar/sb-battery Executable file
View file

@ -0,0 +1,18 @@
#!/bin/bash
for battery in /sys/class/power_supply/BAT?*; do
[ -n "${capacity+x}" ] && printf " "
case "$(cat "$battery/status" 2>&1)" in
"Full") status="⚡ " ;;
"Discharging") status="🔋" ;;
"Charging") status="🔌" ;;
"Not charging") status="🛑" ;;
"Unknown") status="♻️" ;;
*) exit 1 ;;
esac
capacity="$(cat "$battery/capacity" 2>&1)"
# Will make a warn variable if discharging and low
[ "$status" = "🔋" ] && [ "$capacity" -le 25 ] && warn="❗"
# Prints the info
printf "%s%s%d%%" "$status" "$warn" "$capacity"; unset warn
done && printf "\\n"

7
.local/statusbar/sb-cast Executable file
View file

@ -0,0 +1,7 @@
#!/bin/bash
PIDFILE="${XDG_RUNTIME_DIR}/mkchromecast.pid"
if [ -f "${PIDFILE}" ]; then
printf "🔴 Casting"
fi

7
.local/statusbar/sb-vpn Executable file
View file

@ -0,0 +1,7 @@
#!/bin/bash
IFNAME="$(ip link show | grep 'wg_' | cut -d ' ' -f 2 | sed 's/://' | sed 's/wg_//' | tr '[:lower:]' '[:upper:]' | sed 's/_D/ (dpi)/')"
if [ ! -z "${IFNAME}" ]; then
echo "🛡️ ${IFNAME}"
fi