From ddd00d7844590184229e2556590e704b3440d144 Mon Sep 17 00:00:00 2001 From: ange Date: Thu, 30 Jan 2025 13:55:36 +0000 Subject: [PATCH] cleanup --- .config/bash/10-aliases.bash | 68 ++++++++++--------- .config/nvim/ftplugin/dart.lua | 2 + .config/nvim/pack/plugins/start/treesitter | 2 +- .gitmodules | 3 + .local/aur/waydroid | 1 + .local/bin/light | 7 +- .local/bin/sbar | 54 +++++++-------- .local/bin/vm | 8 ++- .local/bin/vol | 11 ++- .local/bin/vpn | 42 ++++++------ .local/bin/wlp | 4 +- .local/share/bash-completion/completions/ddev | 2 + .local/share/bash-completion/completions/gi | 2 + .local/share/bash-completion/completions/kctx | 2 + .local/share/bash-completion/completions/kns | 2 + .local/share/bash-completion/completions/pac | 2 - 16 files changed, 121 insertions(+), 91 deletions(-) create mode 100644 .config/nvim/ftplugin/dart.lua create mode 160000 .local/aur/waydroid delete mode 100644 .local/share/bash-completion/completions/pac diff --git a/.config/bash/10-aliases.bash b/.config/bash/10-aliases.bash index b524f25..5ea629f 100644 --- a/.config/bash/10-aliases.bash +++ b/.config/bash/10-aliases.bash @@ -12,8 +12,8 @@ function gi() { } function update() { - $TERM --hold -e "$SHELL" -ic "pac -Syu && echo $'\e[32mDONE'" & - $TERM --hold -e "$SHELL" -ic "flatpak update && echo -e $'\e[32mDONE'" & + $TERM --hold -e "$SHELL" -c "sudo pacman -Syu && echo $'\e[32mDONE'" & + $TERM --hold -e "$SHELL" -c "flatpak update && echo -e $'\e[32mDONE'" & $TERM --hold -e "$SHELL" -ic "cd && c submodule update --remote --recursive && echo $'\e[32mDONE'" & } @@ -21,37 +21,39 @@ function tmp() { cd "$(mktemp -d --tmpdir "$1"XXX)" || return } -alias ...='../..' \ - ....='../../..' \ - .....='../../../..' \ - ......='../../../../..' \ - c='git --git-dir="$HOME/.dotfiles/" --work-tree="$HOME"' \ - cp='cp -vi' \ - diff='diff --color' \ - feh='feh --auto-zoom --scale-down' \ - g=git \ - grep='grep --color --exclude-dir={.cache,.git,.idea,.venv,.vscode,node_modules}' \ - ip='ip -c=auto' \ - l='ll -a' \ - la='ll -A' \ - ll='ls -lh' \ - ls='ls --color' \ - mail=aerc \ - mkdir='mkdir -v' \ - mv='mv -vi' \ - neofetch=fastfetch \ - pac='sudo pacman' \ - qcp='qcp -o tabsize=4' \ - qmv='qmv -o tabsize=4' \ - rm='rm -vI' \ - rss=newsraft \ - rsync='rsync -P' \ - ssh='TERM=xterm-256color ssh' \ - sudo='sudo ' \ - vi='$EDITOR' \ - watch='watch -c ' \ - xargs='xargs ' \ - xmr='monero-wallet-cli --daemon-address monero.maby.dev:18081 --trusted-daemon --log-file=/tmp/monero-wallet-cli.log --wallet-file /home/ange/.config/monero/ange' +alias -- \ + -='cd -' \ + ......='../../../../..' \ + .....='../../../..' \ + ....='../../..' \ + ...='../..' \ + c='git --git-dir="$HOME/.dotfiles/" --work-tree="$HOME"' \ + cp='cp -vi' \ + diff='diff --color' \ + feh='feh --auto-zoom --scale-down' \ + g=git \ + grep='grep --color --exclude-dir={.cache,.git,.idea,.venv,.vscode,node_modules}' \ + ip='ip -c=auto' \ + l='ll -a' \ + la='ll -A' \ + ll='ls -lh' \ + ls='ls --color' \ + mail=aerc \ + mkdir='mkdir -v' \ + mv='mv -vi' \ + neofetch=fastfetch \ + qcp='qcp -o tabsize=4' \ + qmv='qmv -o tabsize=4' \ + rm='rm -vI' \ + rss=newsraft \ + rsync='rsync -P' \ + ssh='TERM=xterm-256color ssh' \ + sudo='sudo ' \ + vi='$EDITOR' \ + watch='watch -c ' \ + waydroid='cage -- waydroid' \ + xargs='xargs ' \ + xmr='monero-wallet-cli --daemon-address monero.maby.dev:18081 --trusted-daemon --log-file=/tmp/monero-wallet-cli.log --wallet-file $XDG_CONFIG_HOME/.config/monero/ange' . /usr/share/git/completion/git-completion.bash $(complete -p git) p c diff --git a/.config/nvim/ftplugin/dart.lua b/.config/nvim/ftplugin/dart.lua new file mode 100644 index 0000000..413a354 --- /dev/null +++ b/.config/nvim/ftplugin/dart.lua @@ -0,0 +1,2 @@ +vim.opt_local.shiftwidth = 2 +vim.opt_local.tabstop = 2 diff --git a/.config/nvim/pack/plugins/start/treesitter b/.config/nvim/pack/plugins/start/treesitter index a67a312..0c94de7 160000 --- a/.config/nvim/pack/plugins/start/treesitter +++ b/.config/nvim/pack/plugins/start/treesitter @@ -1 +1 @@ -Subproject commit a67a312e7b08cbf2895d8f29a4b1f38f18d9a8e8 +Subproject commit 0c94de7e9792cf89c14a865ab819ad5c6e6a7f77 diff --git a/.gitmodules b/.gitmodules index 1592ea4..9562826 100644 --- a/.gitmodules +++ b/.gitmodules @@ -19,3 +19,6 @@ [submodule ".local/aur/sparrow"] path = .local/aur/sparrow url = https://aur.archlinux.org/sparrow-wallet.git +[submodule ".local/aur/waydroid"] + path = .local/aur/waydroid + url = https://aur.archlinux.org/waydroid.git diff --git a/.local/aur/waydroid b/.local/aur/waydroid new file mode 160000 index 0000000..d19d582 --- /dev/null +++ b/.local/aur/waydroid @@ -0,0 +1 @@ +Subproject commit d19d5823400fc065a3b0ea9bb1eb8b7cc9cb5e12 diff --git a/.local/bin/light b/.local/bin/light index 7c4d56d..7d5de2e 100755 --- a/.local/bin/light +++ b/.local/bin/light @@ -12,7 +12,10 @@ case "${1:0:1}" in *) CUR="$1" ;; esac -[ "$CUR" -lt 0 ] && CUR=0 -[ "$CUR" -gt "$MAX" ] && CUR="$MAX" +if [ "$CUR" -lt 0 ]; then + CUR=0 +elif [ "$CUR" -gt "$MAX" ]; then + CUR="$MAX" +fi echo "$CUR" > "$DIR/brightness" diff --git a/.local/bin/sbar b/.local/bin/sbar index 07f03ae..3d1592f 100755 --- a/.local/bin/sbar +++ b/.local/bin/sbar @@ -19,43 +19,42 @@ function update_bat() { dir='/sys/class/power_supply/BAT0' cap="$(cat "$dir/capacity")" - { grep -qv Discharging "$dir/status" && bat=" $cap%"; } || - { [ "$cap" -gt 80 ] && bat=" $cap%"; } || - { [ "$cap" -gt 60 ] && bat=" $cap%"; } || - { [ "$cap" -gt 40 ] && bat=" $cap%"; } || - { [ "$cap" -gt 20 ] && bat=" $cap%"; } || - { bat=" $cap%"; } + if grep -qv Discharging "$dir/status"; then + bat=" $cap%" + elif [ "$cap" -gt 80 ]; then bat=" $cap%" + elif [ "$cap" -gt 60 ]; then bat=" $cap%" + elif [ "$cap" -gt 40 ]; then bat=" $cap%" + elif [ "$cap" -gt 20 ]; then bat=" $cap%" + else bat=" $cap%" + fi } function update_sink_vol() { - local sink vol + local vol mute - sink="$(wpctl get-volume '@DEFAULT_AUDIO_SINK@')" - if grep -q MUTED <<< "$sink"; then - sink_vol='🔇' - return + read -r vol mute < <(wpctl get-volume '@DEFAULT_AUDIO_SINK@') + vol="$((10#${vol/./}))" + if [ -n "$mute" ]; then sink_vol='🔇' + elif [ "$vol" -gt 67 ]; then sink_vol=" $vol" + elif [ "$vol" -gt 33 ]; then sink_vol=" $vol" + else sink_vol=" $vol" fi - vol="$(awk '{printf "%.0f", $2 * 100}' <<< "$sink")" - { [ "$vol" -gt 67 ] && sink_vol=" $vol"; } || - { [ "$vol" -gt 33 ] && sink_vol=" $vol"; } || - { sink_vol=" $vol"; } } function update_source_vol() { - local source vol + local vol mute - source="$(wpctl get-volume '@DEFAULT_AUDIO_SOURCE@')" - if grep -q MUTED <<< "$source"; then - source_vol='' - return + read -r vol mute < <(wpctl get-volume '@DEFAULT_AUDIO_SOURCE@') + vol="$((10#${vol/./}))" + if [ -n "$mute" ]; then source_vol='🔇' + else source_vol=" $vol" fi - source_vol=" $(awk '{printf "%.0f", $2 * 100}' <<< "$source")" } function update_net() { local dev j ssid sig - dev="$(ip route show default | sed -n 's/.*dev\s\+\(\w\+\).*/\1/p;q')" + dev="$(ip route | grep -oP 'default.*dev\s+\K[^\s]+')" j="$(networkctl status "$dev" --json=short)" case "$(jq -r .Type <<< "$j")" in ether) @@ -64,11 +63,12 @@ function update_net() { wlan) ssid="$(jq -r .SSID <<< "$j")" sig="$(awk "/$dev/{printf \"%.0f\", \$3}" /proc/net/wireless)" - { [ "$sig" -gt 56 ] && net="▂▄▆█ $ssid"; } || - { [ "$sig" -gt 38 ] && net="▂▄▆_ $ssid"; } || - { [ "$sig" -gt 21 ] && net="▂▄__ $ssid"; } || - { [ "$sig" -gt 3 ] && net="▂___ $ssid"; } || - { net="____ $ssid"; } + if [ "$sig" -gt 56 ]; then net="▂▄▆█ $ssid" + elif [ "$sig" -gt 38 ]; then net="▂▄▆_ $ssid" + elif [ "$sig" -gt 21 ]; then net="▂▄__ $ssid" + elif [ "$sig" -gt 3 ]; then net="▂___ $ssid" + else net="____ $ssid" + fi ;; *) net='⚠' diff --git a/.local/bin/vm b/.local/bin/vm index 951323b..a351314 100755 --- a/.local/bin/vm +++ b/.local/bin/vm @@ -7,8 +7,12 @@ OVMF_CODE=/usr/share/edk2/x64/OVMF_CODE.4m.fd OVMF_VARS=/tmp/OVMF_VARS.4m.fd set -x -[ -f "$OVMF_VARS" ] || cp -f /usr/share/edk2/x64/OVMF_VARS.4m.fd "$OVMF_VARS" -[ -f "$DISK" ] || qemu-img create -f qcow2 "$DISK" 20G +if [ -f "$OVMF_VARS" ]; then + cp -f /usr/share/edk2/x64/OVMF_VARS.4m.fd "$OVMF_VARS" +fi +if [ -f "$DISK" ]; then + qemu-img create -f qcow2 "$DISK" 20G +fi qemu-system-x86_64 \ -accel kvm \ -M q35 \ diff --git a/.local/bin/vol b/.local/bin/vol index 846aaa4..b89cc68 100755 --- a/.local/bin/vol +++ b/.local/bin/vol @@ -19,8 +19,11 @@ function update_vol() { case "$1" in +*|-*) CUR="$(($CUR + $1 - $CUR % $1 + $CUR % $1 * 10 / $1 / 5 * $1))" - [ "$CUR" -lt 0 ] && CUR=0 - [ "$CUR" -gt 150 ] && CUR=150 + if [ "$CUR" -lt 0 ]; then + CUR=0 + elif [ "$CUR" -gt 300 ]; then + CUR=150 + fi ;; *) CUR="$1" @@ -40,7 +43,9 @@ else if [[ "$1" =~ [0-9] ]]; then update_vol "$1" fi - [ -n "$MUTE" ] && wpctl set-mute "$DEV" 0 + if [ -n "$MUTE" ]; then + wpctl set-mute "$DEV" 0 + fi fi kill "-$SIG" "$(cat "$HOME/.cache/pidofbar")" diff --git a/.local/bin/vpn b/.local/bin/vpn index 9171c51..95a4be6 100755 --- a/.local/bin/vpn +++ b/.local/bin/vpn @@ -1,24 +1,26 @@ #!/bin/bash -e -function off() { - local ifs - - read -ra ifs < <(wg show interfaces) || true - for i in "${ifs[@]}"; do - wg-quick down "$i" - done -} - -[ "$EUID" != 0 ] && { pkexec bash -c "DISPLAY='$DISPLAY' XAUTHORITY='$XAUTHORITY' $0 $*"; exit; } - -[ "$1" == off ] && { off; exit; } - -if [ -n "$DISPLAY" ]; then - if="$(basename -s.conf /etc/wireguard/*.conf | /usr/local/bin/dmenu)" +if tty -s; then + DMENU=fzf + SUDO=sudo else - select if in $(basename -s.conf /etc/wireguard/*.conf); do - break - done + DMENU=/usr/local/bin/dmenu + SUDO=pkexec +fi + +if [ "$EUID" != 0 ]; then + exec "$SUDO" env DISPLAY="$DISPLAY" XAUTHORITY="$XAUTHORITY" \ + "$BASH" -- "${BASH_SOURCE[0]}" "$@" +fi + +if [ -z "$1" ]; then + set -- "$(basename -s.conf /etc/wireguard/*.conf | "$DMENU")" +fi + +while read -r i; do + wg-quick down "$i" +done < <(wg show interfaces) + +if [ "$1" != off ]; then + wg-quick up "$1" fi -off -wg-quick up "$if" diff --git a/.local/bin/wlp b/.local/bin/wlp index bb6cf68..31d0fde 100755 --- a/.local/bin/wlp +++ b/.local/bin/wlp @@ -3,7 +3,9 @@ iwctl=(iwctl station "$(basename /sys/class/net/wlan*)") rfkill unblock wlan -"${iwctl[@]}" show | grep -q 'Scanning\s\+yes' || "${iwctl[@]}" scan +if ! "${iwctl[@]}" show | grep -q 'Scanning\s\+yes'; then + "${iwctl[@]}" scan +fi for _ in {0..29}; do if "${iwctl[@]}" show | grep -q '\s*State\s\+connected\s*$'; then diff --git a/.local/share/bash-completion/completions/ddev b/.local/share/bash-completion/completions/ddev index aa10170..b6166a9 100644 --- a/.local/share/bash-completion/completions/ddev +++ b/.local/share/bash-completion/completions/ddev @@ -1,3 +1,5 @@ +# vim: ft=bash + function _ddev() { cache="/tmp/${FUNCNAME[0]}" diff --git a/.local/share/bash-completion/completions/gi b/.local/share/bash-completion/completions/gi index 71cf315..c531edb 100644 --- a/.local/share/bash-completion/completions/gi +++ b/.local/share/bash-completion/completions/gi @@ -1,3 +1,5 @@ +# vim: ft=bash + function _gi() { cache="/tmp/${FUNCNAME[0]}" diff --git a/.local/share/bash-completion/completions/kctx b/.local/share/bash-completion/completions/kctx index a4f5cdc..6f5ecfd 100644 --- a/.local/share/bash-completion/completions/kctx +++ b/.local/share/bash-completion/completions/kctx @@ -1,3 +1,5 @@ +# vim: ft=bash + function _kctx() { [ "$COMP_CWORD" -ne 1 ] && return mapfile -t COMPREPLY < <(compgen -W \ diff --git a/.local/share/bash-completion/completions/kns b/.local/share/bash-completion/completions/kns index 6781879..d6c8e0a 100644 --- a/.local/share/bash-completion/completions/kns +++ b/.local/share/bash-completion/completions/kns @@ -1,3 +1,5 @@ +# vim: ft=bash + function _kns() { [ "$COMP_CWORD" -ne 1 ] && return mapfile -t COMPREPLY < <(compgen -W \ diff --git a/.local/share/bash-completion/completions/pac b/.local/share/bash-completion/completions/pac deleted file mode 100644 index 3abc060..0000000 --- a/.local/share/bash-completion/completions/pac +++ /dev/null @@ -1,2 +0,0 @@ -. /usr/share/bash-completion/completions/pacman -complete -F _pacman pac