Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
dokutan committed Nov 29, 2020
1 parent d0ff4f5 commit eae7411
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
11 changes: 4 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Turn any input device into a dedicated macrodevice. This is a rewrite of [macroKeyboard](https://github.com/dokutan/macroKeyboard).

## What is the purpose of this program?
This program is designed to execute a command at the press of a button (or other input) from a dedicated device (e.g keyboard, gamepad, Arduino (over serial), keyboard indicators, etc.). The configuration is done in Lua, so a complex configuration is possible.
This program is designed to execute a command at the press of a button (or other input) from a dedicated device (e.g keyboard, gamepad, Arduino (over serial), keyboard indicators, etc.). The configuration is done in Lua, so a complex configuration is possible. It is possible to open multiple devices simultaneously.

## Installing
- Install all dependencies (on some distros you might need a dev package for the header files)
Expand Down Expand Up @@ -37,20 +37,17 @@ macrodevice-lua -c your-config.lua -f

### Lua config

To handle the incoming events and execute commands a Lua script is needed. For the details look at example.lua .
To handle the incoming events and execute commands a Lua script is needed. For the details look at ``example.lua``.

To easily create the input_handler function for your lua script, edit ``create-config.lua`` and execute
To easily create the input handler function for your lua script, edit ``create-config.lua`` and execute
```
macrodevice-lua -c create-config.lua
```

### Dealing with permissions
In most cases root privileges are needed to directly open an input device, however running this program as root creates a major security risk, as all macros are executed with root privileges as well. There are multiple ways to deal with this problem.

1. Start the program with root privileges, and drop these as soon as the device has been opened. This works in all cases where no root privileges are needed once the device has been opened. For this you need to [know your user id and group id](https://wiki.archlinux.org/index.php/Users_and_groups#User_database).
```
sudo macrodevice-lua -c your-config.lua -u your_user_id -g your_group_id
```
1. Start the program with root privileges, and drop these as soon as the device has been opened. This works in all cases where no root privileges are needed once all devices have been opened. See ``example.lua`` for details.
2. If the device is represented by a file, as with the libevdev backend, you can change the file permissions, or add your user to a group with access to the files of interest.
3. In case of the libusb and hidapi backends, you can create a [udev](https://wiki.archlinux.org/index.php/Udev) rule that allows read and write access to the device from your normal user.

Expand Down
3 changes: 3 additions & 0 deletions backends/macrodevice-libusb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ int macrodevice::device_libusb::open_device()
*/
int macrodevice::device_libusb::close_device()
{
if( m_device == NULL )
return 1;

// release interface 0
libusb_release_interface( m_device, 0 );

Expand Down
2 changes: 0 additions & 2 deletions macrodevice-lua.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,8 +374,6 @@ int main( int argc, char *argv[] )
{"help", no_argument, 0, 'h'},
{"config", required_argument, 0, 'c'},
{"fork", no_argument, 0, 'f'},
{"user", no_argument, 0, 'u'},
{"group", no_argument, 0, 'g'},
{0, 0, 0, 0}
};

Expand Down

0 comments on commit eae7411

Please sign in to comment.