#!/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)