summaryrefslogtreecommitdiffstats
path: root/.local/bin
diff options
context:
space:
mode:
Diffstat (limited to '.local/bin')
-rwxr-xr-x.local/bin/eibhear/clear-pkgs52
-rwxr-xr-x.local/bin/eibhear/dmenudoas12
-rwxr-xr-x.local/bin/eibhear/open-brave-in-profile8
-rwxr-xr-x.local/bin/shortcuts12
-rwxr-xr-x.local/bin/statusbar/sb-clock2
5 files changed, 83 insertions, 3 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/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"