I want to create a script and bind it to a keyboard shortcut which let's me do the following:

  • If the focused program displays a .pdf file (for example evince or okular): Get the filename, search in the corresponding directory for a corresponding .tex file and open this with an editor
  • Do nothing (or display a message) if the file is not a pdf file or the tex file doesn' exist.

My problem is how to get the filename of the file opened in the focused window so that it works with every pdf reader. Any suggestions of how I could do this?

I am using xmonad if this matters.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.