Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/carvilsi/systemd-usb-monitor-example

Simple example about systemd (sd-event & sd-device) to monitor USB devices on connection
https://github.com/carvilsi/systemd-usb-monitor-example

sd-device sd-event systemd unix

Last synced: 27 days ago
JSON representation

Simple example about systemd (sd-event & sd-device) to monitor USB devices on connection

Awesome Lists containing this project

README

        

# systemd USB monitor example

Simple example about systemd (sd-event & sd-device) to monitor USB devices on connection

## Compile and Run

Compile with **gcc**:

```
gcc usb_sd_device_monitor.c -o usbthingy `pkg-config --libs --cflags libsystemd`
```
And run it:

`./usbthingy`

**Note:** It's quite possible that on **Ubuntu** you'll need to install the `libsystem-dev` package. At least was my case for **Ubuntu 23.04** (lunar)

`sudo apt install libsystemd-dev`

Seems that on **Arch Linux** is already installed.

### Example of output

This is the output that I get when I connect my Zowie mouse:

```bash
syspath: /sys/devices/pci0000:00/0000:00:14.0/usb2/2-1/2-1.3
devtype: usb_device
subsystem: usb
first_sysattr: idProduct
first_tag: seat
id_vendor: 1af3
id_product: 0001
product: ZOWIE Gaming mouse
```

---
I will appreciate any comment, suggestions or improvement from you; Also if you like it please leave a :star: ;)