Skip to content

Instantly share code, notes, and snippets.

@CihatAltiparmak
Created July 6, 2018 23:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save CihatAltiparmak/f4945ad5883b9d06a5d94fa4be17668a to your computer and use it in GitHub Desktop.
Save CihatAltiparmak/f4945ad5883b9d06a5d94fa4be17668a to your computer and use it in GitHub Desktop.
import dbus
bus = dbus.SystemBus()
obj = bus.get_object("org.freedesktop.UDisks2", "/org/freedesktop/UDisks2/block_devices/sdb1")
iface = dbus.Iface(obj, "org.freedesktop.Dbus.Properties")
your_usb_device_name = iface.Get("org.freedesktop.UDisks2.Block","IdLabel")
print(your_usb_device_name)
@CihatAltiparmak
Copy link
Author

When you run this script,if usb device is inserted,this script gives you usb device name(IdLabel).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment