diff --git a/arch-user/bin/sway/search-mode.sh b/arch-user/bin/sway/search-mode.sh index db1d898..3d5621d 100755 --- a/arch-user/bin/sway/search-mode.sh +++ b/arch-user/bin/sway/search-mode.sh @@ -41,7 +41,7 @@ formatted_list=$(echo "$window_list" | while IFS='|' read -r id app_id name work printf "%s%s%s %s %s\n" "$workspace" "$indicator" "$id" "$app_id" "$name" done) -selection=$(echo "$formatted_list" | bemenu --width-factor 100 --prompt "/" --index "$(echo "$formatted_list" | awk 'substr($0,2,1)==">" {print NR-1}')" ) +selection=$(echo "$formatted_list" | bemenu --auto-select --width-factor 100 --prompt "/" --index "$(echo "$formatted_list" | awk 'substr($0,2,1)==">" {print NR-1}')" ) [ -z "$selection" ] && exit 0 window_id=$(echo "$selection" | sed -E 's/^...([0-9]+).*/\1/') diff --git a/arch-user/bin/workspace-compat/profile.tmpl b/arch-user/bin/workspace-compat/profile.tmpl new file mode 100644 index 0000000..1065b0e --- /dev/null +++ b/arch-user/bin/workspace-compat/profile.tmpl @@ -0,0 +1,33 @@ +#!/bin/bash + +if [ -z "$WSCOMPAT_DIR" ] || [ "$WS_IS_COMPAT" != 1 ]; then + exit 0 +fi + +[ -f /etc/profile ] && . /etc/profile +[ -f ~/.profile ] && . ~/.profile + +export EDITOR=vim +export SHELL=/bin/bash +export PATH="$WSCOMPAT_DIR:$PATH" + +stty intr ^K + +export VIMINIT="source $WSCOMPAT_DIR/.vimrc" +cat << 'EOF_04tcIQE7' > "$WSCOMPAT_DIR/.vimrc" +{{ template "vimrc" . }} +EOF_04tcIQE7 + +export INPUTRC="$WSCOMPAT_DIR/.inputrc" +cat << 'EOF_04tcIQE7' > "$WSCOMPAT_DIR/.inputrc" +{{ template "inputrc" . }} +EOF_04tcIQE7 + +export LESSKEYIN="$WSCOMPAT_DIR/.lesskey" +cat << 'EOF_04tcIQE7' > "$WSCOMPAT_DIR/.lesskey" +{{ template "lesskey" . }} +EOF_04tcIQE7 + +cat << 'EOF_04tcIQE7' > "$WSCOMPAT_DIR/wssh" +{{ tmpl.Exec "wssh" . | strings.ReplaceAll "EOF_" "EOF_1_" }} +EOF_04tcIQE7 diff --git a/arch-user/bin/wssh b/arch-user/bin/wssh new file mode 100755 index 0000000..bd12e9f --- /dev/null +++ b/arch-user/bin/wssh @@ -0,0 +1,31 @@ +#!/bin/bash + +if [ $# -lt 1 ]; then + echo "Usage: $0 [ssh-options]" + exit 1 +fi +[ -z "$WSCOMPAT_MASTER" ] && WSCOMPAT_MASTER="$(whoami)" +read -r -d '' init_cmd << EOF_9oqn7IVF + export WS_IS_COMPAT=1 + export WSCOMPAT_MASTER="$WSCOMPAT_MASTER" + export WSCOMPAT_DIR="/tmp/wscompat_${WSCOMPAT_MASTER}_\$(whoami)" + + ws_cleanup() { rm -rf "\$WSCOMPAT_DIR"; } + trap ws_cleanup EXIT + rm -rf "\$WSCOMPAT_DIR" && mkdir -p "\$WSCOMPAT_DIR" && chmod 700 "\$WSCOMPAT_DIR" + +cat << 'EOF_84EbM3la' > "\$WSCOMPAT_DIR/profile" +$( + cat "$WSCOMPAT_DIR/profile" + for file in "$WSCOMPAT_DIR.profile"*.sh; do + if [ -f "$file" ]; then cat "$file"; fi + done +) +EOF_84EbM3la + . \$WSCOMPAT_DIR/profile + + # pam, systemd - wrap in login shell + exec /bin/bash --login --norc --noprofile -c "exec /bin/bash" +EOF_9oqn7IVF + +ssh -t "$@" "$init_cmd" diff --git a/arch-user/config/profile b/arch-user/config/profile index cced9e6..670b806 100644 --- a/arch-user/config/profile +++ b/arch-user/config/profile @@ -3,7 +3,6 @@ export PATH=~/.local/bin:$PATH #export WLR_RENDERER=vulkan - export QT_STYLE_OVERRIDE=kvantum export GTK_THEME=Materia-dark diff --git a/arch-user/config/workspace-compat/env.sh b/arch-user/config/workspace-compat/env.sh new file mode 100644 index 0000000..e0aa28a --- /dev/null +++ b/arch-user/config/workspace-compat/env.sh @@ -0,0 +1 @@ +export WSCOMPAT_DIR=~/.local/bin/workspace-compat diff --git a/arch-user/gen-linux-compat.sh b/arch-user/gen-linux-compat.sh index 5de9677..b0288cf 100755 --- a/arch-user/gen-linux-compat.sh +++ b/arch-user/gen-linux-compat.sh @@ -5,6 +5,7 @@ cd "$(dirname "$(readlink -f -- "$0")")" umask 002 export IS_COMPAT=1 -gomplate --file config/vim/vimrc --out ../linux-compat/home/.vimrc -gomplate --file config/readline/inputrc --out ../linux-compat/home/.inputrc -gomplate --file config/less/lesskey --out ../linux-compat/home/.lesskey +gomplate --file bin/workspace-compat +gomplate --file config/vim/vimrc +gomplate --file config/readline/inputrc +gomplate --file config/less/lesskey diff --git a/arch-user/install.sh b/arch-user/install.sh index 7fb19f5..fcc26e0 100755 --- a/arch-user/install.sh +++ b/arch-user/install.sh @@ -8,6 +8,7 @@ set -e cd "$(dirname "$(readlink -f -- "$0")")" umask 002 [[ "$(id -u)" == "0" ]] && echo "ERROR: wrong user" >&1 && exit 1 +export IS_COMPAT=0 ########## init config ######### if [[ ! -f ~/.config/workspace.conf ]]; then @@ -48,7 +49,7 @@ mkdir -p "${USER_DIRS[@]}" ########## scripts ############# cp -rf bin/* ~/.local/bin -LN_EXCLUDE_DIRS=(i3blocks bemenu sway) +LN_EXCLUDE_DIRS=(i3blocks bemenu sway workspace-compat) ln_exclude_dirs_cmp=" ${LN_EXCLUDE_DIRS[*]} " for sdir in bin/*; do @@ -64,7 +65,6 @@ done ################################ ########### config ############# -export IS_COMPAT=0 gomplate --input-dir config \ --output-map "$HOME/.config/{{ .in | strings.ReplaceAll \".tmpl\" \"\" }}" \ --exclude-processing "!*.tmpl" \ @@ -83,6 +83,17 @@ mkdir -p ~/.gnupg && ln -sf ~/.config/gnupg/gpg-agent.conf ~/.gnupg cp -rf data/* ~/.local/share ############################### +########### compat ############ +export IS_COMPAT=1 +gomplate --file bin/workspace-compat/profile.tmpl \ + -t vimrc=config/vim/vimrc \ + -t inputrc=config/readline/inputrc \ + -t lesskey=config/less/lesskey \ + -t wssh=bin/wssh \ + --out ~/.local/bin/workspace-compat/profile +export IS_COMPAT=0 +############################### + swaymsg reload || true echo ok diff --git a/linux-compat/home/.inputrc b/linux-compat/home/.inputrc deleted file mode 100644 index e020474..0000000 --- a/linux-compat/home/.inputrc +++ /dev/null @@ -1,71 +0,0 @@ -set editing-mode vi - -########### prompt ############## -set show-mode-in-prompt on -set vi-ins-mode-string \1\e[1 q\2 -set vi-cmd-mode-string \1\e[2 q\2 -################################# - -############# new ############### -set keymap vi-insert -"\C-a":beginning-of-line -"\C-e":end-of-line -"\C-b":backward-char -"\C-f":forward-char -"\eb":backward-word -"\ef":forward-word -################################# - -##### remap - colemak-dh ####### - -# n -> h -set keymap vi-insert -"\C-n":backward-delete-char -set keymap vi-command -"n":backward-char -"\C-n":backward-char -# e -> k (reverse swap) -set keymap vi-command -"e":previous-history -"\C-e":kill-line -# i -> j (reverse swap) -#set keymap vi-insert -# "\C-i":accept-line # ascii code conflicts with tab -set keymap vi-command -"i":next-history -# "\C-i":accept-line # ascii code conflicts with tab -# o -> l -set keymap vi-command -"o":forward-char -"\C-o":clear-screen - -# k -> n -#set keymap vi-insert -#"\C-k":menu-complete # bound to intr, use tab -set keymap vi-command -"k":vi-search-again -"K":vi-search-again -"\C-k":next-history -# j -> e -set keymap vi-insert -"\C-j":self-insert -set keymap vi-command -"j":vi-end-word -"J":vi-end-word -# l -> i -set keymap vi-insert -"\C-l":complete -set keymap vi-command -"l":vi-insertion-mode -"L":vi-insert-beg -# h -> o -set keymap vi-insert -"\C-h":operate-and-get-next - -################################# - -########### custom ############## -$if qalc -set show-mode-in-prompt off -$endif -################################# diff --git a/linux-compat/home/.lesskey b/linux-compat/home/.lesskey deleted file mode 100644 index 59161a3..0000000 --- a/linux-compat/home/.lesskey +++ /dev/null @@ -1,48 +0,0 @@ -###### colemak dh movement ##### - -# n -> h -#n Help -#N Help - -# e -> j -e forw-line -E forw-line-force - -# i -> k -i back-line -^I back-line -I back-line-force - -# o -> l -^O repaint - - -# k -> n -^K forw-line -k repeat-search -\ek repeat-search-all -K reverse-search -\eK reverse-search-all -#^O^K osc8-forw-search -#^Ok osc8-forw-search -:k next-file - -# j -> e -j forw-line -^J forw-line -J examine -:j examine - -# l -> i -# noop - -# h -> o -#^H^H osc8-open - -############################ - - -######### custom ########### -n left-scroll -o right-scroll -############################ diff --git a/linux-compat/home/.vimrc b/linux-compat/home/.vimrc deleted file mode 100644 index 32cfb53..0000000 --- a/linux-compat/home/.vimrc +++ /dev/null @@ -1,173 +0,0 @@ -"########## system ########### -set nocompatible -set ttyfast -set encoding=utf-8 -set mouse=a -set autoread -au FocusGained,BufEnter * silent! checktime -"############################# - -"######### generic ########### - -" status line -set showmode -set showcmd -set ruler - -" syntax hl -syntax enable -filetype on -filetype plugin on - -" lines -set number -set relativenumber -set numberwidth=3 -set wrap -set showmatch " brackets - -" search -set hlsearch -set incsearch -set ignorecase -set smartcase - -" tabs -set shiftwidth=4 -set tabstop=4 -set softtabstop=0 -set noexpandtab - -" scroll -set scrolloff=5 - -" commands -set wildmenu -set wildmode=list:longest,full -set gdefault - -" colors -colorscheme default -set t_Co=16 -set notermguicolors -set t_RV= " bugfix -" new -highlight LineNr ctermfg=5 ctermbg=none -autocmd VimEnter * highlight SignColumn ctermbg=none -" fg magenta (5) -> blue (4) -highlight Title term=bold ctermfg=4 gui=bold -highlight Special term=bold ctermfg=4 -highlight PreProc term=underline ctermfg=4 -highlight Underlined term=underline cterm=underline ctermfg=4 gui=underline -" fg blue (4 or 12) -> magenta (5) -highlight SpecialKey term=bold ctermfg=5 -highlight Directory term=bold ctermfg=5 -highlight Folded term=standout ctermfg=5 ctermbg=7 -highlight FoldColumn term=standout ctermfg=5 ctermbg=7 -highlight SignColumn term=standout ctermfg=5 ctermbg=7 -highlight Comment term=bold ctermfg=5 -highlight NonText term=bold ctermfg=5 gui=bold -highlight DiffDelete term=bold ctermfg=5 ctermbg=14 gui=bold -highlight Changed ctermfg=5 -" bg -highlight SpellCap cterm=underline ctermfg=9 ctermbg=none gui=undercurl -"########################################### - -"############## file-specific ############### -autocmd FileType markdown setlocal spell -autocmd FileType gitcommit setlocal spell -autocmd FileType markdown setlocal complete+=kspell -autocmd FileType gitcommit setlocal complete+=kspell -"############################################ - -"####### remap - colemak-dh ####### - -" n -> h -noremap n h -noremap N H -noremap! -" e -> j -noremap e j -noremap E J -noremap! -" i -> k -noremap i k -noremap I K -"noremap! " breaks tab -" o -> l -noremap o l -noremap O L -noremap! - -" k -> n -noremap k n -noremap K N -noremap! -" j -> e -noremap j e -noremap J E -noremap! -" l -> i -noremap l i -noremap L I -noremap! -" h -> o -noremap h o -noremap H O -noremap! - -"################################# - -"############### new keybinds ############### -cnoremap -cnoremap -cnoremap -cnoremap -cnoremap -cnoremap -"############################################ - -"####### custom commands ######### -" W - Save file as superuser -command! W execute 'w !sudo tee % > /dev/null' edit! -"################################# - -"######### localization ########## -set langmap=ьЬыЫфФпПбБжЖлЛуУяЯаАрРсСтТгГмМнНеЕиИоОчЧцЦдДвВзЗкКхХ;qQwWfFpPbBjJlLuUyYaArRsStTgGmMnNeEiIoOxXcCdDvVzZkKhH -" n -> h -noremap н х -noremap Н Х -noremap! -" e -> j -noremap е ж -noremap Е Ж -noremap! -" i -> k -noremap и к -noremap И К -"noremap! " breaks tab -" o -> l -noremap о л -noremap О Л -noremap! -" k -> n -noremap к н -noremap К Н -noremap! -" j -> e -noremap й е -noremap Й Е -noremap! -" l -> i -noremap л и -noremap Л И -noremap! -" h -> o -noremap х о -noremap Х O -noremap! -"################################# - -"############# hacks ############# - -"################################ diff --git a/linux-compat/home/env.sh b/linux-compat/home/env.sh deleted file mode 100755 index 3406e6f..0000000 --- a/linux-compat/home/env.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -export BASIC_PACMAN="vim less" diff --git a/linux-compat/install-via-ssh.sh b/linux-compat/install-via-ssh.sh deleted file mode 100755 index 2f06bf5..0000000 --- a/linux-compat/install-via-ssh.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -set -e -cd "$(dirname "$(readlink -f -- "$0")")" - -[[ -z "$1" ]] && echo "ERROR: no destination" >&1 && exit 1 - -scp -r home/. "$1:/tmp/workspace" -ssh "$1" "cp -rfT /tmp/workspace ~/ && rm -rf /tmp/workspace"