init
This commit is contained in:
Executable
+14
@@ -0,0 +1,14 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import pyudev
|
||||
import subprocess
|
||||
|
||||
context = pyudev.Context()
|
||||
monitor = pyudev.Monitor.from_netlink(context)
|
||||
monitor.filter_by(subsystem='block')
|
||||
|
||||
for device in iter(monitor.poll, None):
|
||||
if device.action == 'add':
|
||||
print(f"New device detected: {device.device_node}")
|
||||
subprocess.run(f"notify-send 'New device connected: {device.device_node}'", shell=True)
|
||||
Reference in New Issue
Block a user