Initial commit

This commit is contained in:
2026-07-29 13:29:46 +01:00
commit dcc44b05bd
8 changed files with 396 additions and 0 deletions

27
main.py Normal file
View File

@@ -0,0 +1,27 @@
import pyudev
def main() -> None:
context = pyudev.Context()
monitor = pyudev.Monitor.from_netlink(context)
monitor.filter_by(subsystem="block")
print("Waiting for disks...")
for device in iter(monitor.poll, None):
if device.action == "add" and device.device_type == "disk":
print("\nDisk connected")
print(f"Device: {device.device_node}")
print(f"Name: {device.sys_name}")
print(f"Model: {device.get('ID_MODEL', 'Unknown')}")
print(f"Serial: {device.get('ID_SERIAL_SHORT', 'Unknown')}")
print(f"Bus: {device.get('ID_BUS', 'Unknown')}")
elif device.action == "remove" and device.device_type == "disk":
print("\nDisk disconnected")
print(f"Name: {device.sys_name}")
if __name__ == "__main__":
main()