diff --git a/devel/g8 b/devel/g8 index 0385ef9..27f5a07 100755 --- a/devel/g8 +++ b/devel/g8 @@ -2,7 +2,6 @@ #dep:g8 source ${$(realpath "$0"):h:h}/lib/next-in-path.zsh G8=$(next-in-path g8 $0) -if (( $? != 0 )); then exit 1; fi args=() zparseopts -D -E \ diff --git a/lib/next-in-path.zsh b/lib/next-in-path.zsh index d5f646d..4fb2c95 100644 --- a/lib/next-in-path.zsh +++ b/lib/next-in-path.zsh @@ -2,19 +2,12 @@ # Usage: next-in-path typeset -U path next-in-path() { - local entries=( $(which -a $1) ) - local index=${entries[(ie)$2]} - local result + entries=( $(which -a $1) ) + index=${entries[(ie)$2]} if [[ $index -le ${#entries} ]]; then # found $0, use next entry - result=$entries[$((index + 1))] + echo $entries[$((index + 1))] else - result=$entries[1] - fi - - if [[ -n $result ]]; then - echo $result - else - return 1 + echo $entries[1] fi } diff --git a/misc/envwrap b/misc/envwrap index af0cf6f..e95cbb4 100755 --- a/misc/envwrap +++ b/misc/envwrap @@ -7,8 +7,6 @@ if [[ $program == "envwrap" ]]; then exit 0 fi -envwrapconf=${XDG_CONFIG_HOME:-$HOME/.config}/envwrap/$program +envwrapconf=${XDG_CONFIG_HOME:-$HOME/.config}/envwrap/$program [[ -e $envwrapconf ]] && source $envwrapconf -next=$(next-in-path "$program" $0) -if (( $? != 0 )); then exit 1; fi -$next "$@" +$(next-in-path "$program" $0) "$@" diff --git a/misc/pass b/misc/pass index d25c831..e175943 100755 --- a/misc/pass +++ b/misc/pass @@ -1,6 +1,4 @@ #!/bin/zsh source ${$(realpath "$0"):h:h}/lib/next-in-path.zsh export PASSWORD_STORE_ENABLE_EXTENSIONS=true -next=$(next-in-path pass $0) -if (( $? != 0 )); then exit 1; fi -$next $@ +$(next-in-path pass $0) $@ diff --git a/misc/qrshow b/misc/qrshow index 72d4425..78330cf 100755 --- a/misc/qrshow +++ b/misc/qrshow @@ -3,5 +3,5 @@ if [[ -z "$1" ]]; then qrencode -s 40 -o - else - qrencode -s 40 -o - -- "$*" + qrencode -s 40 "$*" -o - fi | feh -ZF - diff --git a/misc/webapp b/misc/webapp index 113d760..684aeaf 100755 --- a/misc/webapp +++ b/misc/webapp @@ -11,7 +11,4 @@ profile_dir=${XDG_DATA_HOME:-$HOME/.local/share}/jails/webapp-$profile mkdir -p $profile_dir -exec firejail ${XAUTHORITY:+--whitelist=$XAUTHORITY} \ - --dbus-user=filter \ - --private=$profile_dir \ - chromium --restore-last-session=false --class=$profile "$@" +exec firejail ${XAUTHORITY:+--whitelist=$XAUTHORITY} --private=$profile_dir chromium --restore-last-session=false --class=$profile "$@" diff --git a/misc/xc b/misc/xc index cf69315..da4b7ac 100755 --- a/misc/xc +++ b/misc/xc @@ -30,18 +30,10 @@ HELP source ${$(realpath "$0"):h:h}/lib/common.zsh -if [[ -n $WAYLAND_DISPLAY ]]; then - function get_primary() { wl-paste -p } - function get_clipboard() { wl-paste } - function set_primary() { wl-copy -p } - function set_clipboard() { wl-copy } -else - function get_primary() { xclip -o -selection primary } - function get_clipboard() { xclip -o -selection clipboard } - function set_primary() { xclip -i -selection primary } - function set_clipboard() { xclip -i -selection clipboard } -fi - +function get_primary() { xclip -o -selection primary } +function get_clipboard() { xclip -o -selection clipboard } +function set_primary() { xclip -i -selection primary } +function set_clipboard() { xclip -i -selection clipboard } function show_both() { printf "\e[1;94mPrimary\e[0m\n" get_primary @@ -103,3 +95,4 @@ case "${0:t}" in esac ;; esac + diff --git a/void/xrestricted b/void/xrestricted index 9b2aee8..6197f51 100755 --- a/void/xrestricted +++ b/void/xrestricted @@ -1,5 +1,5 @@ #!/bin/zsh -#dep:xi xbps-checkvers rg +#dep:xi xbps-checkvers ag source ${$(realpath "$0"):h:h}/lib/common.zsh @@ -12,7 +12,7 @@ if [[ ! -d $PACKAGES_DIR ]]; then fi if [[ ! -d $PACKAGES_DIR ]]; then <<-ERR - void-packages repo not found. Either set VOID_PACKAGES_DIR or place it at one of the + void-packages repo not found. Either set VOID_PACKAGES_DIR or place it at one of the following locations: - ${XDG_DATA_HOME:-$HOME/.local/share}/void-packages - $HOME/void-packages @@ -29,10 +29,10 @@ if [[ $help ]]; then Usage: xrestricted list xrestricted update xrestricted install - + Install restricted packages from a void source repo. Detected repo at: $VOID_PACKAGES_DIR - + Common options: -j, --jobs N Number of jobs to use -b, --branch B Use given branch instead of master @@ -62,7 +62,7 @@ else succeed "on $branch" fi -packages=( $(rg -g 'template' restricted=yes srcpkgs/ | cut -d/ -f 2 | sort -u) ) +packages=( $(ag -G 'template' restricted=yes srcpkgs/ | cut -d/ -f 2 | sort -u) ) version() { grep -Poe '(?<=^version=).*$' srcpkgs/$1/template } install_restricted() { diff --git a/xdg-wrappers/abcde b/xdg-wrappers/abcde index 37c8a2f..f99b0ae 100755 --- a/xdg-wrappers/abcde +++ b/xdg-wrappers/abcde @@ -1,6 +1,4 @@ #!/bin/zsh #dep:abcde source ${$(realpath "$0"):h:h}/lib/next-in-path.zsh -next=$(next-in-path abcde $0) -if (( $? != 0 )); then exit 1; fi -$next -c ${XDG_CONFIG_HOME:-$HOME/.config}/abcde/abcde.conf $@ +$(next-in-path abcde $0) -c ${XDG_CONFIG_HOME:-$HOME/.config}/abcde/abcde.conf $@ diff --git a/xdg-wrappers/mbsync b/xdg-wrappers/mbsync index 938f66f..8bf5def 100755 --- a/xdg-wrappers/mbsync +++ b/xdg-wrappers/mbsync @@ -1,6 +1,4 @@ #!/bin/zsh #dep:mbsync source ${$(realpath "$0"):h:h}/lib/next-in-path.zsh -next=$(next-in-path mbsync $0) -if (( $? != 0 )); then exit 1; fi -$next -c ${XDG_CONFIG_HOME:-$HOME/.config}/mbsyncrc $@ +$(next-in-path mbsync $0) -c ${XDG_CONFIG_HOME:-$HOME/.config}/mbsyncrc $@ diff --git a/xdg-wrappers/mvn b/xdg-wrappers/mvn index 1a37edb..44b8caf 100755 --- a/xdg-wrappers/mvn +++ b/xdg-wrappers/mvn @@ -1,6 +1,4 @@ #!/bin/zsh #dep:mvn source ${$(realpath "$0"):h:h}/lib/next-in-path.zsh -next=$(next-in-path mvn $0) -if (( $? != 0 )); then exit 1; fi -$next -gs $XDG_CONFIG_HOME/maven/settings.xml $@ +$(next-in-path mvn $0) -gs $XDG_CONFIG_HOME/maven/settings.xml $@ diff --git a/xdg-wrappers/node b/xdg-wrappers/node index d4f07d7..3355108 100755 --- a/xdg-wrappers/node +++ b/xdg-wrappers/node @@ -1,12 +1,5 @@ #!/bin/zsh #dep:node -local SELF=$(realpath "$0") source ${$(realpath "$0"):h:h}/lib/next-in-path.zsh export NODE_REPL_HISTORY="$XDG_DATA_HOME"/node_repl_history -NEXT=$(next-in-path node $0) -if (( $? != 0 )); then exit 1; fi -if [[ $NEXT == $SELF ]]; then - exec /usr/bin/node $@ -else - exec $NEXT $@ -fi +$(next-in-path node $0) $@ diff --git a/xdg-wrappers/npm b/xdg-wrappers/npm index 9bdd5a6..3d5012b 100755 --- a/xdg-wrappers/npm +++ b/xdg-wrappers/npm @@ -2,6 +2,4 @@ #dep:npm source ${$(realpath "$0"):h:h}/lib/next-in-path.zsh export NPM_CONFIG_USERCONFIG=$XDG_CONFIG_HOME/npm/npmrc -next=$(next-in-path npm $0) -if (( $? != 0 )); then exit 1; fi -$next $@ +$(next-in-path npm $0) $@ diff --git a/xdg-wrappers/rg b/xdg-wrappers/rg index edf56c2..09f1c3e 100755 --- a/xdg-wrappers/rg +++ b/xdg-wrappers/rg @@ -5,6 +5,4 @@ RIPGREP_CONFIG_PATH=${XDG_CONFIG_HOME:-$HOME/.config}/ripgreprc if [[ -e $RIPGREP_CONFIG_PATH ]]; then export RIPGREP_CONFIG_PATH fi -next=$(next-in-path rg $0) -if (( $? != 0 )); then exit 1; fi -$next $@ +$(next-in-path rg $0) $@ diff --git a/xdg-wrappers/sbt b/xdg-wrappers/sbt index 1e120fd..15b31ba 100755 --- a/xdg-wrappers/sbt +++ b/xdg-wrappers/sbt @@ -15,6 +15,4 @@ opts=( "-Dsbt.override.build.repos=true" ) export SBT_OPTS=${(j: :)opts} -next=$(next-in-path sbt $0) -if (( $? != 0 )); then exit 1; fi -$next $@ +$(next-in-path sbt $0) $@ diff --git a/xdg-wrappers/steam b/xdg-wrappers/steam index 9481a81..42c65cb 100755 --- a/xdg-wrappers/steam +++ b/xdg-wrappers/steam @@ -1,13 +1,32 @@ #!/usr/bin/env bash #dep:steam -#FAKEHOME=${XDG_DATA_HOME:-$HOME/.local/share}/steam -#echo "Starting Steam in faked home $FAKEHOME" >&2 -# -## If .steam exists in ~/ and not in the fake home, move it to the fake home -#if [ -d $HOME/.steam ] && [ ! -d $FAKEHOME/.steam ]; then -# echo "migrating $HOME/.steam to $FAKEHOME" >&2 -# mv $HOME/.steam $FAKEHOME/ -#fi -#export HOME=$FAKEHOME +FAKEHOME=${XDG_DATA_HOME:-$HOME/.local/share}/steam +echo "Starting Steam in faked home $FAKEHOME" >&2 + +# Symlink a file to the fake home +link_dir() { + # Replace HOME with FAKEHOME in the link name + link_name=$(echo $1 | sed "s|^$HOME|$FAKEHOME|") + + # Creates the link's parent directory and symlinks it + mkdir -p $(dirname $link_name) + if [ ! -d $link_name ]; then + echo "Linking $link_name" >&2 + ln -s $1 $link_name + fi +} + +mkdir -p $FAKEHOME + +link_dir $XDG_DATA_HOME # ~/.local/share +link_dir $XDG_CACHE_HOME # ~/.cache +link_dir $XDG_CONFIG_HOME # ~/.config + +# If .steam exists in ~/ and not in the fake home, move it to the fake home +if [ -d $HOME/.steam ] && [ ! -d $FAKEHOME/.steam ]; then + echo "migrating $HOME/.steam to $FAKEHOME" >&2 + mv $HOME/.steam $FAKEHOME/ +fi +export HOME=$FAKEHOME exec /usr/bin/steam $@ diff --git a/xdg-wrappers/wget b/xdg-wrappers/wget index 0f10895..4c45eda 100755 --- a/xdg-wrappers/wget +++ b/xdg-wrappers/wget @@ -1,6 +1,4 @@ #!/bin/zsh #dep:wget source ${$(realpath "$0"):h:h}/lib/next-in-path.zsh -next=$(next-in-path wget $0) -if (( $? != 0 )); then exit 1; fi -$next --hsts-file="${XDG_DATA_HOME:-$HOME/.local/share}/wget-hsts" "$@" +$(next-in-path wget $0) --hsts-file="${XDG_DATA_HOME:-$HOME/.local/share}/wget-hsts" "$@"