diff options
Diffstat (limited to '.local/bin')
| -rwxr-xr-x | .local/bin/eibhear/clear-pkgs | 52 | ||||
| -rwxr-xr-x | .local/bin/eibhear/dmenudoas | 12 | ||||
| -rwxr-xr-x | .local/bin/eibhear/get-new-bg | 10 | ||||
| -rwxr-xr-x | .local/bin/eibhear/open-brave-in-profile | 8 | ||||
| -rwxr-xr-x | .local/bin/shortcuts | 18 | ||||
| -rwxr-xr-x | .local/bin/statusbar/sb-clock | 2 | ||||
| -rwxr-xr-x | .local/bin/statusbar/sb-internet | 8 |
7 files changed, 105 insertions, 5 deletions
diff --git a/.local/bin/eibhear/clear-pkgs b/.local/bin/eibhear/clear-pkgs new file mode 100755 index 0000000..a54174a --- /dev/null +++ b/.local/bin/eibhear/clear-pkgs @@ -0,0 +1,52 @@ +#!/usr/bin/env bash +# Source: https://gist.github.com/lfom/a7e0b79389e05644ce6a40129f531cdb +echo "** Starting cleaning pacman/AUR cache..." + +# pacman cache directory +pcachedir="$(awk '/Cache/ {print $3}' /etc/pacman.conf)" +# paru/AUR cache directory +acachedir="$HOME/.cache/paru/clone" + +toremove="$(comm -23 <(basename -a $(find $acachedir -mindepth 1 -maxdepth 1 -type d) | sort) <(pacman -Qqm) | xargs -r printf "$acachedir/%s\n")" + +echo "** Removing cache for foreign packages that are not installed anymore" +for deldir in $toremove; do + echo "* $deldir" + rm -rf "$deldir" +done + +pkgcache="$(find $acachedir -mindepth 1 -maxdepth 1 -type d | xargs -r printf "%s\n")" + +echo "** Removing untracked/source files for AUR packages" +for pkgdir in "$acachedir"/*/; do + + pkgname=$(basename "$pkgdir") + echo "* $pkgname" + + ## Remove untracked files (e. g. source/build files) excepting package files and main source files for installed version if non-git package + if [[ ! "$pkgname" =~ ^.*-git$ ]]; then + + pkgver="$(pacman -Q $pkgname 2>/dev/null | cut -d ' ' -f2 | cut -d '-' -f1 | cut -d ':' -f2)" + + cd "$pkgdir" + toremove="$(git ls-files --others | grep -v -e '^.*\.pkg\.tar.*$' -e '^.*/$' -e "^.*$pkgver.*$" | xargs -r printf "$pkgdir/%s\n")" + [ -z "$toremove" ] || rm -f $toremove + + fi + + [ -d "${pkgdir}/src" ] && echo "** removing: ${PWD}/${pkgdir}/src" && rm -rf ${pkgdir}/src/ || true + +done + +## Remove everything for uninstalled foreign packages, keep latest version for uninstalled native packages, keep two latest versions for installed packages +echo "** Removing cached AUR packages (keep latest version for installed ones)" +for deldir in $pkgcache; do + echo "* $deldir" + /usr/bin/paccache -qrk1 -c "$deldir" +done + +echo "** Removing cached pacman packages (keep latest version of uninstalled package, latest otherwise)" +/usr/bin/paccache -qruk1 -c "$pcachedir" +/usr/bin/paccache -qrk1 -c "$pcachedir" + +echo "** Done." diff --git a/.local/bin/eibhear/dmenudoas b/.local/bin/eibhear/dmenudoas new file mode 100755 index 0000000..c6971b6 --- /dev/null +++ b/.local/bin/eibhear/dmenudoas @@ -0,0 +1,12 @@ +#!/usr/bin/expect +if {[llength $argv] == 0} { + spawn -noecho doas + expect eof + exit 1 +} + +set pass [exec dmenu -fn Monospace-12 -P -p "Gimme pass: "] + +spawn -noecho doas {*}$argv +expect "doas (maks@laptop) password: " {send -- "$pass\r"} +expect eof diff --git a/.local/bin/eibhear/get-new-bg b/.local/bin/eibhear/get-new-bg new file mode 100755 index 0000000..6622dec --- /dev/null +++ b/.local/bin/eibhear/get-new-bg @@ -0,0 +1,10 @@ +#!/bin/sh +export DISPLAY=":0" +export DBUS_SESSION_BUS_ADDRESS="$(rg -a --null-data DBUS_SESSION_BUS_ADDRESS /proc/$(pgrep dbus | tail -1)/environ | tr "\0" "\n" | cut -d = -f 2-)" +export XDG_RUNTIME_DIR="/run/user/$(id -u)" +source "$HOME/.zprofile" + +bg="$XDG_DATA_HOME/bg.png" +curl -su 'maks:zaq1@WSX' https://jopek.eu/maks/wallpaper/bg.png -o "$bg" +setbg "$bg" + diff --git a/.local/bin/eibhear/open-brave-in-profile b/.local/bin/eibhear/open-brave-in-profile new file mode 100755 index 0000000..98c8888 --- /dev/null +++ b/.local/bin/eibhear/open-brave-in-profile @@ -0,0 +1,8 @@ +#!/bin/sh +profiles_dir="$XDG_CONFIG_HOME/BraveSoftware/Brave-Browser/" +local_state="$profiles_dir/Local State" +profiles="$(jq -r '.profile.info_cache | to_entries | map(.value.name + ":" + .key) | .[]' "$local_state")" + +profile_uname="$(echo "$profiles" | cut -d: -f1 | dmenu -i)" +profile_bname="$(echo "$profiles" | rg -m1 --pcre2 -o "(?<=^$profile_uname:).*")" +[ -n "$profile_bname" ] && brave --profile-directory="$profile_bname" diff --git a/.local/bin/shortcuts b/.local/bin/shortcuts index 08a2f57..9b9feb7 100755 --- a/.local/bin/shortcuts +++ b/.local/bin/shortcuts @@ -1,7 +1,9 @@ #!/bin/sh bmdirs="${XDG_CONFIG_HOME:-$HOME/.config}/shell/bm-dirs" +bmdirs_eibhear="${XDG_CONFIG_HOME:-$HOME/.config}/shell/eibhear/bm-dirs" bmfiles="${XDG_CONFIG_HOME:-$HOME/.config}/shell/bm-files" +bmfiles_eibhear="${XDG_CONFIG_HOME:-$HOME/.config}/shell/eibhear/bm-files" # Output locations. Unactivated progs should go to /dev/null. shell_shortcuts="${XDG_CONFIG_HOME:-$HOME/.config}/shell/shortcutrc" @@ -20,8 +22,14 @@ printf "# vim: filetype=sh\\nalias " > "$shell_shortcuts" printf "# vim: filetype=sh\\n" > "$shell_env_shortcuts" printf "\" vim: filetype=vim\\n" > "$vifm_shortcuts" +# Enable nesting +eval "echo \"$(cat "$bmdirs" "$bmdirs_eibhear")\"" | \ +awk "!/^\s*#/ && !/^\s*\$/ {gsub(\"\\\s*#.*$\",\"\"); + printf(\"[ -n \42%s\42 ] && export %s=\42%s\42 \n\",\$1,\$1,\$2) >> \"$shell_env_shortcuts\" }" +source "$shell_env_shortcuts" + # Format the `directories` file in the correct syntax and sent it to all three configs. -eval "echo \"$(cat "$bmdirs")\"" | \ +eval "echo \"$(cat "$bmdirs" "$bmdirs_eibhear")\"" | \ awk "!/^\s*#/ && !/^\s*\$/ {gsub(\"\\\s*#.*$\",\"\"); printf(\"%s=\42cd %s && ls -A\42 \\\\\n\",\$1,\$2) >> \"$shell_shortcuts\" ; printf(\"[ -n \42%s\42 ] && export %s=\42%s\42 \n\",\$1,\$1,\$2) >> \"$shell_env_shortcuts\" ; @@ -32,8 +40,14 @@ awk "!/^\s*#/ && !/^\s*\$/ {gsub(\"\\\s*#.*$\",\"\"); printf(\"map C%s cd \42%s\42 \n\",\$1,\$2) >> \"$lf_shortcuts\" ; printf(\"cmap ;%s %s\n\",\$1,\$2) >> \"$vim_shortcuts\" }" +# Enable nesting +eval "echo \"$(cat "$bmfiles" "$bmfiles_eibhear")\"" | \ +awk "!/^\s*#/ && !/^\s*\$/ {gsub(\"\\\s*#.*$\",\"\"); + printf(\"[ -n \42%s\42 ] && export %s=\42%s\42 \n\",\$1,\$1,\$2) >> \"$shell_env_shortcuts\" }" +source "$shell_env_shortcuts" + # Format the `files` file in the correct syntax and sent it to both configs. -eval "echo \"$(cat "$bmfiles")\"" | \ +eval "echo \"$(cat "$bmfiles" "$bmfiles_eibhear")\"" | \ awk "!/^\s*#/ && !/^\s*\$/ {gsub(\"\\\s*#.*$\",\"\"); printf(\"%s=\42\$EDITOR %s\42 \\\\\n\",\$1,\$2) >> \"$shell_shortcuts\" ; printf(\"[ -n \42%s\42 ] && export %s=\42%s\42 \n\",\$1,\$1,\$2) >> \"$shell_env_shortcuts\" ; diff --git a/.local/bin/statusbar/sb-clock b/.local/bin/statusbar/sb-clock index e9c2fe6..cab2116 100755 --- a/.local/bin/statusbar/sb-clock +++ b/.local/bin/statusbar/sb-clock @@ -26,4 +26,4 @@ case $BLOCK_BUTTON in 6) setsid -f "$TERMINAL" -e "$EDITOR" "$0" ;; esac -date "+%Y %b %d (%a) $icon%I:%M%p" +date "+%d %b %Y (%a) $icon%H:%M" diff --git a/.local/bin/statusbar/sb-internet b/.local/bin/statusbar/sb-internet index 6d0c513..549c3b8 100755 --- a/.local/bin/statusbar/sb-internet +++ b/.local/bin/statusbar/sb-internet @@ -17,8 +17,10 @@ case $BLOCK_BUTTON in 6) setsid -f "$TERMINAL" -e "$EDITOR" "$0" ;; esac +contains() { case $2 in *$1* ) return 0;; *) return 1;; esac ;} + # Wifi -if [ "$(cat /sys/class/net/w*/operstate 2>/dev/null)" = 'up' ] ; then +if contains "up" "$(cat /sys/class/net/w*/operstate 2>/dev/null)"; then wifiicon="$(awk '/^\s*w/ { print "📶", int($3 * 100 / 70) "% " }' /proc/net/wireless)" elif [ "$(cat /sys/class/net/w*/operstate 2>/dev/null)" = 'down' ] ; then [ "$(cat /sys/class/net/w*/flags 2>/dev/null)" = '0x1003' ] && wifiicon="📡 " || wifiicon="❌ " @@ -30,4 +32,6 @@ fi # TUN [ -n "$(cat /sys/class/net/tun*/operstate 2>/dev/null)" ] && tunicon=" 🔒" -printf "%s%s%s\n" "$wifiicon" "$ethericon" "$tunicon" +if [ "$wifiicon" = "❌ " -a "$ethericon" = "❎" ]; then + printf "%s%s%s\n" "$wifiicon" "$ethericon" "$tunicon" +fi |
