Compare commits

..

3 commits

Author SHA1 Message Date
Alexander Gehrke
639b2ce632 cleanup 2026-01-11 15:35:26 +01:00
Alexander Gehrke
fd643852d4 qrshow: handle additional arguments to qrencode 2026-01-11 15:34:46 +01:00
Alexander Gehrke
31a59f0207 improve next-in-path handling, fix line endings 2026-01-11 15:33:53 +01:00
17 changed files with 79 additions and 55 deletions

View file

@ -2,6 +2,7 @@
#dep:g8 #dep:g8
source ${$(realpath "$0"):h:h}/lib/next-in-path.zsh source ${$(realpath "$0"):h:h}/lib/next-in-path.zsh
G8=$(next-in-path g8 $0) G8=$(next-in-path g8 $0)
if (( $? != 0 )); then exit 1; fi
args=() args=()
zparseopts -D -E \ zparseopts -D -E \

View file

@ -2,12 +2,19 @@
# Usage: next-in-path <program name> <current $0> # Usage: next-in-path <program name> <current $0>
typeset -U path typeset -U path
next-in-path() { next-in-path() {
entries=( $(which -a $1) ) local entries=( $(which -a $1) )
index=${entries[(ie)$2]} local index=${entries[(ie)$2]}
local result
if [[ $index -le ${#entries} ]]; then if [[ $index -le ${#entries} ]]; then
# found $0, use next entry # found $0, use next entry
echo $entries[$((index + 1))] result=$entries[$((index + 1))]
else else
echo $entries[1] result=$entries[1]
fi
if [[ -n $result ]]; then
echo $result
else
return 1
fi fi
} }

View file

@ -9,4 +9,6 @@ fi
envwrapconf=${XDG_CONFIG_HOME:-$HOME/.config}/envwrap/$program envwrapconf=${XDG_CONFIG_HOME:-$HOME/.config}/envwrap/$program
[[ -e $envwrapconf ]] && source $envwrapconf [[ -e $envwrapconf ]] && source $envwrapconf
$(next-in-path "$program" $0) "$@" next=$(next-in-path "$program" $0)
if (( $? != 0 )); then exit 1; fi
$next "$@"

View file

@ -1,4 +1,6 @@
#!/bin/zsh #!/bin/zsh
source ${$(realpath "$0"):h:h}/lib/next-in-path.zsh source ${$(realpath "$0"):h:h}/lib/next-in-path.zsh
export PASSWORD_STORE_ENABLE_EXTENSIONS=true export PASSWORD_STORE_ENABLE_EXTENSIONS=true
$(next-in-path pass $0) $@ next=$(next-in-path pass $0)
if (( $? != 0 )); then exit 1; fi
$next $@

View file

@ -3,5 +3,5 @@
if [[ -z "$1" ]]; then if [[ -z "$1" ]]; then
qrencode -s 40 -o - qrencode -s 40 -o -
else else
qrencode -s 40 "$*" -o - qrencode -s 40 -o - -- "$*"
fi | feh -ZF - fi | feh -ZF -

View file

@ -11,4 +11,7 @@ profile_dir=${XDG_DATA_HOME:-$HOME/.local/share}/jails/webapp-$profile
mkdir -p $profile_dir mkdir -p $profile_dir
exec firejail ${XAUTHORITY:+--whitelist=$XAUTHORITY} --private=$profile_dir chromium --restore-last-session=false --class=$profile "$@" exec firejail ${XAUTHORITY:+--whitelist=$XAUTHORITY} \
--dbus-user=filter \
--private=$profile_dir \
chromium --restore-last-session=false --class=$profile "$@"

17
misc/xc
View file

@ -30,10 +30,18 @@ HELP
source ${$(realpath "$0"):h:h}/lib/common.zsh source ${$(realpath "$0"):h:h}/lib/common.zsh
function get_primary() { xclip -o -selection primary } if [[ -n $WAYLAND_DISPLAY ]]; then
function get_clipboard() { xclip -o -selection clipboard } function get_primary() { wl-paste -p }
function set_primary() { xclip -i -selection primary } function get_clipboard() { wl-paste }
function set_clipboard() { xclip -i -selection clipboard } 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 show_both() { function show_both() {
printf "\e[1;94mPrimary\e[0m\n" printf "\e[1;94mPrimary\e[0m\n"
get_primary get_primary
@ -95,4 +103,3 @@ case "${0:t}" in
esac esac
;; ;;
esac esac

View file

@ -1,5 +1,5 @@
#!/bin/zsh #!/bin/zsh
#dep:xi xbps-checkvers ag #dep:xi xbps-checkvers rg
source ${$(realpath "$0"):h:h}/lib/common.zsh source ${$(realpath "$0"):h:h}/lib/common.zsh
@ -62,7 +62,7 @@ else
succeed "on $branch" succeed "on $branch"
fi fi
packages=( $(ag -G 'template' restricted=yes srcpkgs/ | cut -d/ -f 2 | sort -u) ) packages=( $(rg -g 'template' restricted=yes srcpkgs/ | cut -d/ -f 2 | sort -u) )
version() { grep -Poe '(?<=^version=).*$' srcpkgs/$1/template } version() { grep -Poe '(?<=^version=).*$' srcpkgs/$1/template }
install_restricted() { install_restricted() {

View file

@ -1,4 +1,6 @@
#!/bin/zsh #!/bin/zsh
#dep:abcde #dep:abcde
source ${$(realpath "$0"):h:h}/lib/next-in-path.zsh source ${$(realpath "$0"):h:h}/lib/next-in-path.zsh
$(next-in-path abcde $0) -c ${XDG_CONFIG_HOME:-$HOME/.config}/abcde/abcde.conf $@ next=$(next-in-path abcde $0)
if (( $? != 0 )); then exit 1; fi
$next -c ${XDG_CONFIG_HOME:-$HOME/.config}/abcde/abcde.conf $@

View file

@ -1,4 +1,6 @@
#!/bin/zsh #!/bin/zsh
#dep:mbsync #dep:mbsync
source ${$(realpath "$0"):h:h}/lib/next-in-path.zsh source ${$(realpath "$0"):h:h}/lib/next-in-path.zsh
$(next-in-path mbsync $0) -c ${XDG_CONFIG_HOME:-$HOME/.config}/mbsyncrc $@ next=$(next-in-path mbsync $0)
if (( $? != 0 )); then exit 1; fi
$next -c ${XDG_CONFIG_HOME:-$HOME/.config}/mbsyncrc $@

View file

@ -1,4 +1,6 @@
#!/bin/zsh #!/bin/zsh
#dep:mvn #dep:mvn
source ${$(realpath "$0"):h:h}/lib/next-in-path.zsh source ${$(realpath "$0"):h:h}/lib/next-in-path.zsh
$(next-in-path mvn $0) -gs $XDG_CONFIG_HOME/maven/settings.xml $@ next=$(next-in-path mvn $0)
if (( $? != 0 )); then exit 1; fi
$next -gs $XDG_CONFIG_HOME/maven/settings.xml $@

View file

@ -1,5 +1,12 @@
#!/bin/zsh #!/bin/zsh
#dep:node #dep:node
local SELF=$(realpath "$0")
source ${$(realpath "$0"):h:h}/lib/next-in-path.zsh source ${$(realpath "$0"):h:h}/lib/next-in-path.zsh
export NODE_REPL_HISTORY="$XDG_DATA_HOME"/node_repl_history export NODE_REPL_HISTORY="$XDG_DATA_HOME"/node_repl_history
$(next-in-path node $0) $@ NEXT=$(next-in-path node $0)
if (( $? != 0 )); then exit 1; fi
if [[ $NEXT == $SELF ]]; then
exec /usr/bin/node $@
else
exec $NEXT $@
fi

View file

@ -2,4 +2,6 @@
#dep:npm #dep:npm
source ${$(realpath "$0"):h:h}/lib/next-in-path.zsh source ${$(realpath "$0"):h:h}/lib/next-in-path.zsh
export NPM_CONFIG_USERCONFIG=$XDG_CONFIG_HOME/npm/npmrc export NPM_CONFIG_USERCONFIG=$XDG_CONFIG_HOME/npm/npmrc
$(next-in-path npm $0) $@ next=$(next-in-path npm $0)
if (( $? != 0 )); then exit 1; fi
$next $@

View file

@ -5,4 +5,6 @@ RIPGREP_CONFIG_PATH=${XDG_CONFIG_HOME:-$HOME/.config}/ripgreprc
if [[ -e $RIPGREP_CONFIG_PATH ]]; then if [[ -e $RIPGREP_CONFIG_PATH ]]; then
export RIPGREP_CONFIG_PATH export RIPGREP_CONFIG_PATH
fi fi
$(next-in-path rg $0) $@ next=$(next-in-path rg $0)
if (( $? != 0 )); then exit 1; fi
$next $@

View file

@ -15,4 +15,6 @@ opts=(
"-Dsbt.override.build.repos=true" "-Dsbt.override.build.repos=true"
) )
export SBT_OPTS=${(j: :)opts} export SBT_OPTS=${(j: :)opts}
$(next-in-path sbt $0) $@ next=$(next-in-path sbt $0)
if (( $? != 0 )); then exit 1; fi
$next $@

View file

@ -1,32 +1,13 @@
#!/usr/bin/env bash #!/usr/bin/env bash
#dep:steam #dep:steam
FAKEHOME=${XDG_DATA_HOME:-$HOME/.local/share}/steam #FAKEHOME=${XDG_DATA_HOME:-$HOME/.local/share}/steam
echo "Starting Steam in faked home $FAKEHOME" >&2 #echo "Starting Steam in faked home $FAKEHOME" >&2
#
# Symlink a file to the fake home ## If .steam exists in ~/ and not in the fake home, move it to the fake home
link_dir() { #if [ -d $HOME/.steam ] && [ ! -d $FAKEHOME/.steam ]; then
# Replace HOME with FAKEHOME in the link name # echo "migrating $HOME/.steam to $FAKEHOME" >&2
link_name=$(echo $1 | sed "s|^$HOME|$FAKEHOME|") # mv $HOME/.steam $FAKEHOME/
#fi
# Creates the link's parent directory and symlinks it #export HOME=$FAKEHOME
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 $@ exec /usr/bin/steam $@

View file

@ -1,4 +1,6 @@
#!/bin/zsh #!/bin/zsh
#dep:wget #dep:wget
source ${$(realpath "$0"):h:h}/lib/next-in-path.zsh source ${$(realpath "$0"):h:h}/lib/next-in-path.zsh
$(next-in-path wget $0) --hsts-file="${XDG_DATA_HOME:-$HOME/.local/share}/wget-hsts" "$@" next=$(next-in-path wget $0)
if (( $? != 0 )); then exit 1; fi
$next --hsts-file="${XDG_DATA_HOME:-$HOME/.local/share}/wget-hsts" "$@"