Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to get command() to work #243

Closed
Liveo123 opened this issue Jun 22, 2022 · 8 comments
Closed

Unable to get command() to work #243

Liveo123 opened this issue Jun 22, 2022 · 8 comments
Labels

Comments

@Liveo123
Copy link

When I remap anything to command, nothing happens.

Here is an example of my default.conf:

[ids]

[main]

Remaps the escape key to capslock

esc = capslock

rightalt = toggle(calc)

[calc]

e = command("ls")
q = command(echo "here" &> ~/temp/err.txt)

@rvaiya
Copy link
Owner

rvaiya commented Jun 22, 2022

The command will be run with /bin/sh, '&>' is a bashism. Try echo "Hello World" > /tmp/test.log 2>&1 instead. Having said that, you probably don't really want to do this anyway, see #229 and #211.

@rvaiya rvaiya added the command label Jun 22, 2022
@Liveo123
Copy link
Author

Thanks for the reply. Really loving your program. Thanks for making it!!!

I tried that and it still did nothing. Can't seem to get it to work with any command. Tried with notify-send, rofi and various others, but nothing seems to run.

I am using Fedora. When I check /bin/sh it is simlinked to bash. Would that make any difference?

@rvaiya
Copy link
Owner

rvaiya commented Jun 23, 2022

Thanks.

To clarify, are you suggesting:

[main]

tab = command(echo "Tab pressed" > /tmp/test)

doesn't create /tmp/test when tab is pressed?

If so, please run the following and post the output after trying to execute a command:

sudo systemctl stop keyd && sudo KEYD_DEBUG=1 keyd

@Liveo123
Copy link
Author

It did not work.

I set up your:

[main]
command(echo "Tab pressed" > /tmp/test)

and I also had

[calc]
q = Command("rofi -show")

I ran your debug command and the rofi menu appeared. I had to hit escape a few times to get rid of it. I then hit a few keys, including the tab and then trying ralt followed by q. Got the following (I am using linux on an old MacBook Pro):
``

> sudo systemctl stop keyd && sudo KEYD_DEBUG=1 keyd
DEBUG: src/keyd.c:555: Debug mode activated
MainStarting keyd v2.4.1 (bb49007-dirty)
socket: /var/run/keyd.socket
device added: 05ac:0274 Apple Inc. Apple Internal Keyboard / Trackpad (/dev/input/event8)
        matched /etc/keyd/default.conf
DEBUG: src/layer.c:81: created [main] from "main"
DEBUG: src/layer.c:81: created [control] from "control:C"
DEBUG: src/layer.c:81: created [meta] from "meta:M"
DEBUG: src/layer.c:81: created [shift] from "shift:S"
DEBUG: src/layer.c:81: created [altgr] from "altgr:G"
DEBUG: src/layer.c:81: created [alt] from "alt:A"
DEBUG: src/layer.c:81: created [calc] from "calc"
        ERROR parsing /etc/keyd/default.conf:7: invalid key or action
        ERROR parsing /etc/keyd/default.conf:42: invalid key or action
DEBUG: src/keyd.c:122: Ignoring Broadcom Corp. Bluetooth USB Host Controller (not a keyboard)
command errorcommand errorcommand errorcommand errorcommand errorcommand errorcommand errordevice added: 05ac:8290 Broadcom Corp. Bluetooth USB Host Controller (/dev/input/event6)
        matched /etc/keyd/default.conf
^[^[^[^[^[^[^[^[^[^[^[^[^[^[^[^[^[^[^[^[^[^[^[^[^[^[^[^[^[^[^[^[^[^[^[^[^[^[^[^[^[^[^[
                DEBUG: src/keyboard.c:315: Activating layer calc
qqqDEBUG: src/keyboard.c:302: Deactivating layer calc
DEBUG: src/keyboard.c:315: Activating layer control
^CYo!Yo!Yo!Yo!Yo!Yo!Yo!Yo!Yo!Yo!Yo!Yo!Yo!Yo!Yo!Yo!Yo!Yo!⏎                     

@rvaiya
Copy link
Owner

rvaiya commented Jun 23, 2022

Please post the full output of default.conf. Your comment suggests that you did not use the config snippet I provided to you (and the logs seem to corroborate this, hence the parsing errors).

rofi is a bad test program since it relies on DISPLAY (as mentioned in the issues I linked to).

If your goal is to launch graphical programs from keyd I would strongly discourage this for reasons I have already outlined in the referenced links. The reason it worked in this case is because keyd inherited your session variables, in general you cannot rely on this.

@Liveo123
Copy link
Author

OK. Thanks. I will use my window manager instead. I just thought it would be nice to include it as a layer.

Here is my config file and thanks again!

[ids]

[main]

tab = command(echo "Tab pressed" > /tmp/test)

One shot the control, meta etc

NB oneshot is a mode where you can tap the key and it will allow for

one click on that layer

shift = oneshot(shift)
meta = oneshot(meta)
control = oneshot(control)
leftalt = oneshot(alt)
#rightalt = oneshot(altgr)

Maps capslock to escape when pressed and control when held.

capslock = overload(control, esc)

Remaps the escape key to capslock

esc = capslock

rightalt = toggle(calc)

[calc]

n = 1
m = 2
, = 3
h = 4
j = 5
k = 6
y = 7
u = 8
i = 9
7 = +
8 = -
9 = *
0 = /
q = Command("rofi -show")

@rvaiya
Copy link
Owner

rvaiya commented Jun 23, 2022

Please surround command output in backticks (```), otherwise github will render it as markdown. In your earlier post you wrote command(echo "Tab pressed" > /tmp/test), in your second you wrote tab = command(echo "Tab pressed" > /tmp/test). Which of these did you actually test?

According to the log output (parsing error on line 7), you tested the first one, which is probably why it didn't work. Does the issue still occur with the config you actually posted? If so, it is a bug, and I would appreciate your help in fixing it (even if you don't end up using the feature).

@rvaiya
Copy link
Owner

rvaiya commented Jun 25, 2022

I'm treating this as a configuration error. Feel free to reopen it if you can reproduce the problem using the config I posted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants