• Ubuntu启动自动登录并启动程序


    最近在研究Ubuntu,需要在系统启动之后自动登录,并且启动某个程序。
    手上拿到的系统只有一个空桌面,其他嘛也没有,鼠标右键也不管用。于是借助自己的虚拟机研究发现,自动启动程序配置文件在:
    /home/username/.config/autostart下,并以.desktop命名。
    比如我做了一个例子。
    /home/henry/.config/autostart/mystartup.desktop内容如下:

    1. [Desktop Entry]  
    2. Type=Application  
    3. Encoding=UTF-8   
    4. Version=1.0   
    5. Name=No Name  
    6. Name[en_US]=MyStartup  
    7. Comment[en_US]=Try to start my programe  
    8. Comment=Start the ...  
    9. Exec=/home/henry/mysh.sh  
    10. X-GNOME_Autostart-enabled=true   
     
    Java代码
    1. [Desktop Entry]  
    2. Type=Application  
    3. Encoding=UTF-8  
    4. Version=1.0  
    5. Name=No Name  
    6. Name[en_US]=MyStartup  
    7. Comment[en_US]=Try to start my programe  
    8. Comment=Start the ...  
    9. Exec=/home/henry/mysh.sh  
    10. X-GNOME_Autostart-enabled=true  


    配置好后,在系统-首选项-会话这个配置页面中就可以看到这个新添加的启动程序项目。
    /home/henry/mysh.sh

    1. #!/bin/bash  
    2. /usr/bin/gnome-system-monitor  
    Java代码
    1. #!/bin/bash  
    2. /usr/bin/gnome-system-monitor  


    这里启动了系统监视器。
    上面工作做好后,重新启动系统,登录,就会看到系统监视器被启动起来。

    Ubuntu提供了指定用户自动登录的功能,设置好后不需要用户输入密码,直接进入X环境。
    配置是在系统-管理-登录窗口,在Security标签页中有Enable Automatic Login项,选中并指定用户即可。
    这 个是GDM的配置,GDM的配置文件是在/etc/gdm/下,有gdm.conf(GDM的默认配置项,不要手动修改)和gdm.conf- custom(自定义GDM配置),使用sudo gdmsetup命令即可打开上面说的(系统-管理-登录窗口)配置界面。当在界面上进行修改后,可以打开gdm.conf-custom文件查看,能够 发现相关内容已经改变。
    比如在我这里我直接手动修改gdm.conf-custom内容为:

    1. [daemon]  
    2. AutomaticLoginEnable=true   
    3. AutomaticLogin=henry  
    4. [security]  
    5.   
    6. [xdmcp]  
    7.   
    8. [gui]  
    9.   
    10. [greeter]  
    Java代码
    1. [daemon]  
    2. AutomaticLoginEnable=true  
    3. AutomaticLogin=henry  
    4. [security]  
    5. [xdmcp]  
    6. [gui]  
    7. [greeter]  


    保存并重新启动,系统自动登录并启动了系统监视器。
    总结
    作为程序员,不免要根据用户需求针对某些操作系统进行一些设置,这些设置需要直接修改配置文件,所以要定位好配置文件。
    Ubuntu的自动启动的配置文件在用户目录下.config/autostart文件夹中,以.desktop命名的文件。
    Ubuntu的自动登录的配置文件是/etc/gdm/gdm.conf-custom。

    [Desktop Entry]
    Encoding=UTF-8
    Version=0.9.4
    Type=Application
    Name=player
    Comment=start player demo
    Exec=/home/player/start_app.sh
    StartupNotify=false
    Terminal=false
    Hidden=false

  • 相关阅读:
    char *详细指针
    UIScrollViewA都PI得知。
    Android动画之二:View Animation
    计算机基本知识拾遗(七)页面缓存数据的同步和恢复机制页
    得到Android系统语言设置
    Harry Potter and the Prisoner of Azkaban
    zerglurker的c语言教程006——第一功能
    ExtJs迄今datefield控制设置默认值
    quick 2.23 它们的定义c++代码lua与总结的一些细节
    uva live 6190 Beautiful Spacing (二分法+dp试 基于优化的独特性质)
  • 原文地址:https://www.cnblogs.com/subo_peng/p/5258025.html
Copyright © 2020-2023  润新知