Gnome启动时启动脚本 [英] Start Script when Gnome Starts Up

查看:161
本文介绍了Gnome启动时启动脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在用户通过nx客户端登录后,我需要启动一个脚本.据我了解,Gnome是在用户登录后启动的(如果我错了,请纠正我).我应该将脚本放在哪里,以便用户登录后启动脚本?

相关信息: 我在redhat机器上工作,并假定我只能访问主目录(〜目录)中的文件,而不能访问/目录(有人可以告诉我该目录是什么吗?/one).我可以在主目录中修改/添加任何文件来帮助我启动脚本吗?如果我想从/目录启动脚本怎么办?

请澄清一下,因为可能尚不清楚. 〜/home目录隐含了home目录中的所有文件,包括子目录中的文件;与/目录相同.

解决方案

有一个为此目的的规范,它可与支持该规范的任何桌面环境(例如KDE,GNOME2,GNOME3等)一起使用.

您应该放置桌面条目 ~/.config/autostart(对于用户)或/etc/xdg/autostart(对于整个系统)内部的文件(扩展名为 .desktop ).在文件中,将脚本设置为运行(请参阅选项Exec).有关更多信息,请查看桌面应用程序自动启动规范.

例如,您可以放置​​具有以下内容的文件:

[Desktop Entry]
Name=MyScript
GenericName=A descriptive name
Comment=Some description about your script
Exec=/path/to/my/script.sh
Terminal=false
Type=Application
X-GNOME-Autostart-enabled=true

您还可以使用图形用户界面创建一个条目或添加一个新条目:

    GNOME 2中的
  • System/Preferences/Startup Applications.
  • 在GNOME 3中,按 Alt + R 并查找Startup Applications Preferences(键入名称的首字母将对其进行快速过滤)或从中运行gnome-session-properties在那儿或终点站.

I have a script that I need to start up after the user logs in via a nx client. From what I understand, Gnome starts up after a user logs in (correct me if I am wrong here). Where would I put my script so that it starts up after the user logs in?

Relevant Information: I am working on a redhat machine and assume that I have access only to the files within the home directory (the ~ directory) and not the / directory (can someone tell me what that directory is called? the / one). Are there any files that I can modify/add in the home directory that will help me start up my script? What about if I wanted to start the script from / directory?

Just to clarify since it might've not been clear. The ~/home directory implies all files in the home directory including the ones in the subdirectories; same with the / directory.

解决方案

There is a specification for this purpose, and it works with any desktop environment that supports the specification (eg. KDE, GNOME2, GNOME3, ...).

You should put a Desktop Entry file (with .desktop extension) inside of ~/.config/autostart (for a user) or /etc/xdg/autostart (for the whole system). In the file you set the script to run (see the option Exec). For more information, check the Desktop Application Autostart Specification.

For example, you can put a file with the following content:

[Desktop Entry]
Name=MyScript
GenericName=A descriptive name
Comment=Some description about your script
Exec=/path/to/my/script.sh
Terminal=false
Type=Application
X-GNOME-Autostart-enabled=true

You can also use the graphical user interface to create one entry or Add a new entry:

  • in GNOME 2 is System/Preferences/Startup Applications.
  • in GNOME 3, press Alt+R and look for Startup Applications Preferences (typing the first letters of the name will filter it quickly) or run gnome-session-properties from there or a terminal.

这篇关于Gnome启动时启动脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆