Compare commits

...

10 Commits

5 changed files with 266 additions and 68 deletions

View File

@ -6,14 +6,18 @@ esac
# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth
HISTCONTROL=ignoreboth:erasedups
# append to the history file, don't overwrite it
shopt -s histappend
# Save multi-line commands as single entry
shopt -s cmdhist
# Save history immediately after each command
PROMPT_COMMAND="history -a; $PROMPT_COMMAND"
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000
HISTSIZE=10000
HISTFILESIZE=20000
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.

View File

@ -135,10 +135,6 @@ cursor {
hide_on_key_press = true
}
gestures {
workspace_swipe = false
}
device {
name = elecom-trackball-mouse-deft-pro-trackball-1
sensitivity = 0.7
@ -163,7 +159,8 @@ bind = $mainMod, H, layoutmsg, preselect l
bind = $mainMod, L, layoutmsg, preselect r
bind = $mainMod, J, layoutmsg, preselect d
bind = $mainMod, K, layoutmsg, preselect u
bind = $mainMod, F, exec, walker --modules applications
# bind = $mainMod, F, exec, walker --modules applications
bind = $mainMod, F, exec, wofi --show drun
bind = SUPER, L, exec, python ~/linuxbox/black.py
bind = ALT, Tab, workspace, e+1
bind = ALT SHIFT, Tab, workspace, emptyn

View File

@ -73,9 +73,7 @@ local active_statusline = function()
end
local inactive_statusline = function()
return MiniStatusline.combine_groups({
{ hl = "MiniStatuslineDevinfo", strings = {} },
})
return active_statusline()
end
-------------------------------------------------------------------
@ -93,20 +91,16 @@ vim.pack.add({
{ src = "https://github.com/neovim/nvim-lspconfig" },
{ src = "https://github.com/lewis6991/gitsigns.nvim" },
{ src = "https://github.com/MunifTanjim/nui.nvim" },
-- { src = "https://github.com/folke/noice.nvim" },
{ src = "https://github.com/L3MON4D3/LuaSnip" },
{ src = "https://github.com/rafamadriz/friendly-snippets" },
{ src = "https://github.com/saghen/blink.cmp" },
{ src = "https://github.com/stevearc/conform.nvim" },
{ src = "https://github.com/prichrd/netrw.nvim" },
{ src = "https://github.com/nvim-tree/nvim-tree.lua" },
})
-------------------------------------------------------------------
-- Plugin config
-------------------------------------------------------------------
-- require("noice").setup()
require("netrw").setup()
require("conform").setup({
formatters_by_ft = {
lua = { "stylua" },
@ -183,13 +177,82 @@ require("blink.cmp").setup({
},
fuzzy = { implementation = "lua" },
})
require("nvim-tree").setup()
require("nvim-tree").setup({
view = {
-- Ensures files open in the window where nvim-tree was triggered
preserve_window_proportions = true,
centralize_selection = true,
},
update_focused_file = {
enable = true, -- update the tree to focus the current file
update_root = false, -- don't change the root dir automatically
ignore_list = {}, -- you can add filetypes to ignore (e.g. "help")
},
actions = {
open_file = {
quit_on_open = true, -- auto-close tree when file is opened
resize_window = true,
window_picker = {
enable = false, -- disable asking which window to use
},
},
},
})
-------------------------------------------------------------------
-- LSP config
-------------------------------------------------------------------
vim.lsp.enable({ "lua_ls", "rust_analyzer", "bashls", "pyright", "marksman", "clangd", "yamlls" })
local Input = require("nui.input")
local event = require("nui.utils.autocmd").event
local function lsp_rename()
local curr_name = vim.fn.expand("<cword>")
local client = vim.lsp.get_clients({ bufnr = 0 })[1]
local offset_encoding = client and client.offset_encoding or "utf-16"
local pos_params = vim.lsp.util.make_position_params(0, offset_encoding)
local input = Input({
position = {
row = vim.fn.winline(),
col = vim.fn.wincol(),
},
size = #curr_name + 10,
border = {
style = "rounded",
text = { top = "Rename", top_align = "left" },
},
}, {
prompt = "",
default_value = curr_name,
on_submit = function(new_name)
if new_name and #new_name > 0 and new_name ~= curr_name then
local params = {
textDocument = pos_params.textDocument,
position = pos_params.position,
newName = new_name,
}
-- send to all clients attached to buffer
vim.lsp.buf_request(0, "textDocument/rename", params)
end
end,
})
input:mount()
input:on(event.BufLeave, function()
input:unmount()
end)
input:map("i", "<Esc>", function()
input:unmount()
end, { noremap = true, nowait = true })
input:map("n", "<Esc>", function()
input:unmount()
end, { noremap = true, nowait = true })
end
-------------------------------------------------------------------
-- GUI config
-------------------------------------------------------------------
@ -235,17 +298,16 @@ map("n", "<leader>u", ":update<CR> :source<CR>", { noremap = true, silent = true
map("n", "<leader>w", ":write<CR>", { noremap = true, silent = true })
map("n", "<leader>q", ":quit<CR>", { noremap = true, silent = true })
map("n", "<leader>v", ":vsplit<CR>", { noremap = true, silent = true })
map("n", "<C-d>", "<C-d>zz", { noremap = true, silent = true })
map("n", "<C-u>", "<C-u>zz", { noremap = true, silent = true })
map("n", "n", "nzzzv", { noremap = true, silent = true })
map("n", "N", "Nzzzv", { noremap = true, silent = true })
-- vim.keymap.set("n", "grn", lsp_rename, { desc = "LSP Rename (popup)" })
-- Git
map("n", "<leader>g", ":LazyGitCurrentFile<CR>", { noremap = true, silent = true })
-- File browser
-- map("n", "<leader>e", ":25Lex<CR>", { noremap = true, silent = true })
map("n", "<leader>e", ":NvimTreeToggle<CR>", { noremap = true, silent = true })
map("n", "<leader>e", ":NvimTreeFindFileToggle!<CR>", { noremap = true, silent = true })
map("n", "<leader>f", ":Pick files<CR>", { noremap = true, silent = true })
map("n", "<leader>h", ":Pick help<CR>", { noremap = true, silent = true })

View File

@ -2,6 +2,159 @@
set -e
sudo -v
ACTION="${1:-update}"
KERNEL_PACKAGES=(linux linux-lts linux-zen linux-hardened linux-rt linux-rt-lts linux-rt-bfq linux-xanmod linux-xanmod-lts linux-xanmod-tt)
create_timeshift_snapshot() {
local comment=${1:-"Update script"}
if ! pacman -Qs timeshift >/dev/null; then
printf -- '\033[33m Timeshift not installed; skipping snapshot\n\033[37m'
return 0
fi
printf -- '\033[33m Creating Timeshift snapshot\n\033[37m'
sudo timeshift --create --comments "$comment"
}
backup_boot_archive() {
local mode=${1:-auto}
if [ "$mode" = "auto" ]; then
sudo pacman -Sy --noconfirm >/dev/null
local pending=()
for kernel_pkg in "${KERNEL_PACKAGES[@]}"; do
if pacman -Qi "$kernel_pkg" >/dev/null 2>&1 && pacman -Qu "$kernel_pkg" >/dev/null 2>&1; then
pending+=("$kernel_pkg")
fi
done
if [ "${#pending[@]}" -eq 0 ]; then
printf -- '\033[33m No kernel update detected; skipping /boot backup\n\033[37m'
return 0
fi
printf -- '\033[33m Kernel update detected; backing up /boot\n\033[37m'
else
printf -- '\033[33m Forcing /boot backup\n\033[37m'
fi
local boot_backup_dir="${HOME}/boot-backups"
mkdir -p "$boot_backup_dir"
local backup_file="${boot_backup_dir}/boot-$(date +%Y%m%d-%H%M%S).tar.gz"
sudo tar -C /boot -acf "$backup_file" .
sudo chown "$USER":"$USER" "$backup_file"
printf -- '\033[32m Saved /boot backup to %s\n\033[37m' "$backup_file"
}
restore_latest_state() {
printf -- '\033[33m Gathering restore options\n\033[37m'
BOOT_BACKUP_DIR="${HOME}/boot-backups"
TIMESLICE_INFO=""
TIMESLICE_META=""
TIMESLICE_LABEL=""
if pacman -Qs timeshift >/dev/null; then
TIMESHIFT_LIST=$(sudo timeshift --list)
TIMESLICE_INFO=$(printf '%s\n' "$TIMESHIFT_LIST" | awk '
$1 ~ /^[0-9]+$/ {
idx=2
if ($2 == ">") { idx=3 }
snap=$idx
desc=""
for (i=idx+2; i<=NF; i++) {
desc = desc ? desc " " $i : $i
}
}
END {
if (snap != "") {
printf "%s|%s", snap, desc
}
}
')
if [ -z "$TIMESLICE_INFO" ]; then
TIMESLICE_INFO=$(printf '%s\n' "$TIMESHIFT_LIST" | awk -F': +' '
/^Snapshot/ {snap=$2}
/^Created on/ {created=$2}
END { if (snap != "") { printf "%s|%s", snap, created } }
')
fi
if [ -n "$TIMESLICE_INFO" ]; then
TIMESLICE_LABEL=${TIMESLICE_INFO%%|*}
TIMESLICE_META=${TIMESLICE_INFO#*|}
[ "$TIMESLICE_META" = "$TIMESLICE_LABEL" ] && TIMESLICE_META=""
fi
fi
LATEST_BOOT=""
if [ -d "$BOOT_BACKUP_DIR" ]; then
LATEST_BOOT=$( (ls -1t "$BOOT_BACKUP_DIR"/boot-*.tar.gz 2>/dev/null || true) | head -n1 )
fi
if [ -n "$TIMESLICE_LABEL" ]; then
printf -- '\033[33m Latest Timeshift snapshot: %s\n\033[37m' "$TIMESLICE_LABEL"
if [ -n "$TIMESLICE_META" ]; then
printf -- ' Details: %s\n' "$TIMESLICE_META"
fi
else
printf -- '\033[33m No Timeshift snapshots available\n\033[37m'
fi
if [ -n "$LATEST_BOOT" ]; then
BOOT_BASENAME=$(basename "$LATEST_BOOT")
BOOT_STAMP=${BOOT_BASENAME#boot-}
BOOT_STAMP=${BOOT_STAMP%.tar.gz}
printf -- '\033[33m Latest /boot archive: %s (saved %s)\n\033[37m' "$BOOT_BASENAME" "$BOOT_STAMP"
else
printf -- '\033[33m No /boot backup archives available\n\033[37m'
fi
if [ -z "$TIMESLICE_LABEL" ] && [ -z "$LATEST_BOOT" ]; then
printf -- '\033[31m Nothing to restore\n\033[37m'
exit 1
fi
RESTORED_ANY=0
if [ -n "$TIMESLICE_LABEL" ]; then
read -r -p "Restore this Timeshift snapshot? [y/N]: " CONFIRM
if [[ "$CONFIRM" =~ ^[Yy]$ ]]; then
printf -- '\033[33m Starting Timeshift restore (follow on-screen prompts)\n\033[37m'
sudo timeshift --restore --snapshot "$TIMESLICE_LABEL" --yes
RESTORED_ANY=1
else
printf -- '\033[33m Timeshift restore skipped\n\033[37m'
fi
fi
if [ -n "$LATEST_BOOT" ]; then
read -r -p "Restore /boot from this archive? [y/N]: " BOOT_CONFIRM
if [[ "$BOOT_CONFIRM" =~ ^[Yy]$ ]]; then
printf -- '\033[33m Restoring /boot from %s\n\033[37m' "$LATEST_BOOT"
sudo tar -C /boot -xpf "$LATEST_BOOT"
printf -- '\033[32m /boot restore complete\n\033[37m'
RESTORED_ANY=1
else
printf -- '\033[33m /boot restore skipped\n\033[37m'
fi
fi
if [ "$RESTORED_ANY" -eq 0 ]; then
printf -- '\033[33m No restore actions performed\n\033[37m'
fi
}
if [ "$ACTION" == "restore" ]; then
restore_latest_state
exit 0
elif [ "$ACTION" == "backup" ]; then
create_timeshift_snapshot "Manual backup (update_arch.sh)"
backup_boot_archive force
exit 0
fi
if ! pacman -Qs inetutils >/dev/null; then
sudo pacman -Syy --noconfirm inetutils
fi
@ -10,7 +163,7 @@ HOSTNAME=$(hostname | tr '[:lower:]' '[:upper:]')
# Declare associative array for roles
declare -A ROLES
for role in MUSIC LAB BT GAME VR DESKTOP_BASE DESKTOP_WORK CODE NVIDIA_GPU NVIDIA_1080_GPU TERMINAL HYPERLAND; do
for role in MUSIC LAB BT GAME VR DESKTOP_BASE DESKTOP_WORK NVIDIA_GPU NVIDIA_1080_GPU TERMINAL HYPERLAND; do
ROLES["$role"]="no"
done
@ -19,7 +172,6 @@ case "$HOSTNAME" in
CMBOX)
ROLES[DESKTOP_BASE]="yes"
ROLES[DESKTOP_WORK]="yes"
ROLES[CODE]="yes"
ROLES[TERMINAL]="yes"
ROLES[HYPERLAND]="yes"
ROLES[MUSIC]="yes"
@ -34,7 +186,6 @@ STEAMBOX)
;;
LABBOX)
ROLES[DESKTOP_BASE]="yes"
ROLES[CODE]="yes"
ROLES[TERMINAL]="yes"
ROLES[HYPERLAND]="yes"
ROLES[LAB]="yes"
@ -76,10 +227,7 @@ printf -- '\n\n\033[37m'
sleep 1
# Create backup/snapshot
if pacman -Qs timeshift >/dev/null; then
printf -- '\033[33m Creating backup/snapshot\n\033[37m'
sudo timeshift --create --comments "Update script"
fi
create_timeshift_snapshot "Update script"
# Enable multilib (if applicable)
if [ "${ROLES[GAME]}" == "yes" ]; then
@ -93,6 +241,9 @@ EOT
fi
fi
# Back up /boot ahead of kernel upgrades so it aligns with Timeshift snapshots
backup_boot_archive auto
# Update all pacman packages
printf -- '\033[33m Updating pacman packages\n\033[37m'
sudo pacman -Suyy --noconfirm
@ -172,15 +323,15 @@ sudo localectl set-locale LANG=en_US.UTF-8
# Install hyprland
if [ "${ROLES[HYPERLAND]}" == "yes" ]; then
printf -- '\033[33m Installing hyprland\n\033[37m'
sudo pacman --noconfirm --needed -S wayvnc nm-connection-editor usbutils plymouth dracut dunst hyprpaper hypridle hyprland hyprlock xdg-desktop-portal-hyprland polkit-gnome xorg-xhost gnome-keyring qt6ct qt6ct gnome-themes-extra qt5-wayland qt6-wayland lxappearance qt5-tools adwaita-fonts gnome-disk-utility hyprpaper tk
sudo pacman --noconfirm --needed -S alacritty wofi wayvnc nm-connection-editor usbutils plymouth dracut dunst hyprpaper hypridle hyprland hyprlock xdg-desktop-portal-hyprland polkit-gnome xorg-xhost gnome-keyring qt6ct qt6ct gnome-themes-extra qt5-wayland qt6-wayland lxappearance qt5-tools adwaita-fonts gnome-disk-utility hyprpaper tk
yay --noconfirm -S --needed --aur adwaita-qt5-git
yay --noconfirm -S --needed --aur adwaita-qt6-git
yay --noconfirm -S --needed --aur hyprshot
yay --noconfirm -S --needed --aur walker-bin
mkdir -p ~/.local/bin
mkdir -p ~/.config/hypr
mkdir -p ~/.config/alacritty
if [ -f ~/linuxbox/config/hypr/hyprland_$HOSTNAME.conf ]; then
ln -sf ~/linuxbox/config/hypr/hyprland_$HOSTNAME.conf ~/.config/hypr/hyprland_extra.conf
@ -202,6 +353,7 @@ if [ "${ROLES[HYPERLAND]}" == "yes" ]; then
ln -sf ~/linuxbox/config/qt6ct ~/.config
ln -sf ~/linuxbox/config/dunst ~/.config
ln -sf ~/linuxbox/config/walker ~/.config
ln -sf ~/linuxbox/config/alacritty/alacritty.toml ~/.config/alacritty/alacritty.toml
printf -- '\033[33m Installing waybar\n\033[37m'
sudo pacman --noconfirm --needed -S waybar
@ -238,17 +390,14 @@ if [ "${ROLES[TERMINAL]}" == "yes" ]; then
if pacman -Qs gnu-free-fonts >/dev/null; then
sudo pacman --noconfirm -R gnu-free-fonts
fi
sudo pacman --noconfirm --needed -S dysk lazygit alacritty btop ranger tmux fd ttf-nerd-fonts-symbols ttf-roboto-mono-nerd gdu ruby bottom go php luarocks composer jdk-openjdk julia nodejs npm
sudo pacman --noconfirm --needed -S dysk lazygit btop ranger tmux fd ttf-nerd-fonts-symbols ttf-roboto-mono-nerd gdu ruby bottom go php luarocks composer jdk-openjdk julia nodejs npm
yay --noconfirm -S --needed --aur neovim-git-bin
sudo npm install -g neovim
cargo install tree-sitter-cli ripgrep eza
cargo install zoxide --locked
cargo install starship --locked
cargo install tree-sitter-cli ripgrep eza starship
mkdir -p ~/.config/nvim
mkdir -p ~/.config/alacritty
mkdir -p ~/.config/lazygit
mkdir -p ~/.local/bin
@ -256,14 +405,9 @@ if [ "${ROLES[TERMINAL]}" == "yes" ]; then
ln -sf ~/linuxbox/luacheckrc ~/.luacheckrc
ln -sf ~/linuxbox/config/starship.toml ~/.config/starship.toml
ln -sf ~/linuxbox/config/nvim/init.lua ~/.config/nvim/init.lua
ln -sf ~/linuxbox/config/alacritty/alacritty.toml ~/.config/alacritty/alacritty.toml
ln -sf ~/linuxbox/config/lazygit/config.yml ~/.config/lazygit/config.yml
ln -sf ~/linuxbox/start_nvim.sh ~/.local/bin/start_nvim
if [ -d ~/.local/share/nvim/lazy ]; then
nvim --headless "+Lazy! sync" +qa
fi
printf -- '\033[33m Installing fzf\n\033[37m'
rm -rf ~/.fzf
git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
@ -275,29 +419,21 @@ if [ "${ROLES[TERMINAL]}" == "yes" ]; then
yay --noconfirm -S --needed --aur dockerfile-language-server
rustup component add rust-analyzer clippy rustfmt
printf -- '\033[33m Installing Rust embedded rp2040\n\033[37m'
cd ~
rustup target add thumbv6m-none-eabi
cargo install elf2uf2-rs --locked
cargo install probe-run flip-link
mkdir -p ~/.local/bin
ln -sf ~/linuxbox/pico-load.sh ~/.local/bin/pico-load
printf -- '\033[33m Installing VirtualHere client\n\033[37m'
cd ~
wget https://www.virtualhere.com/sites/default/files/usbclient/scripts/virtualhereclient.service
wget https://www.virtualhere.com/sites/default/files/usbclient/vhclientx86_64
wget https://www.virtualhere.com/sites/default/files/usbclient/vhuit64
chmod +x ./vhclientx86_64
chmod +x ./vhuit64
sudo mv ./vhclientx86_64 /usr/sbin
sudo mv ./vhuit64 /usr/sbin
echo "$USER ALL=(ALL:ALL) NOPASSWD: /usr/sbin/vhclientx86_64" | sudo tee /etc/sudoers.d/$USER+vhclientx86_64
echo "$USER ALL=(ALL:ALL) NOPASSWD: /usr/sbin/vhuit64" | sudo tee /etc/sudoers.d/$USER+vhuit64
sudo mv virtualhereclient.service /etc/systemd/system/virtualhereclient.service
sudo systemctl daemon-reload
sudo systemctl enable virtualhereclient.service
sudo systemctl start virtualhereclient.service
# printf -- '\033[33m Installing VirtualHere client\n\033[37m'
# cd ~
# wget https://www.virtualhere.com/sites/default/files/usbclient/scripts/virtualhereclient.service
# wget https://www.virtualhere.com/sites/default/files/usbclient/vhclientx86_64
# wget https://www.virtualhere.com/sites/default/files/usbclient/vhuit64
# chmod +x ./vhclientx86_64
# chmod +x ./vhuit64
# sudo mv ./vhclientx86_64 /usr/sbin
# sudo mv ./vhuit64 /usr/sbin
# echo "$USER ALL=(ALL:ALL) NOPASSWD: /usr/sbin/vhclientx86_64" | sudo tee /etc/sudoers.d/$USER+vhclientx86_64
# echo "$USER ALL=(ALL:ALL) NOPASSWD: /usr/sbin/vhuit64" | sudo tee /etc/sudoers.d/$USER+vhuit64
# sudo mv virtualhereclient.service /etc/systemd/system/virtualhereclient.service
# sudo systemctl daemon-reload
# sudo systemctl enable virtualhereclient.service
# sudo systemctl start virtualhereclient.service
fi
@ -307,10 +443,9 @@ if [ "${ROLES[DESKTOP_BASE]}" == "yes" ]; then
sudo pacman --noconfirm --needed -S cameractrls feh
flatpak install -y flathub com.discordapp.Discord
flatpak install -y flathub com.behringer.XAirEdit
flatpak install -y flathub com.github.vikdevelop.timer
flatpak install -y flathub io.github.efogdev.mpris-timer
flatpak install -y flathub org.remmina.Remmina
yay --noconfirm -S --needed --aur brave-bin
flatpak install -y flathub com.brave.Browser
# yay --noconfirm -S --needed --aur brave-bin
printf -- '\033[33m Installing other fonts\n\033[37m'
sudo pacman --noconfirm --needed -S noto-fonts poppler-data adobe-source-code-pro-fonts
@ -318,7 +453,7 @@ fi
if [ "${ROLES[DESKTOP_WORK]}" == "yes" ]; then
printf -- '\033[33m Installing desktop work utilities\n\033[37m'
sudo pacman --noconfirm --needed -S kicad freecad
sudo pacman --noconfirm --needed -S kicad kicad-library freecad
flatpak install -y flathub org.kde.krita
flatpak install -y flathub com.prusa3d.PrusaSlicer
flatpak install -y flathub com.jgraph.drawio.desktop

View File

@ -17,8 +17,8 @@ if [ -d ~/linuxbox ]; then
cd ~/linuxbox &&
git pull &&
if [ "$OS" == "Ubuntu" ]; then
./update_ubuntu.sh
./update_ubuntu.sh "$@"
elif [ "$OS" == "Arch Linux" ]; then
./update_arch.sh
./update_arch.sh "$@"
fi
fi