English 中文(简体)
B. 改变凯洛单元的格诺米背景
原标题:Changing gnome background from kernel module

I m trying to set a background from a kernel module, but I can t get it work.

What I ve already got is:

static void change_desktop(unsigned long unused);

static struct timer_list timer = TIMER_INITIALIZER(change_desktop, 0, 0);

static int umh_test( void ) {
    char *argv[] = { "/usr/bin/sudo", "-u", "mmarquez", "/bin/bash", "/home/mmarquez/script.sh", NULL };
    static char *envp[] = {
        "HOME=/home/mmarquez",
        "TERM=linux",
        "PATH=/sbin:/bin:/usr/sbin:/usr/bin",
        NULL
    };
    call_usermodehelper( argv[0], argv, envp, UMH_WAIT_PROC);
    return call_usermodehelper( argv[0], argv, envp, UMH_WAIT_PROC);
}

static void change_desktop(unsigned long unused) {
    umh_test()

    timer.expires = jiffies + 10 * HZ;
    add_timer(&timer);
}

int __init init_module(void) {
    change_desktop(0);
    return 0;
}

void __exit exit_module(void) {
}

文字是:

#!/bin/bash
nautilus_pid=$(pgrep -u $LOGNAME -n nautilus)
eval $(tr     
  < /proc/$nautilus_pid/environ | grep  ^DBUS_SESSION_BUS_ADDRESS= )
export DBUS_SESSION_BUS_ADDRESS
cp /home/mmarquez/Pictures/logo.png /home/mmarquez/Pictures/bg.png
gconftool-2 --set /desktop/gnome/background/picture_filename --type string /home/mmarquez/Pictures/bg.png

问题是,计算机在几秒后冻结。

如果不使用文字一,则用印刷机打印电文,它就会运转良好。 如果我不把文字与时俱进,但我却一再把文字放在一栏中,那是完美的。 但是,如果我不是/usr/bin/sudo,它也会冻结。 将静态结构与非静态左翼重新置于同一问题上。

I m using gnome 2 and kernel 2.6.32.37

问题回答

Having the kernel call user-space programs should generally be avoided:

  • 它把《油轮法》与政策决定联系起来,例如各种双手的位置及其选择。

  • It violates the layered structure of the system. In general, the kernel is supposed to serve calls from the user-space, rather than the opposite.

  • 如果用户空间处于意外状态,它就能够以意外的方式打破。

舱面支持用户-空间方案,但通常通过。 通常用于需要用户-空间合作(例如电力管理)的相对低级业务,或因其固有的限制而无法合理地在舱面空间开展业务。 尽管如此,它很少得到使用,只是在用尽了所有其他替代品之后。

You should probably consider these other alternatives first:

  • Have a daemon connect to your module through a Netlink socket. This method is used widely (e.g. udev) due to its familiarity for user-space programmers. There are user-space libraries (e.g. libnl) that significantly facilitate the creation of programs that use this approach.

  • 拥有一个sysfs文档,由你的模块编制和更新。

  • 是否通过新的装置节点与你的模块沟通。

  • 贵模块是否通过调和贵邮联发出烟雾信号——仅please 除非你别无选择,否则不会直接使用用户空间方案。

有一个how-to,其中介绍了舱内/用户-空间通信的最常见方法。

由于你担任了工作台,拥有一个敢于监测你的方言模块的台式台站肯定是可行的。 作为附带奖金,你将能够将你的一些法典移至用户空间,因为在用户空间中,分解设施的范围要广得多,而开发风险则低,耗时。

EDIT:

顺便说一句,应当从程序的角度来呼唤用户modehelper(。 把它从一个时间上说来并不满足这一要求——你的法典基本上中断了。





相关问题
Fastest method for running a binary search on a file in C?

For example, let s say I want to find a particular word or number in a file. The contents are in sorted order (obviously). Since I want to run a binary search on the file, it seems like a real waste ...

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

Tips for debugging a made-for-linux application on windows?

I m trying to find the source of a bug I have found in an open-source application. I have managed to get a build up and running on my Windows machine, but I m having trouble finding the spot in the ...

Trying to split by two delimiters and it doesn t work - C

I wrote below code to readin line by line from stdin ex. city=Boston;city=New York;city=Chicago and then split each line by ; delimiter and print each record. Then in yet another loop I try to ...

Good, free, easy-to-use C graphics libraries? [closed]

I was wondering if there were any good free graphics libraries for C that are easy to use? It s for plotting 2d and 3d graphs and then saving to a file. It s on a Linux system and there s no gnuplot ...

Encoding, decoding an integer to a char array

Please note that this is not homework and i did search before starting this new thread. I got Store an int in a char array? I was looking for an answer but didn t get any satisfactory answer in the ...

热门标签