Merge branch 'master' of git.axenov.dev:anthony/my-env

master
Anthony Axenov 2023-04-12 21:50:46 +08:00
commit 7cc6888cca
Signed by: anthony
GPG Key ID: EA9EC32FF7CCD4EC
5 changed files with 278 additions and 22 deletions

View File

@ -1,4 +1,4 @@
# Autogenerated at 01.02.2023 22:27 using ./gen-makefile
# Autogenerated at 12.04.2023 19:04 using ./gen-makefile
.DEFAULT_GOAL := help
#===============================================
@ -57,11 +57,15 @@ golang:
grubc:
@./install/grubc
##jbmono: Install JetBrains Mono fonts
jbmono:
@./install/jbmono
##kde-appmenu: Install KDE Window AppMenu Applet
kde-appmenu:
@./install/kde-appmenu
##kde-backports: Install KDE Backports + ppa
##kde-backports: Install KDE Backports
kde-backports:
@./install/kde-backports
@ -169,6 +173,10 @@ syncthing:
telebit:
@./install/telebit
##telegram: Install telegram (latest)
telegram:
@./install/telegram
##ulauncher: Install ulauncher (latest) + ppa
ulauncher:
@./install/ulauncher
@ -181,7 +189,7 @@ vivaldi:
wine:
@./install/wine
##youtube-dl: Install youtube-dl
##youtube-dl: Install youtube-dl (src)
youtube-dl:
@./install/youtube-dl
@ -202,7 +210,7 @@ zsh:
# Scripts listed in ./packs
#===============================================
##flameshot: [TODO] qt5 + flameshot from source
##flameshot: [TODO] [PACK] qt5 + flameshot from source
flameshot: qt5 flameshot-build
##lamp: [PACK] Apache + php + mariadb
@ -226,7 +234,7 @@ phpstack: php phptools
# Scripts listed in ./upgrade
#===============================================
# Upgrade omz
##^omz: Upgrade omz
^omz:
@./upgrade/omz
@ -234,19 +242,19 @@ phpstack: php phptools
# Scripts listed in ./uninstall
#===============================================
# Uninstall docker + ppa
##/docker: Uninstall docker + ppa
/docker:
@./uninstall/docker
# Uninstall lite-xl
##/lite-xl: Uninstall lite-xl
/lite-xl:
@./uninstall/lite-xl
# Uninstall omz
##/omz: Uninstall omz
/omz:
@./uninstall/omz
# Uninstall vivaldi + ppa
##/vivaldi: Uninstall vivaldi + ppa
/vivaldi:
@./uninstall/vivaldi
@ -271,8 +279,4 @@ help: Makefile
@echo "\nAvailable GOALs:"
@sed -n 's/^##//p' $< | column -ts ':' | sed -e "s/^/\t/"
+%:
@
^%:
@./upgrade/
@%:
@./uninstall/
@make

View File

@ -47,7 +47,7 @@ for file in ./upgrade/*; do
name=${name%.sh}
desc=$(grep -m 1 -oP "(?<=^##makedesc:\s).*$" ${file})
[ -z "$desc" ] && desc='<no description>'
echo -e "# ${desc}\n${CHR_UPGRADE}${name}:\n\t@${file}\n" >> Makefile
echo -e "##${CHR_UPGRADE}${name}: ${desc}\n${CHR_UPGRADE}${name}:\n\t@${file}\n" >> Makefile
done;
cat << EOF >> Makefile
@ -62,7 +62,7 @@ for file in ./uninstall/*; do
name=${name%.sh}
desc=$(grep -m 1 -oP "(?<=^##makedesc:\s).*$" ${file})
[ -z "$desc" ] && desc='<no description>'
echo -e "# ${desc}\n${CHR_UNINSTALL}${name}:\n\t@${file}\n" >> Makefile
echo -e "##${CHR_UNINSTALL}${name}: ${desc}\n${CHR_UNINSTALL}${name}:\n\t@${file}\n" >> Makefile
done;
cat << EOF >> Makefile
@ -87,11 +87,7 @@ help: Makefile
@echo "\nAvailable GOALs:"
@sed -n 's/^##//p' $< | column -ts ':' | sed -e "s/^/\t/"
+%:
@$(MAKE) $*
^%:
@./upgrade/$*
@%:
@./uninstall/$*
@make $*
EOF
echo "New ./Makefile has been generated!"

196
helpers 100644
View File

@ -0,0 +1,196 @@
#!/bin/bash
installed() {
command -v "$1" >/dev/null 2>&1
}
title() {
[ "$1" ] && title="$1" || title="$(grep -m 1 -oP "(?<=^##makedesc:\s).*$" ${BASH_SOURCE[1]})"
info
info "==============================================="
info "$title"
info "==============================================="
info
}
require() {
if ! installed "$1"; then
if [ "$2" ]; then
die "'$1' must to be installed in your system" 200
else
info "Installing '$1' because it is required to continue"
sudo apt install "$1"
[ $? -gt 0 ] && die "installation cancelled" 201
fi
fi
}
download() {
require wget 1
wget "$1" -O "$2"
}
abspath() {
echo $(realpath -q "${1/#\~/$HOME}")
}
is_writable() {
[ -w "$(abspath $1)" ]
}
is_dir() {
[ -d "$(abspath $1)" ]
}
is_file() {
[ -f "$(abspath $1)" ]
}
is_function() {
declare -F "$1" > /dev/null
}
regex_match() {
printf "%s" "$1" | grep -qP "$2"
}
in_array() {
local find=$1
shift
for e in "$@"; do
[[ "$e" == "$find" ]] && return 0
done
return 1
}
implode() {
local d=${1-}
local f=${2-}
if shift 2; then
printf %s "$f" "${@/#/$d}"
fi
}
IINFO="( i )"
INOTE="( * )"
IWARN="( # )"
IERROR="( ! )"
IFATAL="( @ )"
ISUCCESS="( ! )"
IASK="( ? )"
IDEBUG="(DBG)"
IVRB="( + )"
BOLD="\e[1m"
DIM="\e[2m"
NOTBOLD="\e[22m" # sometimes \e[21m
NOTDIM="\e[22m"
NORMAL="\e[20m"
RESET="\e[0m"
FRESET="\e[39m"
FBLACK="\e[30m"
FWHITE="\e[97m"
FRED="\e[31m"
FGREEN="\e[32m"
FYELLOW="\e[33m"
FBLUE="\e[34m"
FLRED="\e[91m"
FLGREEN="\e[92m"
FLYELLOW="\e[93m"
FLBLUE="\e[94m"
BRESET="\e[49m"
BBLACK="\e[40m"
BWHITE="\e[107m"
BRED="\e[41m"
BGREEN="\e[42m"
BYELLOW="\e[43m"
BBLUE="\e[44m"
BLRED="\e[101m"
BLGREEN="\e[102m"
BLYELLOW="\e[103m"
BLBLUE="\e[104m"
dt() {
echo "[$(date +'%H:%M:%S')] "
}
ask() {
IFS= read -rp "$(print ${BOLD}${BBLUE}${FWHITE}${IASK}${BRESET}\ ${BOLD}$1 ): " $2
}
print() {
echo -e "$*${RESET}"
}
debug() {
if [ "$2" ]; then
print "${DIM}${BOLD}${RESET}${DIM} ${FUNCNAME[1]:-?}():${BASH_LINENO:-?}\t$1 "
else
print "${DIM}${BOLD}${RESET}${DIM}$1 "
fi
}
verbose() {
print "${BOLD}${IVRB}${RESET}${FYELLOW} $1 "
}
info() {
print "${BOLD}${FWHITE}${BLBLUE}${IINFO}${RESET}${FWHITE} $1 "
}
note() {
print "${BOLD}${DIM}${FWHITE}${INOTE}${RESET} $1 "
}
success() {
print "${BOLD}${BGREEN}${FWHITE}${ISUCCESS}${BRESET}$FGREEN $1 "
}
warn() {
print "${BOLD}${BYELLOW}${FBLACK}${IWARN}${BRESET}${FYELLOW} Warning:${RESET} $1 "
}
error() {
print "${BOLD}${BLRED}${FWHITE}${IERROR} Error: ${BRESET}${FLRED} $1 " >&2
# print_stacktrace
}
fatal() {
print "${BOLD}${BRED}${FWHITE}${IFATAL} FATAL: $1 " >&2
print_stacktrace
}
die() {
error "$1"
[ "$2" ] && exit $2 || exit 100
}
die_fatal() {
fatal "$1"
[ "$2" ] && exit $2 || exit 100
}
die_help() {
error "$1"
[ "$2" ] && is_function "$2".help && $2.help
[ "$3" ] && exit $3 || exit 100
}
print_stacktrace() {
STACK=""
local i
local stack_size=${#FUNCNAME[@]}
debug "Callstack:"
# for (( i=$stack_size-1; i>=1; i-- )); do
for (( i=1; i<$stack_size; i++ )); do
local func="${FUNCNAME[$i]}"
[ x$func = x ] && func=MAIN
local linen="${BASH_LINENO[$(( i - 1 ))]}"
local src="${BASH_SOURCE[$i]}"
[ x"$src" = x ] && src=non_file_source
debug " at $func $src:$linen"
done
}

14
install/jbmono 100755
View File

@ -0,0 +1,14 @@
#!/bin/bash
##makedesc: Install JetBrains Mono fonts
[ -f `dirname $0`/../helpers ] && source `dirname $0`/../helpers || exit 255
# https://www.jetbrains.com/lp/mono/#how-to-install
title
require unzip
mkdir -p "$HOME/install/jbmono" "$HOME/.local/share/fonts/"
download "https://download.jetbrains.com/fonts/JetBrainsMono-2.304.zip" "$HOME/install/jbmono.zip" && \
unzip -oj "$HOME/install/jbmono.zip" "fonts/ttf/*.ttf" -d "$HOME/.local/share/fonts/" && \
fc-cache -vf "$HOME/.local/share/fonts/"

View File

@ -1,4 +1,50 @@
#!/bin/bash
# https://obsproject.com/kb/virtual-camera-troubleshooting
# https://obsproject.com/forum/threads/how-to-start-virtual-camera-without-sudo-privileges.139783/
sudo modprobe v4l2loopback video_nr=2 card_label="OBS Virtual Camera"
# https://blog.csdn.net/qq_43008667/article/details/128041455
# https://blog.jbrains.ca/permalink/using-obs-studio-as-a-virtual-cam-on-linux
# https://github.com/obsproject/obs-studio/issues/4808
# v4l2loopback-dkms
# obs_start()
# {
# #This function is intended to prevent blank cameras in OBS upon OBS restart / exit
# #1. load/refresh uvcvideo before starting obs
# if lsmod | grep -q 'uvcvideo'; then
# sudo rmmod uvcvideo
# fi
# sudo modprobe uvcvideo
# #2. since no environment with a keyring to prompt for allowing virtual webcams prior is a must
# sudo modprobe v4l2loopback video_nr=10 card_label='OBS Virtual Camera'
# sleep 1
# sh -c "$obs_cmd --startvirtualcam || sleep 3; sudo rmmod uvcvideo"
# }
installed () {
command -v $1 > /dev/null
}
installed 'obs' && obs_cmd='obs'
installed 'obs-studio' && obs_cmd='obs-studio'
# obs executes this command when you start virtual camera
# sudo modprobe v4l2loopback exclusive_caps=1 card_label="OBS Virtual Camera"
# another version from one of links below
# sudo modprobe v4l2loopback video_nr=2 devices=1 card_label="OBS Virtual Camera"
sudo modprobe -r v4l2loopback || sudo rmmod v4l2loopback
if [[ $? == 0 ]]; then
sudo modprobe v4l2loopback video_nr=2 devices=1 card_label="OBS Virtual Camera"
if [[ $? == 0 ]]; then
$obs_cmd --startvirtualcam & disown
else
echo "Cannot run modprobe. Ensure v4l2loopback-dkms is installed and try again"
exit 1
fi
else
echo "Cannot remove v4l2loopback device"
exit 2
fi