Sysbin now checks non-home path

This commit is contained in:
agryphus 2023-10-17 21:41:07 -04:00
parent 71f1006190
commit 7e558ef2b1
3 changed files with 24 additions and 18 deletions

View file

@ -14,8 +14,7 @@ alias wget='wget --hsts-file="$XDG_CACHE_HOME/wget-hsts"'
alias javafx='java --module-path /usr/lib/jvm/default/lib/ --add-modules javafx.base,javafx.controls,javafx.graphics,javafx.media,javafx.swing,javafx.web' alias javafx='java --module-path /usr/lib/jvm/default/lib/ --add-modules javafx.base,javafx.controls,javafx.graphics,javafx.media,javafx.swing,javafx.web'
alias sxiv='nsxiv' alias sxiv='nsxiv'
alias blueman='blueman-manager' alias blueman='blueman-manager'
alias spotify='spotify-launcher' alias spotify='dlkiller spotify'
alias spotify-launcher='dlkiller spotify-launcher'
alias zoom='dlkiller zoom' alias zoom='dlkiller zoom'
alias tor='torbrowser-launcher' alias tor='torbrowser-launcher'
if [ ! -z "$(grep nixos /etc/os-release)" ]; then if [ ! -z "$(grep nixos /etc/os-release)" ]; then

View file

@ -1,9 +0,0 @@
#!/usr/bin/env sh
# This script exists because I want to use dmenu instead of dmenu-wl, which passmenu
# defaults to if it sees that your $WAYLAND_DISPLAY variable is set. I also passed
# $PINENTRY_USER_DATA which will eventually reach the pinentry-wrapper script and launch
# a graphical pinentry as opposed to my curses default, since launching pinentry-curses
# outside of a terminal just breaks everything.
PINENTRY_USER_DATA=rofi WAYLAND_DISPLAY= /usr/bin/passmenu

View file

@ -2,13 +2,29 @@
# Finds the absolute path of a system binary by checking places in most-likely order. # Finds the absolute path of a system binary by checking places in most-likely order.
# Helpful for when overriding a binary with a script, meaning the script takes higher # Helpful for when overriding a binary with a script, meaning the script takes higher
# precedence in the path, but then the script needs to call the actual binary. # precedence in the path, but then the script needs to call the actual binary.
# I understand that this is not the most ~NixOS~ way of doing things.
if [ -e "/usr/bin/$1" ]; then if [ -z "$1" ]; then
echo "/usr/bin/$1" # No program prvided
elif [ -e "/bin/$1" ]; then exit 1
echo "/bin/$1"
elif [ -e "/run/current-system/sw/bin/$1" ]; then
echo "/run/current-system/sw/bin/$1"
fi fi
# Split the custom path into an array based on ":" (path separator)
IFS=":" read -ra path_dirs <<< "$PATH"
# Iterate through the directories in PATH_2
for dir in "${path_dirs[@]}"; do
if [ "$(echo "$dir" | cut -c 1)" = "~" ] || [ "$(echo "$dir" | cut -c 1-5)" = "/home" ]; then
# We are looking in a user's home, skip.
continue
fi
potential_path="$dir/$1"
if [ -x "$potential_path" ]; then
echo "$potential_path"
exit 0
fi
done
echo "command not found: $1"
exit 2 # Not found