是否有用于为 Gnome 3 设置用户个人资料图标/图块图片的 API?
我正在尝试以编程方式为 Gnome3/GDM 中的用户帐户设置 Gnome 3/GDM 3 用户个人资料/图块/脸部图片。这是我第一次尝试为 Linux 编写一个简单的程序,我对 API 并不熟悉,而且我的搜索几乎没有产生有用的信息。似乎可以将数据写入 .face 文件,但这似乎没有影响(或者我的文件类型/规格可能是错误的)。我从此论坛帖子中发现信息存储在 /var/lib/AccountsService/users 下的用户特定目录中,但是我希望我的程序以常规用户权限运行,并且(直接)写入此文件将需要提升的权限(尽管是非特权用户)能够通过 Gnome 设置 GUI 为其帐户指定图像)。
理想情况下,我也想对 KDE/KDM 和 Gnome 2 版本执行相同的操作。任何信息将不胜感激。谢谢!
I am trying to programmatic-ally set the Gnome 3/GDM 3 user profile/tile/face picture for a user's account in Gnome3/GDM. This is my first attempt at a simple program for Linux and I'm unfamiliar with the APIs and my searching has yielded little useful information. It seems like one can write data to a .face file but this doesn't seem to take affect (or perhaps my file type/specs are wrong). I found from this forum post that the information is stored in a user-specific directory under /var/lib/AccountsService/users, however I want my program to run with regular user privileges and writing (directly) to this file would require elevated privileges (despite an unprivileged user being able to specify an image for their account via the Gnome settings GUI).
Ideally, I would like to do the same for KDE/KDM and Gnome 2 versions as well. Any information would be greatly appreciated. Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的,这是我可以阐明的部分:
在任何 Unix'y 操作系统上,您可以始终依靠 GECOS 字段更新函数
putpwent.传统上,“真实姓名”是用户记录中 GECOS 字段的第一部分,直到第一个
,
。不同的系统在,
之后存储不同的扩展信息,包括部门名称、家庭和办公室电话号码等。在 Gnome 2 中,“他们”曾经使用 ~/.face 作为你的个人脸部图标。然而,在各种情况下,一个用户无法查看另一个用户的主文件夹(包括 root:网络文件系统、加密环回主目录等),因此在某些时候(我相信 3.0)放弃了这一点支持 /var/lib/AccountsService/icons/$YOURNAMEHERE 位置。
本着 Gnome 3 的精神,新系统(您最可能想要使用的系统)是 Accounts Services DBus 服务。您可以通过 DBus 获取用户对象并对其进行更改。接口是 org.freedesktop.Accounts / org.freedesktop.Accounts.User 并具有诸如 SetRealName 和 SetIconFile 之类的方法>。还有“一堆”其他方法,例如位置、语言、电子邮件等。
PS:您还可以使用
libaccountsservice
与其交互,而无需自己调用 DBus 。 EG:void act_user_set_real_name (ActUser *user,
和const char *real_name)
void act_user_set_icon_file (ActUser *user,
从该库导出。const char *icon_file)
但是,我不知道 K(或 K 的哪个版本)是否可能正在查看此 DBus 服务。所以,如果你真的想设置K信息,恐怕我不知道......
对于它的价值,你也可以让用户自己调整它
OK, here's the part I can shed some light on:
On any Unix'y OS, you can always fall back on the GECOS field update function
putpwent
. Traditionally, the “Real Name” is the first part of the GECOS field in the user record, up to the first,
. Different systems store different extended information after the,
, including things like department names, home and office phone numbers and the like.In Gnome 2, “they” used to use ~/.face as your personal face icon. However, there are all kinds of situations in which one user can't look into another's home folder (including root: things like network filesystems, encrypted loopback homes, and more), so this was abandoned at some point (I believe 3.0) in favour of the /var/lib/AccountsService/icons/$YOURNAMEHERE location.
In the spirit of Gnome 3, the new system (the one you most likely want to use) is the Accounts Services DBus service. You can obtain a user object over DBus, and alter it. The interface is
org.freedesktop.Accounts
/org.freedesktop.Accounts.User
and has methods likeSetRealName
andSetIconFile
. There are also a “bunch” of other methods for things like location, language, eMail, …PS: you can also use
libaccountsservice
to interact with it without calling the DBus yourself. EG:void act_user_set_real_name (ActUser *user,
andconst char *real_name)
void act_user_set_icon_file (ActUser *user,
are exported from that library.const char *icon_file)
However, I don't know if K (or which version(s) of K) might be looking at this DBus service. So, if you really want to set up the K information, I'm afraid I don't know…
For what it's worth, you can also just let the user adjust it themself with