This commit is contained in:
Yuri Zamyatin 2024-12-15 23:37:24 +00:00
commit 2bae9747c9
19 changed files with 706 additions and 0 deletions

10
README.md Normal file
View File

@ -0,0 +1,10 @@
# Workspace
My scripts and configuration.
Built with multi-user and multi-machine setup in mind (assuming you are in charge).
- arch-root/ - administrative pc stuff related to hardware, packages, login management, group flow, roaming, etc.
- arch-user/ - all the pc session stuff including window management that reflect my preferences as a user. Tiling wm, colemak, minimalism, vi bindings everywhere.
- deb-vps/
- android/

75
arch-root/install.sh Normal file
View File

@ -0,0 +1,75 @@
#!/bin/bash
set -e
PACKAGES=(
# system
base apparmor lvm2 greetd sudo # system
openssh networkmanager man-db restic htop # admin utils
# cli programs
vifm vim # navigation & editors
dash shellcheck # shell scripting
hugo miniserve neomutt # www
gnupg pass pass-otp # crypt
git zip # others
# desktop env
sway swaybg xorg-xwayland # basic
foot bemenu-wayland i3blocks mako # terminals, ui
xorg-xev wl-clipboard slurp grim # interaction
ttf-roboto ttf-roboto-mono # fonts
# gui apps
imv mpv gimp # media
firefox sqlitebrowser qt5-wayland
# extensions
firefox-tridactyl vim-ale vim-fugitive
)
file_has_line() {
grep -qxF "$2" "$1" || echo "$2" >> "$1"
}
[ "$(id -u)" != "0" ] && echo "ERROR: root required" >&2 && exit 1
pacman -Syu
pacman -S --needed "${PACKAGES[@]}"
pacman -S --needed brightnessctl sof-firmware intel-media-driver intel-ucode
file_has_line "/etc/profile" "umask 002"
while read -r entity; do
# group <name> <id>
# user <name> <id> [<secondary groups>...]
read -ra entity_parts <<< "$entity"
etype="${entity_parts[0]}"
ename="${entity_parts[1]}"
eid="${entity_parts[2]}"
[ "$etype" != "user" ] && [ "$etype" != "group" ] && echo "ERROR: bad entity type" >&2 && exit 1
# every user has their own primary group with id matching uid,
# so for each entry we need a usergroup
if [ -z "$(getent group "$eid")" ]; then
echo "Creating group \"$ename\", id=$eid"
groupadd --gid "$eid" "$ename"
fi
if [ "$etype" = "user" ]; then
if ! id "$eid" >/dev/null 2>&1; then
echo "Creating user \"$ename\", id=$eid"
useradd --gid "$eid" --uid "$eid" -m "$ename"
fi
usermod -aG "$(IFS=,; echo "${entity_parts[*]:3}")" "$ename"
else # group
if [[ "$ename" == share-* ]]; then
echo "Creating shared dir $ename"
mkdir -p "/home/$ename"
chgrp "$ename" -R "/home/$ename"
chmod u=rwX,g=rwX,o= -R "/home/$ename"
find "/home/$ename" -type d -print0 | xargs -0 chmod g+s
fi
fi
done </root/users.conf

View File

@ -0,0 +1,15 @@
#!/bin/bash
[[ $- != *i* ]] && return
alias ls='ls --color=auto'
alias grep='grep --color=auto'
unset SSH_AGENT_PID
if [ "${gnupg_SSH_AUTH_SOCK_by:-0}" -ne $$ ]; then
export SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)"
fi
export GPG_TTY=$(tty)
gpg-connect-agent updatestartuptty /bye >/dev/null
PS1='\u@\h:\w> '

View File

@ -0,0 +1,2 @@
#!/bin/sh
export BEMENU_OPTS="--ignorecase --width-factor 0.5 --fn \"Roboto Mono 14\" --list 500 --border 1 --scrollbar autohide --bdr #9988ff --nb #0d1117d9 --ab #0d1117d9"

View File

@ -0,0 +1,255 @@
# -*- conf -*-
# shell=$SHELL (if set, otherwise user's default shell from /etc/passwd)
# term=foot (or xterm-256color if built with -Dterminfo=disabled)
# login-shell=no
# app-id=foot # globally set wayland app-id. Default values are "foot" and "footclient" for desktop and server mode
# title=foot
# locked-title=no
font=Roboto Mono:size=12
# font-bold=<bold variant of regular font>
# font-italic=<italic variant of regular font>
# font-bold-italic=<bold+italic variant of regular font>
# font-size-adjustment=0.5
# line-height=<font metrics>
# letter-spacing=0
# horizontal-letter-offset=0
# vertical-letter-offset=0
# underline-offset=<font metrics>
# underline-thickness=<font underline thickness>
# strikeout-thickness=<font strikeout thickness>
# box-drawings-uses-font-glyphs=no
# dpi-aware=no
# initial-window-size-pixels=700x500 # Or,
# initial-window-size-chars=<COLSxROWS>
# initial-window-mode=windowed
# pad=0x0 # optionally append 'center'
# resize-by-cells=yes
# resize-keep-grid=yes
# resize-delay-ms=100
# bold-text-in-bright=no
# word-delimiters=,│`|:"'()[]{}<>
# selection-target=primary
# workers=<number of logical CPUs>
# utmp-helper=/usr/lib/utempter/utempter # When utmp backend is libutempter (Linux)
# utmp-helper=/usr/libexec/ulog-helper # When utmp backend is ulog (FreeBSD)
[environment]
# name=value
[bell]
# urgent=no
# notify=no
# visual=no
# command=
# command-focused=no
[desktop-notifications]
# command=notify-send --wait --app-name ${app-id} --icon ${app-id} --category ${category} --urgency ${urgency} --expire-time ${expire-time} --hint STRING:image-path:${icon} --hint BOOLEAN:suppress-sound:${muted} --hint STRING:sound-name:${sound-name} --replace-id ${replace-id} ${action-argument} --print-id -- ${title} ${body}
# command-action-argument=--action ${action-name}=${action-label}
# close=""
# inhibit-when-focused=yes
[scrollback]
# lines=1000
# multiplier=3.0
# indicator-position=relative
# indicator-format=""
[url]
# launch=xdg-open ${url}
# label-letters=sadfjklewcmpgh
# osc8-underline=url-mode
# protocols=http, https, ftp, ftps, file, gemini, gopher
# uri-characters=abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.,~:;/?#@!$&%*+="'()[]
[cursor]
# style=block
# color=<inverse foreground/background>
# blink=no
# blink-rate=500
# beam-thickness=1.5
# underline-thickness=<font underline thickness>
[mouse]
# hide-when-typing=no
# alternate-scroll-mode=yes
[touch]
# long-press-delay=400
[colors]
# alpha=1.0
background=0d1117
# foreground=ffffff
# flash=7f7f00
# flash-alpha=0.5
## Normal/regular colors (color palette 0-7)
# regular0=242424 # black
# regular1=f62b5a # red
# regular2=47b413 # green
# regular3=e3c401 # yellow
# regular4=24acd4 # blue
# regular5=f2affd # magenta
# regular6=13c299 # cyan
# regular7=e6e6e6 # white
## Bright colors (color palette 8-15)
# bright0=616161 # bright black
# bright1=ff4d51 # bright red
# bright2=35d450 # bright green
# bright3=e9e836 # bright yellow
# bright4=5dc5f8 # bright blue
# bright5=feabf2 # bright magenta
# bright6=24dfc4 # bright cyan
# bright7=ffffff # bright white
## dimmed colors (see foot.ini(5) man page)
# dim0=<not set>
# ...
# dim7=<not-set>
## The remaining 256-color palette
# 16 = <256-color palette #16>
# ...
# 255 = <256-color palette #255>
## Sixel colors
# sixel0 = 000000
# sixel1 = 3333cc
# sixel2 = cc2121
# sixel3 = 33cc33
# sixel4 = cc33cc
# sixel5 = 33cccc
# sixel6 = cccc33
# sixel7 = 878787
# sixel8 = 424242
# sixel9 = 545499
# sixel10 = 994242
# sixel11 = 549954
# sixel12 = 995499
# sixel13 = 549999
# sixel14 = 999954
# sixel15 = cccccc
## Misc colors
# selection-foreground=<inverse foreground/background>
# selection-background=<inverse foreground/background>
# jump-labels=<regular0> <regular3> # black-on-yellow
# scrollback-indicator=<regular0> <bright4> # black-on-bright-blue
# search-box-no-match=<regular0> <regular1> # black-on-red
# search-box-match=<regular0> <regular3> # black-on-yellow
# urls=<regular3>
[csd]
# preferred=server
# size=26
# font=<primary font>
# color=<foreground color>
# hide-when-maximized=no
# double-click-to-maximize=yes
# border-width=0
# border-color=<csd.color>
# button-width=26
# button-color=<background color>
# button-minimize-color=<regular4>
# button-maximize-color=<regular2>
# button-close-color=<regular1>
[key-bindings]
# scrollback-up-page=Shift+Page_Up
# scrollback-up-half-page=none
# scrollback-up-line=none
# scrollback-down-page=Shift+Page_Down
# scrollback-down-half-page=none
# scrollback-down-line=none
# scrollback-home=none
# scrollback-end=none
# clipboard-copy=Control+Shift+c XF86Copy
# clipboard-paste=Control+Shift+v XF86Paste
# primary-paste=Shift+Insert
# search-start=Control+Shift+r
# font-increase=Control+plus Control+equal Control+KP_Add
# font-decrease=Control+minus Control+KP_Subtract
# font-reset=Control+0 Control+KP_0
# spawn-terminal=Control+Shift+n
# minimize=none
# maximize=none
# fullscreen=none
# pipe-visible=[sh -c "xurls | fuzzel | xargs -r firefox"] none
# pipe-scrollback=[sh -c "xurls | fuzzel | xargs -r firefox"] none
# pipe-selected=[xargs -r firefox] none
# pipe-command-output=[wl-copy] none # Copy last command's output to the clipboard
# show-urls-launch=Control+Shift+o
# show-urls-copy=none
# show-urls-persistent=none
# prompt-prev=Control+Shift+z
# prompt-next=Control+Shift+x
# unicode-input=Control+Shift+u
# noop=none
[search-bindings]
# cancel=Control+g Control+c Escape
# commit=Return
# find-prev=Control+r
# find-next=Control+s
# cursor-left=Left Control+b
# cursor-left-word=Control+Left Mod1+b
# cursor-right=Right Control+f
# cursor-right-word=Control+Right Mod1+f
# cursor-home=Home Control+a
# cursor-end=End Control+e
# delete-prev=BackSpace
# delete-prev-word=Mod1+BackSpace Control+BackSpace
# delete-next=Delete
# delete-next-word=Mod1+d Control+Delete
# extend-char=Shift+Right
# extend-to-word-boundary=Control+w Control+Shift+Right
# extend-to-next-whitespace=Control+Shift+w
# extend-line-down=Shift+Down
# extend-backward-char=Shift+Left
# extend-backward-to-word-boundary=Control+Shift+Left
# extend-backward-to-next-whitespace=none
# extend-line-up=Shift+Up
# clipboard-paste=Control+v Control+Shift+v Control+y XF86Paste
# primary-paste=Shift+Insert
# unicode-input=none
# quit=none
# scrollback-up-page=Shift+Page_Up
# scrollback-up-half-page=none
# scrollback-up-line=none
# scrollback-down-page=Shift+Page_Down
# scrollback-down-half-page=none
# scrollback-down-line=none
# scrollback-home=none
# scrollback-end=none
[url-bindings]
# cancel=Control+g Control+c Control+d Escape
# toggle-url-visible=t
[text-bindings]
# \x03=Mod4+c # Map Super+c -> Ctrl+c
[mouse-bindings]
# scrollback-up-mouse=BTN_WHEEL_BACK
# scrollback-down-mouse=BTN_WHEEL_FORWARD
# font-increase=Control+BTN_WHEEL_BACK
# font-decrease=Control+BTN_WHEEL_FORWARD
# selection-override-modifiers=Shift
# primary-paste=BTN_MIDDLE
# select-begin=BTN_LEFT
# select-begin-block=Control+BTN_LEFT
# select-extend=BTN_RIGHT
# select-extend-character-wise=Control+BTN_RIGHT
# select-word=BTN_LEFT-2
# select-word-whitespace=Control+BTN_LEFT-2
# select-quote = BTN_LEFT-3
# select-row=BTN_LEFT-4
# vim: ft=dosini

View File

@ -0,0 +1,7 @@
[user]
email = yuri@yrz.am
name = Yuri Zamyatin
[init]
defaultBranch = main
[pull]
rebase = false

View File

@ -0,0 +1,12 @@
#!/bin/sh
set -- /sys/class/power_supply/*/capacity;
read cap < "$1"
read st < "/sys/class/power_supply/ACAD/online" || true
if [ "$st" = "1" ]; then
echo "⚡$cap▴"
else
echo "⚡$cap▾"
[ "$cap" -lt "15" ] && exit 33
fi

View File

@ -0,0 +1,10 @@
separator_block_width=15
[batterybar]
command=~/.config/i3blocks/battery
interval=10
[time]
command=date +"%Y-%m-%dT%H:%M:%SZ"
interval=1

4
arch-user/config/profile Normal file
View File

@ -0,0 +1,4 @@
#!/bin/bash
export SESSION_START_COMMAND=sway
export PATH=$PATH:~/scripts

View File

@ -0,0 +1,98 @@
# vim: filetype=swayconfig
set $mod Mod4
set $left n
set $down e
set $up i
set $right o
################ inputs ####################
input "type:keyboard" {
xkb_layout us(colemak_yz),us(basic),ru
}
bindsym $mod+0 input "type:keyboard" xkb_switch_layout next
input "type:touchpad" {
dwt enabled
tap enabled
natural_scroll enabled
middle_emulation enabled
}
############################################
############### workspaces #################
bindsym --to-code $mod+x workspace x
bindsym --to-code $mod+c workspace c
bindsym --to-code $mod+d workspace d
bindsym --to-code $mod+v workspace v
bindsym --to-code $mod+z workspace z
bindsym --to-code $mod+k workspace k
bindsym --to-code $mod+h workspace h
bindsym --to-code $mod+Control+x move container to workspace x
bindsym --to-code $mod+Control+c move container to workspace c
bindsym --to-code $mod+Control+d move container to workspace d
bindsym --to-code $mod+Control+v move container to workspace v
bindsym --to-code $mod+Control+z move container to workspace z
bindsym --to-code $mod+Control+k move container to workspace k
bindsym --to-code $mod+Control+h move container to workspace h
bindgesture swipe:right workspace prev
bindgesture swipe:left workspace next
############################################
############### containers #################
bindsym --to-code $mod+$left focus left
bindsym --to-code $mod+$down focus down
bindsym --to-code $mod+$up focus up
bindsym --to-code $mod+$right focus right
bindsym --to-code $mod+Control+$left move left
bindsym --to-code $mod+Control+$down move down
bindsym --to-code $mod+Control+$up move up
bindsym --to-code $mod+Control+$right move right
bindsym --to-code $mod+r mode "resize"
mode "resize" {
bindsym $left resize shrink width 5ppt
bindsym $down resize grow height 5ppt
bindsym $up resize shrink height 5ppt
bindsym $right resize grow width 5ppt
bindsym Escape mode "default"
}
bindsym --to-code $mod+f fullscreen
floating_modifier $mod normal
bindsym --to-code $mod+b splith
bindsym --to-code $mod+m splitv
bindsym --to-code $mod+s layout stacking
bindsym --to-code $mod+w layout tabbed
bindsym --to-code $mod+9 layout toggle split
bindsym --to-code $mod+a focus parent
bindsym --to-code $mod+Shift+minus move scratchpad
bindsym --to-code $mod+minus scratchpad show
############################################
################ styles ####################
default_border pixel 1
output * bg #$THEME_COLOR_BG solid_color
client.focused #$THEME_COLOR_BG_ACCENT_LIGHT #$THEME_COLOR_BG_ACCENT_LIGHT #$THEME_COLOR_BG_ACCENT_LIGHT
############################################
################## bar #####################
bar {
position top
font "Roboto Mono 12"
status_command i3blocks
colors {
statusline #$THEME_COLOR_FG
background #$THEME_COLOR_BG
focused_workspace #$THEME_COLOR_BG_ACCENT_LIGHT #$THEME_COLOR_BG_ACCENT_LIGHT #$THEME_COLOR_FG
inactive_workspace #$THEME_COLOR_BG_ACCENT_DARK #$THEME_COLOR_BG_ACCENT_DARK #$THEME_COLOR_FG
}
}
###########################################
################ scripts ##################
bindsym --to-code $mod+Escape kill
bindsym --to-code $mod+Control+r reload
bindsym --to-code $mod+Return exec foot
bindsym --to-code $mod+Space exec run.sh
###########################################
exec foot -s

10
arch-user/config/theme.sh Normal file
View File

@ -0,0 +1,10 @@
#!/bin/bash
export THEME_COLOR_FG=ffffff # main text
export THEME_COLOR_FG_DARK=b8bcc1 # secondary text
export THEME_COLOR_FG_ACCENT=9988ff # highlighted text, scrollbars (low-mid transp)
export THEME_COLOR_BG=0d1117 # base bg
export THEME_COLOR_BG_ACCENT_LIGHT=510079 # highlighted alt bg, borders
export THEME_COLOR_BG_ACCENT_DARK=020030 # alt bg
export THEME_OPACITY_LOW=0.2
export THEME_OPACITY_MID=0.55
export THEME_OPACITY_HIGH=0.85

View File

@ -0,0 +1,23 @@
" Don't try to be vi compatible
set nocompatible
" Show matching brackets when text indicator is over them
set showmatch
" Turn on syntax highlighting
syntax on
" Highlight search results
set hlsearch
" Search while typing
set incsearch
" Show line numbers
set number
" Show file stats
set ruler
" W - Save file as superuser
command! W execute 'w !sudo tee % > /dev/null' <bar> edit!

View File

@ -0,0 +1,31 @@
xkb_symbols "colemak_yz" {
include "us(colemak_dh)"
# functional
key.type = "ONE_LEVEL";
replace key <CAPS> { [ BackSpace ] };
replace key <RALT> { [ Escape ] };
# modifiers
key.type = "ONE_LEVEL";
replace key <RTSH> { [ Control_L ] };
modifier_map Control { <RTSH> };
replace key <LCTL> { [ Super_L ] };
modifier_map Mod4 { <LCTL> };
replace key <LALT> { [ ISO_Level3_Shift ] };
modifier_map Mod3 { <LALT> };
replace key <RCTL> { [ Alt_L ] };
modifier_map Mod1 { <RCTL> };
# layer3
# TODO: migrate to type=ALPHANUMERIC
# This would fix caps lock which i dont use anyway
key.type = "FOUR_LEVEL";
# navigation
key <AC07> { [ n, N, Left, eacute] };
key <AC08> { [ e, E, Down, eacute ] };
key <AC09> { [ i, I, Up, iacute ] };
key <AC10> { [ o, O, Right, oacute ] };
};

40
arch-user/install.sh Normal file
View File

@ -0,0 +1,40 @@
#!/bin/bash
set -e
cd "$(dirname "$0")"
umask 002
########## scripts #############
cp -rf scripts/* ~/scripts
################################
########### config #############
source config/theme.sh
VARS=$(printenv | \
grep -E 'THEME_.*' | \
sed -e 's/[= ].*//g' | sed -e 's/^/\$/' | tr '\n' ' '
)
cp_subst() {
mkdir -p "$(dirname "$2")"
envsubst "$VARS" < "$1" > "$2"
}
# simple
cp -rf config/foot ~/.config
cp -rf config/i3blocks ~/.config
cp -rf config/git ~/.config
cp -rf config/vim ~/.config
cp -rf config/xkb ~/.config
# non-xdg
cp -rf config/bash/bashrc ~/.bashrc
# templated
cp_subst config/sway/config.tmpl ~/.config/sway/config
# dynamic
cp -rf config/profile ~/.profile
cat config/bemenu/config.sh >> ~/.profile
cat config/theme.sh >> ~/.profile
################################
swaymsg reload

View File

@ -0,0 +1,12 @@
#!/bin/bash
for range in $(fc-match --format='%{charset}\n' "$1"); do
for n in $(seq "0x${range%-*}" "0x${range#*-}"); do
printf "%04x\n" "$n"
done
done | while read -r n_hex; do
count=$((count + 1))
printf "%-5s\U$n_hex\t" "$n_hex"
[ $((count % 10)) = 0 ] && printf "\n"
done
printf "\n"

View File

@ -0,0 +1,18 @@
#!/bin/bash
set -e
if [ -z "$1" ] || [ -z "$2" ]; then
echo "bad args" >&2
exit 1
fi
DEST=$(realpath "$2")
cd "$1"
mkdir -p DEST
for rel in $(find . -type f -name *.gpg); do
DESTFILE=$(echo $DEST/$rel | sed 's/\.[^.]*$//')
[ -f "$DESTFILE" ] && continue
mkdir -p "$(dirname "$DESTFILE")"
gpg --output "$DESTFILE" --decrypt "$rel"
done

65
arch-user/scripts/run.sh Executable file
View File

@ -0,0 +1,65 @@
#!/bin/sh
if [ "$USER" = "yrzam" ]; then
WEB="\
web projects
web life\
"
else
WEB=web
fi
LIST="\
term
$WEB
vifm
vim
gimp
htop
man
sway reload
logout
poweroff
reboot\
"
out=$(bemenu --prompt "" << EOF
$LIST
EOF
)
conf() {
echo yes | bemenu --prompt "sure?"
}
case "$out " in
" ");;
"web "*)
profile="${out##* }"
if [ "$profile" != "web" ]; then
exec firefox -P "$profile"
else
exec firefox
fi;;
"man ")
page="$(man -k . | bemenu --prompt "man" | awk '{print $1}')"
[ -n "$page" ] && exec footclient man "$page";;
"logout ")
conf && swaymsg exit;;
"poweroff "|"reboot ")
conf && exec systemctl "$out";;
"sway reload ")
exec $out;;
# term session
"term ")
exec footclient -D ~/;;
# term exec pure
"man "*|"htop ")
exec footclient -D ~/ "$out";;
# term exec in shell
"vifm "*|"vim "*)
exec footclient -D ~/ "$SHELL" -c "$out";;
#term exec in shell and wait
*)
exec footclient -D ~/ "$SHELL" -c "$out; read -n1";;
esac

View File

@ -0,0 +1,2 @@
#!/bin/sh
pacman -Qdttq | sudo pacman -Rns -

17
deb-vps-docker/install.sh Normal file
View File

@ -0,0 +1,17 @@
#!/bin/bash
set -e
# packages
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt update && sudo apt upgrade -y
sudo apt install gnupg docker-ce
# keys
curl https://yrz.am/gpg | gpg --import
# files
mkdir -p ~/app
touch ~/app/docker-compose.yaml