是否有用于为 Gnome 3 设置用户个人资料图标/图块图片的 API?

发布于 2024-12-17 06:36:25 字数 470 浏览 1 评论 0原文

我正在尝试以编程方式为 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

简单爱 2024-12-24 06:36:25

好的,这是我可以阐明的部分:

在任何 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信息,恐怕我不知道......

对于它的价值,你也可以让用户自己调整它

       gnome-control-center user-accounts

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 like SetRealName and SetIconFile. 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,
const char *real_name)
and void act_user_set_icon_file (ActUser *user,
const char *icon_file)
are exported from that library.

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

       gnome-control-center user-accounts
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文