You are not logged in.
Is there a way to run a shell command as soon as a program has started up?
At the moment I use this workaround, but it obviously isn't very elegant...
programcmd &
while true; do
if (~/.i3/py-scripts/wincurrent.py | grep -i "programclass"); then
# do something
break
fi
done
wincurrent.py simply prints the class of the currently focused program.
An example of my usage (but there are more):
Working on a latex document in vim I want to preview it with my favourite pdf reader. I have a keybinding which opens the pdf reader and then resizes it so both code and pdf are well aligned (no text wrapping in vim).
Last edited by karlch (2015-09-08 12:13:58)
Offline
search [options] pattern Search for windows with titles, names, or classes with a regular expression pattern. [snip] --sync Block until there are results. This is useful when you are launching an application want want to wait until the application window is visible. For example: google-chrome & xdotool search --sync --onlyvisible --class "google-chrome"
Doesn't seem to cover the "currently focused" part, though, but do you need that?
Offline
Awesome, thank you! Seems to react a littlle bit slower than the workaround but definitely solves the problem as the nicer solution.
I don't, it was just the only way I could think of to solve the issue.
Offline
Working on a latex document in vim I want to preview it with my favourite pdf reader. I have a keybinding which opens the pdf reader and then resizes it so both code and pdf are well aligned (no text wrapping in vim).
I don't know how this fits with the goal you described in your post. What program/script do you need to have wait for what other program/script to finish starting up?
Have you looked into latexmk and it's (pre)view options?
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
I simply want to resize zathura and re-focus vim as soon as zathura has finished loading, it's probably easier if I just share what I use to explain.
This is in my ~/.vim/ftplugin/tex/tex_settings.vim
if len(serverlist()) > 1
nnoremap <leader>d :AsyncCommand(~/.vim/ftplugin/tex/start_zathura.sh %:t:r.pdf)<CR>:redraw<CR>
else
nnoremap <leader>d :!~/.vim/ftplugin/tex/start_zathura.sh %:t:r.pdf<CR><CR>:redraw<CR>
endif
And the now modified start_zathura.sh is the following:
#! /bin/bash
zathura &>/dev/null >/dev/null $1 &
xdotool search --sync --onlyvisible --class "Zathura"
i3-msg -q resize shrink width 50 px or 10 ppt
i3-msg -q focus left
I remember looking into it a while ago, but I shall do so again, thanks for the recommendation.
Currently I compile with rubber and a slightly modified tex_pdf.vim http://www.vim.org/scripts/script.php?script_id=3230
-- EDIT --
The viewing capabilites of latex-mk gave me the idea of implementing my viewing script into the BuildAndViewTexPdf function of tex_pdf.vim.
Thanks again! (:
Last edited by karlch (2015-09-08 13:12:44)
Offline
If it's working, that's great. But note that latex-mk != latexmk. The latter is part of texlive-core and seems much smoother to me.
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
Uhh, now how could i miss that?
I should really look into latexmk then although I don't think I will leave rubber anytime soon.
Offline