Blub / netevent

Input-Event device cloning utility. Use it together with ssh/netcat/... to share input devices among different machines.
GNU General Public License v2.0
148 stars 14 forks source link

how to emulate -ontoggle event on new version #7

Closed yuyuyak closed 6 years ago

yuyuyak commented 6 years ago

Hello again and thanks again for your effort. I would love to switch to the new version of netevent, however the deal breaker is that I cannot figure out how to toggle my keyboard leds as the ontoggle command does in the stable-1 version. I find the visual indication indispensable. .Here's an excerpt of what I use there: /home/<user>/netevent/netevent -nograb -hotkey EV_KEY:70:1 "@toggle" -ontoggle "echo \$GRAB > /home/<user>/.mytmpfs/.netevent_mouse;/home/<user>/netevent/toggle_scrolllock" -read /dev/input/by-id/usb-Logitech_USB_Keyboard-event-kbd | nc 192.168.1.132 1956 toggle_scrolllock is a simple bash script that uses xset to control the led. I've spent considerable time on it, can you give me a hint? Thanks. I'm trying to drum you up some business ;) https://forum.odroid.com/viewtopic.php?f=52&t=31227

Blub commented 6 years ago

I see no harm in adding an ontoggle command. Additionally the current output should be set as an environment variable when executing commands via exec, then it should be enough to add an additional command after output changing hotkeys like: hotkey key:1:2 "output foo; exec sh ~/scripts/update-my-output-display

yuyuyak commented 6 years ago

Thanks for quick response. I have fooled around with your suggestions but getting nowhere fast. I guess you mean we need to add a ontoggle command. I did browse through and try to comprehend how to do that a while back, will continue, but I'm a pretty lousy C programmer (and that's being polite). But I don't give up easily. I already have an output foo exec: command in my *.ne2 script that ssh's to the remote machine setting up the socket, standard stuff I copied from you here. So not quite sure what you have there, I couldn't get any variables exported and man exec was no help. `device add my-mouse /dev/input/by-id/usb-Logitech_Optical_USB_Mouse-event-mouse

device add my-kbd /dev/input/by-id/usb-Logitech_USB_Keyboard-event-kbd

hotkey add my-kbd key:70:1 grab toggle

hotkey add my-kbd key:70:0 nop

output add exec: ssh ~/netevent2 create

use `

Blub commented 6 years ago

Right I wasn't clear. I meant I want to add the env vars, they're not there yet, sorry. Was mostly a note to myself for the issue. I may have some time tonight or tomorrow for this.

Blub commented 6 years ago

Can you try the events branch? The manpage should contain all the new info: see the action set command, and the new daemon environment variable section at the bottom.

yuyuyak commented 6 years ago

Wonderful! Quick testing here shows no issues and does just what I wanted. I love a challenge, woke up this morning and got right on it before checking here: https://github.com/Blub/netevent/compare/master...yuyuyak:master But effort not wasted, I figured out long ago I learn more by doing than asking. Thank you very much, I use it constantly so any bugs will show up soon and I'll keep you posted.

Blub commented 6 years ago

Ah nice. In case you care for the feedback: Functionality wise your code goes into the right direction, although your use of putenv() seems off (it should contain the full "VAR=VALUE" string according to the manpage. I used setenv() instead which takes separate arguments for name and value. One big issue with your code though is the indentation/formatting ;-). For the rest: You have a fork/exec part in there which could use the shellCommand() helper which is already there which performs some cleanup tasks to not leak file descriptors to the new process (in case it forks off something that stays open longer). The difference is though that it waits for the process to finish, so longer tasks would indeed have to do another fork. (I might add a background option to exec at some point if people need it though). And yeah it looks like you ran into the exec command issue, sorry for that.