|
This is the current workflow I have:
What I would like to happen is this: In the second stage, I want these two things:
This is what I have so far: tasks:
pdf:
desc: Create a pdf of the main.
cmds:
- mkdir -p pdf
- typst compile main.typ pdf/atlas.pdf
- task: zathura
sources:
- **/*.typ
- Taskfile.yml
interactive: true
generates:
- pdf/atlas.pdf
status:
- test -d pdf
method: checksum
zathura:
desc: Opens the current PDF with Zathura.
cmds:
- zathura pdf/atlas.pdf # ← I suspect this is going to get much more complex!
sources:
- pdf/atlas.pdf |
Replies: 2 comments 3 replies
|
Well, this works. - if ! pgrep -f "zathura pdf/atlas.pdf"; then bash -c "zathura pdf/atlas.pdf & disown"; fi # yamllint disable-lineIs there something different I could have done? |
|
Your one-liner works, but three things can be simpler. 1. zathura can detach itself. 2. Put the "is it already running?" check in 3. Make the viewer its own task that depends on the PDF. In your current layout, version: '3'
tasks:
pdf:
desc: Create a pdf of the main.
cmds:
- mkdir -p pdf
- typst compile main.typ pdf/atlas.pdf
sources:
- '**/*.typ'
- Taskfile.yml
generates:
- pdf/atlas.pdf
view:
desc: Build the PDF, and open it unless it is already open.
deps: [pdf]
cmds:
- zathura --fork pdf/atlas.pdf
status:
- pgrep -f "zathura pdf/atlas.pdf"Also note that Why a plain How I checked, with Task 3.53.1 on macOS and a stand-in viewer (a script that sleeps, since I don't have zathura there):
The |
Your one-liner works, but three things can be simpler.
1. zathura can detach itself.
zathura --fork FILEstarts a copy of itself in a new session (setsid) and returns right away, so you don't needbash -c "… & disown". The copy runs aszathura FILE(without--fork), so apgrep -f "zathura FILE"still finds it. man page, source2. Put the "is it already running?" check in
status:. That is whatstatusis for: if the command succeeds, Task skips the task and printsTask "view" is up to date.3. Make the viewer its own task that depends on the PDF. In your current layout,
task: zathurais one of thepdfcommands. When the PDF is up to date, Task skips the wholepdftask, so if you closed zath…