因爲我寫的QT程序是帶界面的。baidu一天,也沒搞定怎麼自啓動問題,後來參照瞭如下帖子的回答,終於搞定了
https://forum.ubuntu.org.cn/viewtopic.php?t=379894
因爲有界面程序,所以添加到/etc/rc.local或/etc/rc5.d添加軟連接還是其他方法都沒有搞定。因爲程序啓動依賴界面啓動完成之後才能加載啓動,否則會報錯
具體解決方法如下:
sudo vi /etc/xdg/lxsession/Lubuntu/autostart
添加
@/home/firefly/QT-Code/qtTest
其中/home/firefly/QT-Code/爲文件路徑,qtTest爲自己編譯的可執行程序
@符號是 LXSession 自己定義的。參見 LXSession 源代碼中解析配置文件部分:
代碼: 全選
while ((line = dis.read_line (null)) != null)
{
string first = line[0:1];
switch (first)
{
case ("@"):
var builder = new StringBuilder ();
builder.append(line);
builder.erase(0,1);
string[] command = builder.str.split_set(" ",0);
AppType app = { command[0], command, true, "" };
app_list.add (app);
break;
case ("#"):
/* Commented, skip */
break;
default:
string[] command = line.split_set(" ",0);
AppType app = { command[0], command, false, "" };
app_list.add (app);
break;
}
}
如果沒有如上目錄,則查找下面幾個目錄嘗試一下(因爲我的目錄下沒有,故沒有嘗試)
vi ~/.config/autostart
leafpad .config/openbox/autostart
如何還沒有,自己可在.config目錄下自己查找一下autostart,添加上自啓動文件即可