diff --git a/.config/bspwm/bspwmrc b/.config/bspwm/bspwmrc index 1230c2b..50e7199 100755 --- a/.config/bspwm/bspwmrc +++ b/.config/bspwm/bspwmrc @@ -1,7 +1,4 @@ -#! /bin/sh - -pgrep -x sxhkd > /dev/null || sxhkd & -pgrep -x polybar > /dev/null || polybar & +#!/bin/sh bspc monitor -d I II III IV V VI VII VIII IX X @@ -13,3 +10,12 @@ bspc config borderless_monocle true bspc config gapless_monocle true xsetroot -solid "#000000" + +for i in /sys/class/hwmon/hwmon*/temp*_input; do + if [ "$(<$(dirname $i)/name): $(cat ${i%_*}_label 2>/dev/null || echo $(basename ${i%_*}))" = "coretemp: Package id 0" ]; then + export HWMON_PATH="$i" + fi +done + +pgrep -x sxhkd > /dev/null || sxhkd & +pgrep -x polybar > /dev/null || polybar -r & diff --git a/.config/polybar/config.ini b/.config/polybar/config.ini index 0b24865..95b21bb 100644 --- a/.config/polybar/config.ini +++ b/.config/polybar/config.ini @@ -1,21 +1,3 @@ -;========================================================== -; -; -; ██████╗ ██████╗ ██╗ ██╗ ██╗██████╗ █████╗ ██████╗ -; ██╔══██╗██╔═══██╗██║ ╚██╗ ██╔╝██╔══██╗██╔══██╗██╔══██╗ -; ██████╔╝██║ ██║██║ ╚████╔╝ ██████╔╝███████║██████╔╝ -; ██╔═══╝ ██║ ██║██║ ╚██╔╝ ██╔══██╗██╔══██║██╔══██╗ -; ██║ ╚██████╔╝███████╗██║ ██████╔╝██║ ██║██║ ██║ -; ╚═╝ ╚═════╝ ╚══════╝╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ -; -; -; To learn more about how to configure Polybar -; go to https://github.com/polybar/polybar -; -; The README contains a lot of information -; -;========================================================== - [colors] background = #282A2E background-alt = #373B41 @@ -25,48 +7,30 @@ secondary = #8ABEB7 alert = #A54242 disabled = #707880 -[bar/example] -width = 100% -height = 16pt -radius = 0 +[settings] +screenchange-reload = true +pseudo-transparency = true -; dpi = 96 +[bar/main] +height = 16pt +line-size = 1pt +font-0 = monospace;2 background = ${colors.background} foreground = ${colors.foreground} -line-size = 3pt - -border-size = 0pt -border-color = #00000000 - -padding-left = 0 -padding-right = 0 - -module-margin = 0 - separator = | separator-foreground = ${colors.disabled} -font-0 = monospace;2 - -modules-left = xworkspaces xwindow -modules-right = filesystem network memory cpu temperature pulseaudio xkeyboard date - cursor-click = pointer cursor-scroll = ns-resize -enable-ipc = true - -; tray-position = right - -; wm-restack = generic +tray-position = right wm-restack = bspwm -; wm-restack = i3 - -; override-redirect = true +enable-ipc = true -tray-position = right +modules-left = xworkspaces xwindow +modules-right = network filesystem memory cpu temperature pulseaudio xkeyboard date [module/xworkspaces] type = internal/xworkspaces @@ -91,82 +55,88 @@ label-empty-padding = 1 type = internal/xwindow label = %title:0:60:...% +[module/network] +type = internal/network +interface-type = wired + +label-connected = %{F#F0C674}%local_ip%%{F-} %netspeed% + +label-disconnected = %ifname% disconnected +label-disconnected-foreground = ${colors.disabled} + [module/filesystem] type = internal/fs -interval = 25 +spacing = 1 +warn-percentage = 95 mount-0 = / mount-1 = /media label-mounted = %{F#F0C674}%mountpoint%%{F-} %percentage_used%% -label-unmounted = %mountpoint% not mounted -label-unmounted-foreground = ${colors.disabled} +label-warn = %mountpoint% %percentage_used%% +label-warn-foreground = ${colors.alert} +format-warn = + +[module/memory] +type = internal/memory +warn-percentage = 95 + +format-prefix = "MEM " +format-prefix-foreground = ${colors.primary} + +label-warn = MEM %percentage_used%% +label-warn-foreground = ${colors.alert} +format-warn = + +[module/cpu] +type = internal/cpu +warn-percentage = 95 + +format-prefix = "CPU " +format-prefix-foreground = ${colors.primary} + +label-warn = CPU %percentage%% +label-warn-foreground = ${colors.alert} +format-warn = + +[module/temperature] +type = internal/temperature +hwmon-path = ${env:HWMON_PATH} +warn-temperature = 85 + +format-prefix = "TEMP " +format-prefix-foreground = ${colors.primary} + +label-warn = TEMP %temperature-c% +label-warn-foreground = ${colors.alert} [module/pulseaudio] type = internal/pulseaudio +use-ui-max = false format-volume-prefix = "VOL " format-volume-prefix-foreground = ${colors.primary} -format-volume = label-volume = %percentage%% +format-volume = label-muted = muted label-muted-foreground = ${colors.disabled} [module/xkeyboard] type = internal/xkeyboard -blacklist-0 = num lock -label-layout = %layout% label-layout-foreground = ${colors.primary} -label-indicator-padding = 2 -label-indicator-margin = 1 -label-indicator-foreground = ${colors.background} -label-indicator-background = ${colors.secondary} - -[module/memory] -type = internal/memory -interval = 2 -format-prefix = "RAM " -format-prefix-foreground = ${colors.primary} -label = %percentage_used:2%% - -[module/cpu] -type = internal/cpu -interval = 2 -format-prefix = "CPU " -format-prefix-foreground = ${colors.primary} -label = %percentage:2%% - -[module/temperature] -type = internal/temperature -thermal-zone = 1 -format-prefix = "TEMP " -format-prefix-foreground = ${colors.primary} - -[module/network] -type = internal/network -interface-type = wired -format-connected = -format-disconnected = -label-connected = %{F#F0C674}%local_ip%%{F-} %netspeed% -label-disconnected = %{F#F0C674}%ifname%%{F#707880} disconnected - [module/date] type = internal/date -interval = 1 -date = %H:%M -date-alt = %Y-%m-%d %H:%M:%S +date = %d/%m/%Y +time = %H:%M -label = %date% -label-foreground = ${colors.primary} +date-alt = %A, %d %B %Y +time-alt = %H:%M:%S -[settings] -screenchange-reload = true -pseudo-transparency = true - -; vim:ft=dosini +label = %date% %time% +label-foreground = ${colors.primary} diff --git a/.scripts/arch/alhp-install b/.scripts/arch/alhp-install index a09fa35..2430a27 100755 --- a/.scripts/arch/alhp-install +++ b/.scripts/arch/alhp-install @@ -18,7 +18,6 @@ fi echo "Supported architecture: $ARCH" -pkgs sync pkgs install alhp-keyring alhp-mirrorlist PACMAN_CONF="/etc/pacman.conf" @@ -28,5 +27,6 @@ grep -qxF "[core-$ARCH]" "$PACMAN_CONF" || sudo sed -i "/^[^#]*\[core\]/i [core- grep -qxF "[extra-$ARCH]" "$PACMAN_CONF" || sudo sed -i "/^[^#]*\[extra\]/i [extra-$ARCH]\nInclude = $ALHP_MIRRORLIST\n" "$PACMAN_CONF" grep -qxF "[multilib-$ARCH]" "$PACMAN_CONF" || sudo sed -i "/^[^#]*\[multilib\]/i [multilib-$ARCH]\nInclude = $ALHP_MIRRORLIST\n" "$PACMAN_CONF" -sudo pacman -Suy --noconfirm +pkgs upgrade + echo "alhp-install done." diff --git a/.scripts/arch/archlinuxcn-install b/.scripts/arch/archlinuxcn-install index 0cef304..8b50ffb 100755 --- a/.scripts/arch/archlinuxcn-install +++ b/.scripts/arch/archlinuxcn-install @@ -2,6 +2,8 @@ PACMAN_CONF="/etc/pacman.conf" grep -qxF "[archlinuxcn]" "$PACMAN_CONF" || sudo sed -i '$a\\n[archlinuxcn]\nServer = https://repo.archlinuxcn.org/$arch' $PACMAN_CONF -sudo pacman -Sy --noconfirm --needed archlinuxcn-keyring + +pkgs update +pkgs install archlinuxcn-keyring echo "archlinuxcn-install done." diff --git a/.scripts/arch/base-setup b/.scripts/arch/base-setup index 0c144c7..3d20c15 100755 --- a/.scripts/arch/base-setup +++ b/.scripts/arch/base-setup @@ -8,7 +8,6 @@ fzf lf \ PREFERED_SHELL="/usr/bin/zsh" -pkgs sync pkgs install "$PACKAGES" if [ "$SHELL" != "$PREFERED_SHELL" ] && [ -f "$PREFERED_SHELL" ]; then @@ -16,6 +15,10 @@ if [ "$SHELL" != "$PREFERED_SHELL" ] && [ -f "$PREFERED_SHELL" ]; then chsh -s "$PREFERED_SHELL" fi +if [ -f "/boot/loader/loader.conf" ]; then + sudo sed -i "s/^timeout.*/timeout 0/" /boot/loader/loader.conf +fi + # mitigations off echo "Setting mitigations off" boot-options set mitigations off diff --git a/.scripts/arch/chaotic-aur-install b/.scripts/arch/chaotic-aur-install index 8b9cd0c..cfa63f8 100755 --- a/.scripts/arch/chaotic-aur-install +++ b/.scripts/arch/chaotic-aur-install @@ -6,6 +6,7 @@ sudo pacman -U --noconfirm --needed 'https://cdn-mirror.chaotic.cx/chaotic-aur/c PACMAN_CONF="/etc/pacman.conf" grep -qxF "[chaotic-aur]" "$PACMAN_CONF" || sudo sed -i '$a\\n[chaotic-aur]\nInclude = /etc/pacman.d/chaotic-mirrorlist' $PACMAN_CONF -sudo pacman -Sy + +pkgs update echo "chaotic-aur-install done." diff --git a/.scripts/arch/cups-install b/.scripts/arch/cups-install deleted file mode 100755 index 017249d..0000000 --- a/.scripts/arch/cups-install +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh -e - -PACKAGES=" \ -cups \ -avahi \ -foomatic-db-engine \ -foomatic-db \ -foomatic-db-ppds \ -foomatic-db-nonfree \ -foomatic-db-nonfree-ppds \ -" - -pkgs sync -pkgs install "$PACKAGES" -sudo systemctl enable --now cups.service avahi-daemon.service - -echo "cups-install done. Web interface available on: http://localhost:631/" diff --git a/.scripts/arch/desktop-setup b/.scripts/arch/desktop-setup index d0f8c95..e80a9d7 100755 --- a/.scripts/arch/desktop-setup +++ b/.scripts/arch/desktop-setup @@ -20,7 +20,6 @@ FLATPAK_PACKAGES=" \ discord \ " -pkgs sync pkgs install "$PACKAGES" flatpak install "$FLATPAK_PACKAGES" diff --git a/.scripts/arch/extra-install b/.scripts/arch/extra-install deleted file mode 100755 index fe04d5d..0000000 --- a/.scripts/arch/extra-install +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/sh -e - -NET_PACKAGES=" \ -openssh \ -bind nmap \ -wget yt-dlp \ -proxychains-ng \ -iperf3 speedtest-cli \ -" - -DEV_PACKAGES=" \ -lazygit \ -docker \ -sqlite \ -nodejs npm ts-node \ -php xdebug \ -go \ -python-pip python-virtualenv \ -shellcheck \ -" - -echo "extra-install done." -case "$1" in - net) - pkgs sync - pkgs install "$NET_PACKAGES" - ;; - dev) - pkgs sync - pkgs install "$DEV_PACKAGES" - ;; - all) - pkgs sync - pkgs install "$NET_PACKAGES $DEV_PACKAGES" - ;; - *) -cat << 'EOF' -Usage: extra-install [net|dev|all] -Install extra packages. - - net - network packages. - dev - development packages. - all - all packages. -EOF - exit 1 ;; -esac - -echo "extra-install done." diff --git a/.scripts/arch/full-setup b/.scripts/arch/full-setup index 1efb414..583eddc 100755 --- a/.scripts/arch/full-setup +++ b/.scripts/arch/full-setup @@ -1,12 +1,8 @@ #!/bin/sh -e -repos-install - +repos-setup base-setup desktop-setup - -extra-install all -cups-install -obs-install +meta-install all echo "full-setup done." diff --git a/.scripts/arch/meta-install b/.scripts/arch/meta-install new file mode 100755 index 0000000..6d18a2c --- /dev/null +++ b/.scripts/arch/meta-install @@ -0,0 +1,97 @@ +#!/bin/sh -e + +usage() { + cat << 'EOF' +Usage: meta-install +Install meta packages. + + all - all packages. + net - network packages. + dev - development packages. + cups - CUPS with foomatic drivers. + obs - OBS with some plugins. +EOF +} + +if [ $# -eq 0 ]; then + usage + exit 0 +fi + +while test $# -gt 0; do + case "$1" in + all) ALL_INSTALL=1 ;; + net) NET_INSTALL=1 ;; + dev) DEV_INSTALL=1 ;; + cups) CUPS_INSTALL=1 ;; + obs) OBS_INSTALL=1 ;; + -h|--help|help) + usage + exit 0 + ;; + *) + echo "error: unrecognized parameter '$1'" + exit 1 + ;; + esac + shift +done + +meta_test() { + if [ -n "$ALL_INSTALL" ] || [ -n "$1" ]; then + return 0 + fi + + return 1 +} + +PACKAGES="" + +meta_test "$NET_INSTALL" && PACKAGES="$PACKAGES \ +openssh \ +bind nmap \ +wget yt-dlp \ +proxychains-ng \ +iperf3 speedtest-cli \ +" + +meta_test "$DEV_INSTALL" && PACKAGES="$PACKAGES \ +lazygit \ +docker \ +sqlite \ +nodejs npm ts-node \ +php xdebug \ +go \ +python-pip python-virtualenv \ +shellcheck \ +" + +meta_test "$CUPS_INSTALL" && PACKAGES="$PACKAGES \ +cups \ +avahi \ +foomatic-db-engine \ +foomatic-db \ +foomatic-db-ppds \ +foomatic-db-nonfree \ +foomatic-db-nonfree-ppds \ +" + +meta_test "$OBS_INSTALL" && PACKAGES="$PACKAGES \ +obs-studio-git \ +obs-vaapi \ +obs-kmsgrab wlrobs \ +obs-pipewire-audio-capture-bin \ +obs-vkcapture \ +obs-ndi-bin \ +obs-vban \ +obs-backgroundremoval \ +obs-plugin-tuna-bin \ +obs-streamfx \ +" + +pkgs install "$PACKAGES" + +meta_test "$CUPS_INSTALL" && sudo systemctl enable --now cups.service avahi-daemon.service +meta_test "$OBS_INSTALL" && sudo systemctl enable --now avahi-daemon.service + +echo "meta-install done." diff --git a/.scripts/arch/obs-install b/.scripts/arch/obs-install deleted file mode 100755 index 689cb92..0000000 --- a/.scripts/arch/obs-install +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh -e - -PACKAGES=" \ -obs-studio-git \ -obs-vaapi \ -obs-kmsgrab wlrobs \ -obs-pipewire-audio-capture-bin \ -obs-vkcapture \ -obs-ndi-bin \ -obs-vban \ -obs-audio-monitor \ -obs-backgroundremoval \ -obs-plugin-tuna-bin \ -obs-streamfx \ -" - -pkgs sync -pkgs install "$PACKAGES" -sudo systemctl enable --now avahi-daemon.service - -echo "obs-install done." diff --git a/.scripts/arch/paru-install b/.scripts/arch/paru-install index 6ad8480..b48e0db 100755 --- a/.scripts/arch/paru-install +++ b/.scripts/arch/paru-install @@ -1,6 +1,6 @@ #!/bin/sh -e -sudo pacman -Sy --noconfirm --needed git base-devel +pkgs install git base-devel git clone https://aur.archlinux.org/paru-bin.git cd paru-bin makepkg -cis --noconfirm --needed diff --git a/.scripts/arch/pkgs b/.scripts/arch/pkgs index 99e98a1..41bef11 100755 --- a/.scripts/arch/pkgs +++ b/.scripts/arch/pkgs @@ -1,18 +1,21 @@ #!/bin/sh -e # shellcheck disable=SC2068 -OPERATION="$1" -if [ $# -gt 1 ]; then - shift - SHIFTED=true -fi - -case "$OPERATION" in - sync) +case "$1" in + update) sudo pacman -Fy ;; + upgrade) + sudo pacman -Syu --noconfirm + + if [ -x "$(command -v paru)" ]; then + paru -Syu --noconfirm --sudoloop --skipreview + elif [ -x "$(command -v yay)" ]; then + yay -Syu --noconfirm --sudoloop + fi + ;; install) - if [ -z "$SHIFTED" ]; then + if [ -z "$2" ]; then cat << 'EOF' error: no targets specified usage: pkgs install @@ -20,16 +23,23 @@ EOF exit 1 fi + shift + + FLAGS="-S" + CURRENT_TIME=$(date +%s) + UPDATE_TIME=$(stat -c "%Y" /var/lib/pacman/sync) + + # update if db 24 hours old + [ $((CURRENT_TIME-UPDATE_TIME)) -gt 86400 ] && FLAGS="-Sy" + if pacman -Si $@ > /dev/null 2>&1; then - sudo pacman -S --noconfirm --needed $@ + sudo pacman "$FLAGS" --noconfirm --needed $@ elif [ -x "$(command -v paru)" ]; then - paru -S --noconfirm --needed --sudoloop --skipreview $@ + paru "$FLAGS" --noconfirm --needed --sudoloop --skipreview $@ elif [ -x "$(command -v yay)" ]; then - yay -S --noconfirm --needed --sudoloop $@ + yay "$FLAGS" --noconfirm --needed --sudoloop $@ else - echo "Can't install: " $@ cat << 'EOF' - paru or yay not installed. run `paru-install` to install paru. EOF @@ -40,7 +50,8 @@ EOF cat << 'EOF' usage: pkgs [...] operations: - pkgs sync + pkgs update + pkgs upgrade pkgs install EOF exit 1 ;; diff --git a/.scripts/arch/rankmirrors-update b/.scripts/arch/rankmirrors-update index 5afe4e0..4df6b6b 100755 --- a/.scripts/arch/rankmirrors-update +++ b/.scripts/arch/rankmirrors-update @@ -2,17 +2,10 @@ PACKAGES="" -if ! [ -x "$(command -v rankmirrors)" ]; then - PACKAGES="$PACKAGES pacman-contrib" -fi +[ -x "$(command -v rankmirrors)" ] || PACKAGES="$PACKAGES pacman-contrib" +[ -x "$(command -v parallel)" ] || PACKAGES="$PACKAGES parallel" -if ! [ -x "$(command -v parallel)" ]; then - PACKAGES="$PACKAGES parallel" -fi - -if [ "$PACKAGES" != "" ]; then - sudo pacman -Sy --noconfirm --needed "$PACKAGES" -fi +[ "$PACKAGES" != "" ] && pkgs install "$PACKAGES" SOURCE="https://archlinux.org/mirrorlist/?protocol=https&use_mirror_status=on" echo "Using source: $SOURCE" diff --git a/.scripts/arch/repos-install b/.scripts/arch/repos-setup similarity index 75% rename from .scripts/arch/repos-install rename to .scripts/arch/repos-setup index 33b0c8d..a6c9390 100755 --- a/.scripts/arch/repos-install +++ b/.scripts/arch/repos-setup @@ -7,8 +7,9 @@ rankmirrors-update paru-install -alhp-install +alhp-install || echo "ALHP unsupported." + chaotic-aur-install archlinuxcn-install -echo "repos-install done." +echo "repos-setup done." diff --git a/.scripts/arch/server-setup b/.scripts/arch/server-setup index a993193..19da24f 100755 --- a/.scripts/arch/server-setup +++ b/.scripts/arch/server-setup @@ -9,8 +9,8 @@ BARRIER_SERVER="192.168.2.10" sudo groupadd -f "$MEDIA_GROUP" sudo usermod -aG "$MEDIA_GROUP" "$USER" sudo chown "$USER:$MEDIA_GROUP" -R "$MEDIA_PATH" - -pkgs sync +sudo chmod g+s -R "$MEDIA_PATH" +sudo setfacl -R -d -m g::rwx "$MEDIA_PATH" # SSH Server pkgs install openssh diff --git a/README.md b/README.md index a90afd6..b345fdd 100644 --- a/README.md +++ b/README.md @@ -101,41 +101,45 @@ Arch Linux specific. #### Environment - [full-setup](.scripts/arch/full-setup) - setup everything except server env. +- [repos-setup](.scripts/arch/repos-setup) - setup all repos, paru and run rankmirrors-update. - [base-setup](.scripts/arch/base-setup) - setup base environment with some tweaks. - [desktop-setup](.scripts/arch/desktop-setup) - graphical environment. - [server-setup](.scripts/arch/server-setup) - server environment. +Note: **full-setup** and **base-setup** would disable cpu mitigations, for reset to defaults: +```sh +boot-options del mitigations +``` + -#### Package managers +#### Packages -- [pkgs](.scripts/arch/pkgs) - package managers wrapper, noninteractive, support: pacman, paru, yay. Used in scripts below. +- [pkgs](.scripts/arch/pkgs) - package managers wrapper, noninteractive, support: pacman, paru, yay. Used in scripts. ```sh usage: pkgs [...] operations: - pkgs sync + pkgs update + pkgs upgrade pkgs install ``` +- [meta-install](.scripts/arch/meta-install) - install meta packages. +```sh +Usage: meta-install +Install meta packages. + + all - all packages. + net - network packages. + dev - development packages. + cups - CUPS with foomatic drivers. + obs - OBS with some plugins. +``` + - [rankmirrors-update](.scripts/arch/rankmirrors-update) - rank all [mirrors](https://archlinux.org/mirrorlist/?protocol=https&use_mirror_status=on), process can take a while, some abroad servers can be faster in EU. - [paru-install](.scripts/arch/paru-install) - install AUR [paru](https://github.com/Morganamilo/paru) package manager. #### Repos -- [repos-install](.scripts/arch/repos-install) - install all repos, paru and run rankmirrors-update. - [alhp-install](.scripts/arch/alhp-install) - install [ALHP](https://github.com/an0nfunc/ALHP) repos. Archlinux-based repos build with different x86-64 feature levels, -O3 and LTO. - [chaotic-aur-install](.scripts/arch/chaotic-aur-install) - install [Chaotic-AUR](https://github.com/chaotic-aur) repos. An automated building repo for AUR packages. - [archlinuxcn-install](.scripts/arch/archlinuxcn-install) - install [archlinuxcn](https://github.com/archlinuxcn/repo) repos. Arch Linux CN Repository. - -#### Packages - -- [extra-install](.scripts/arch/extra-install) - install extra packages. -```sh -Usage: extra-install [net|dev|all] - - net - network packages. - dev - development packages. - all - all packages. -``` - -- [cups-install](.scripts/arch/cups-install) - install CUPS with foomatic drivers. -- [obs-install](.scripts/arch/obs-install) - install OBS with some plugins. \ No newline at end of file