I’m trying to set a keybinding in qtile. The command that works in my terminal is this:
xsel | mimic3
Checking the qtile docs shows I should be able to format it like this:
Key([mod], "s", lazy.spawn(['xsel | mimic3'],shell=True), desc='Custom command' ),
However, that doesn’t seem to work so I tried a different format
Key([mod], "s", lazy.spawn(["sh", "-c", "xsel | mimic3"]), desc='Custom command' ),
Still doesn’t work.
I discovered that if I use an early version of mimic, it does work. So, digging into that a little more; I installed the early version of mimic from the AUR and it’s a binary. While mimic3 I installed via python because it’s not in the AUR and it’s a python script.
the mimic3 python script is located: ~/.local/bin/mimic3
So, I’m thinking maybe there’s an issue piping xsel into a python script since qtile is python based as well. So, I started researching how to run an python script from inside another python script and found subprocess.run With that, I thought I’d make a function and just call the function with the hotkey
@lazy.function def mimic3_func(): ps1=subprocess.run(['xsel'],capture_output=True,text=True,check=True) subprocess.run(['python','/home/kodiak/.local/bin/mimic3'],input=ps1.stdout,check=True) Key([mod], "s", mimic3_func, desc='Custom command' ),
But, that just creates an error:
2022-10-15 17:46:31,463 ERROR libqtile base.py:cmd_function():L216 Exception calling "<function mimic3_func at 0x7f0120956710>": Traceback (most recent call last): File "/usr/lib/python3.10/site-packages/libqtile/command/base.py", line 213, in cmd_function function(self, *args, **kwargs) TypeError: mimic3_func() takes 0 positional arguments but 1 was given
Now I’m out of ideas, does anyone else have any?