Skip to content

Instantly share code, notes, and snippets.

@jrosco
Created January 9, 2015 05:33
Show Gist options
  • Save jrosco/c7369a651343ea622e4d to your computer and use it in GitHub Desktop.
Save jrosco/c7369a651343ea622e4d to your computer and use it in GitHub Desktop.
Get and Set IconFile via DBUS
#!/usr/bin/env python
import dbus
import os
import pwd
user_id = pwd.getpwuid(os.getuid()).pw_uid
icon_file = '/home/jrosco/.face'
bus = dbus.SystemBus()
user_name = bus.get_object('org.freedesktop.Accounts',
'/org/freedesktop/Accounts/User' + str(user_id))
properties_manager = dbus.Interface(user_name, dbus_interface='org.freedesktop.DBus.Properties')
icon_path = properties_manager.Get('org.freedesktop.Accounts.User', 'IconFile')
properties_manager.SetIconFile(icon_file, dbus_interface='org.freedesktop.Accounts.User')
print "Icon Path is %s" % icon_path
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment