jschlatow / taskopen

Tool for taking notes and open urls with taskwarrior
GNU General Public License v2.0
364 stars 31 forks source link

auto-redirection of STDOUT and STDERR of non-terminal applications #92

Closed scottkosty closed 8 years ago

scottkosty commented 8 years ago

Sometimes when using taskopen, the user doesn't want to see the terminal output. For example, when launching chromium or nautilus or evince. This might be true when using taskopen right after a task search, because you do not want to have to scroll back up to get the task list that you created before. This situation is true also with VIT, whose display gets jumbled when receving STDOUT and STDERR from a forked command. But oftentimes you don't want to redirect STDOUT and STDERR. For example, if taskopen calls a terminal-based program, such as mutt, then you do not want to redirect.

One idea is the following: if the application is a terminal application, there would be an option for taskopen to not redirect STDOUT or STDERR. If it is not a terminal application, redirect both STDOUT and STDERR. The implementation is not as simple as the idea. How do we figure out whether a command is a terminal application or not? For example, xdg-open can execute many different kinds of commands. Well, we can find this information in the .desktop files. For example:

$ mimetype simple_text_file simple_text_file: text/plain $ xdg-mime query default text/plain vim.desktop $ cat /usr/share/applications/vim.desktop | grep Terminal Terminal=true

This feature would be turned off by default in Taskopen, because it is not very clean and might take some extra time to execute.

scottkosty commented 8 years ago

One workaround is to just launch a separate gnome-terminal for each ID for taskopen. e.g.

task <filter>
gnome-terminal -e "bash -c 'taskopen <ID>; $SHELL'"
gnome-terminal -e "bash -c 'taskopen <ID>; $SHELL'"
gnome-terminal -e "bash -c 'taskopen <ID>; $SHELL'"
jschlatow commented 8 years ago

@scottkosty As the decision about whether to show STDOUT/STDERR of the executed application or not is influenced by three factors (the calling application, the called application and personal preference), I find it hard to find a general solution to this.

So far, let's agree on the following facts:

  1. Terminal applications (i.e. their output) must never be redirected.
  2. Non-terminal application shall be redirected based on personal preference. This could go into the taskopenrc as a default setting.
  3. The should be a command line parameter that allows overridding the default setting for non-terminal applications.

Let me suggest another workaround for the moment that already adresses (1) and (2):

scottkosty commented 8 years ago

@ValiValpas I agree that your breakdown is a nice summary of the situation. I think your workaround is also reasonable and I think that is the most common situation.

Thanks for your time in thinking about this issue.