tweak(qtile): run commands in zsh for shell features

This commit is contained in:
Infinidoge 2022-08-18 16:12:16 -04:00
parent 9f26f7a3e0
commit 82729bf336

View file

@ -54,6 +54,13 @@ class Apps:
""" """
return f"{terminal or cls.TERMINAL} {' '.join(args)} -- {program}" return f"{terminal or cls.TERMINAL} {' '.join(args)} -- {program}"
@classmethod
def shell_command(cls, command, args=tuple(), *, shell=None):
"""
Returns a string of a command to run a command in the shell, with the given arguments.
"""
return f'{shell or cls.SHELL} {" ".join(args)} -- "{command}"'
@classmethod @classmethod
def open_in_terminal(cls, program, args=tuple(), *, terminal=None): def open_in_terminal(cls, program, args=tuple(), *, terminal=None):
""" """
@ -61,6 +68,17 @@ class Apps:
""" """
return lazy.spawn(cls.terminal_command(program, args=args, terminal=terminal)) return lazy.spawn(cls.terminal_command(program, args=args, terminal=terminal))
@classmethod
def shell_in_terminal(
cls, command, sargs=tuple(), targs=tuple(), *, shell=None, terminal=None
):
"""
Opens a program in the terminal using the shell, with the given shell and terminal arguments.
"""
return cls.open_in_terminal(
cls.shell_command(command, sargs, shell=shell), targs, terminal=terminal
)
@classmethod @classmethod
def open_in_editor(cls, file_, args=tuple()): def open_in_editor(cls, file_, args=tuple()):
""" """
@ -261,12 +279,12 @@ keys = [
# Keys for spawning commands or applications # Keys for spawning commands or applications
Key( Key(
[Keys.SUPER], "r", [Keys.SUPER], "r",
lazy.spawncmd(), lazy.spawncmd(command=Apps.shell_command("%s", args=("-ic",))),
desc="Spawn a command using a prompt widget", desc="Spawn a command using a prompt widget",
), ),
Key( Key(
[Keys.SUPER, Keys.SHIFT], "r", [Keys.SUPER, Keys.SHIFT], "r",
lazy.spawncmd(prompt="shell", command=Apps.terminal_command("%s", args=("--hold",))), lazy.spawncmd(prompt="shell", command=Apps.terminal_command(Apps.shell_command("%s", args=("-ic",)), args=("--hold",))),
desc="Spawn a command in a shell using a prompt widget", desc="Spawn a command in a shell using a prompt widget",
), ),
Key( Key(