From d7c8b912e63c9a112d75f6b9e2e3f5d3c6975240 Mon Sep 17 00:00:00 2001 From: Maksymilian Jopek Date: Sat, 15 Mar 2025 14:46:54 +0100 Subject: Eibhear: Initial commit Some file deletion, small changes, some addition --- .local/bin/eibhear/clear-pkgs | 52 ++++++++++++++++++++++++++++++++ .local/bin/eibhear/dmenudoas | 12 ++++++++ .local/bin/eibhear/open-brave-in-profile | 8 +++++ .local/bin/shortcuts | 12 ++++++-- .local/bin/statusbar/sb-clock | 2 +- 5 files changed, 83 insertions(+), 3 deletions(-) create mode 100755 .local/bin/eibhear/clear-pkgs create mode 100755 .local/bin/eibhear/dmenudoas create mode 100755 .local/bin/eibhear/open-brave-in-profile (limited to '.local/bin') 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/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..3311349 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\" ; @@ -33,7 +41,7 @@ awk "!/^\s*#/ && !/^\s*\$/ {gsub(\"\\\s*#.*$\",\"\"); printf(\"cmap ;%s %s\n\",\$1,\$2) >> \"$vim_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" -- cgit v1.3.1