AutoYADM commit: 2025-04-22 17:45:06

This commit is contained in:
Daniel Fichtinger 2025-04-22 17:45:06 -04:00
parent b73faec60c
commit 31527457be
2 changed files with 14 additions and 12 deletions

View file

@ -1,7 +1,7 @@
#!/usr/bin/env fish
argparse q/quiet k/kill-on-exit h/help -- $argv
if test (count $argv) -e 0; or set -q _flag_h
if test (count $argv) -eq 0; or set -q _flag_h
echo "Helper script for opening Typst files from Helix in Zathura."
echo "Usage: (bind the following to a key)"
echo ':sh typst-zathura [opts] %{buffer_name}'
@ -44,22 +44,23 @@ function find_parent_process -a target
return 1
end
set -q _flag_k; and set parent_pid (find_parent_process hx)
if set -q _flag_k; and test -z "$parent_pid"
qecho "Couldn't find parent hx process!"
return $ret
if set -q _flag_k
set kill_parent
echo "kill flag set"
set parent_pid (find_parent_process hx)
if test -z "$parent_pid"
qecho "Couldn't find parent hx process!"
return $ret
end
end
# opens zathura, watching for helix closing
function zopen --wraps zathura
if set -q _flag_k
if set -q kill_parent
begin
zathura "$argv[1]" &>/dev/null &
set zathura_pid $last_pid
notify-send zathura "$zathura_pid"
notify-send hx $parent_pid
waitpid "$parent_pid"
notify-send "helix killed"
kill $zathura_pid
end &
else
@ -71,7 +72,7 @@ function find_pdf
set -l root $argv[1]
set -l base $argv[2]
set -l candidate (fd --no-ignore-vcs -F -1 "$base" "$root")
if test "$candidate" != ''
if test -n "$candidate"
zopen "$candidate"
else
return 1
@ -85,6 +86,7 @@ if not string match -q '*.typ' $src
end
set -l targ (string replace '.typ' '.pdf' $src)
set -l base (path basename --no-extension $src).pdf
if test -f "$targ" -a '' != ''
# zathura "$targ" &>/dev/null &
zopen "$targ"
@ -104,7 +106,7 @@ else
if set -q _flag_q
return 1
else
echo "$base couldn't be found!"
echo "$base couldn't be found at root $root!"
end
end
end