Fixed detached mode of execute
and updated its docstring.
This commit is contained in:
parent
b1341741cc
commit
97e2ad7bba
@ -40,21 +40,25 @@ def run_through_shell(command, enable_shell=False):
|
|||||||
|
|
||||||
def execute(command, detach=False):
|
def execute(command, detach=False):
|
||||||
"""
|
"""
|
||||||
Runs a command in background.
|
Runs a command in background. No output is retrieved. Useful for running GUI
|
||||||
No output is retrieved.
|
applications that would block click events.
|
||||||
Useful for running GUI applications that would block click events.
|
|
||||||
|
|
||||||
:param detach If set to `True` the application will be executed using the
|
:param command: A string or a list of strings containing the name and
|
||||||
`i3-msg` command (survives i3 in-place restart).
|
arguments of the program.
|
||||||
|
:param detach: If set to `True` the program will be executed using the
|
||||||
|
`i3-msg` command. As a result the program is executed independent of
|
||||||
|
i3pystatus as a child of i3 process. Because of how i3-msg parses its
|
||||||
|
arguments the type of `command` is limited to string in this mode.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
if detach:
|
||||||
|
if not isinstance(command, str):
|
||||||
|
raise TypeError("Detached mode expects a string as command.")
|
||||||
|
command = ["i3-msg", "exec", command]
|
||||||
|
else:
|
||||||
if not isinstance(command, list):
|
if not isinstance(command, list):
|
||||||
command = command.split()
|
command = command.split()
|
||||||
|
|
||||||
if detach:
|
|
||||||
command.insert(0, "exec")
|
|
||||||
command.insert(0, "i3-msg")
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
subprocess.Popen(command, stdin=subprocess.DEVNULL,
|
subprocess.Popen(command, stdin=subprocess.DEVNULL,
|
||||||
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||||
|
Loading…
Reference in New Issue
Block a user