autorun firefox และเปิด 2 URL ใน CentOS9


ไฟล์ [Desktop Entry] สำหรับการ autostart (เปิด Firefox อัตโนมัติหลังบูต) ควรเก็บไว้ในตำแหน่งนี้:

~/.config/autostart/

เช่น สร้างไฟล์ชื่อ firefox-cctv.desktop:

nano ~/.config/autostart/firefox-cctv.desktop

แล้วใส่เนื้อหานี้ลงไป:

[Desktop Entry]
Type=Application
Exec=firefox http://test.com/c1.html http://test.com/8.html
Hidden=false
NoDisplay=false
X-GNOME-Autostart-enabled=true
Name=Firefox CCTV
Comment=Start Firefox with CCTV pages
อธิบายเพิ่มเติม:
  • Exec=firefox [url1] [url2] → เปิดทั้งสอง URL ในแท็บใหม่ของ Firefox
  • ถ้าอยากให้แต่ละ URL เปิดในหน้าต่างใหม่แยกกัน ให้เขียนแบบนี้:
Exec=firefox --new-window http://test.com/2.html && firefox --new-window http://test.com/8.html
สรุป:
  • แบบแรก: เปิด 2 URL ใน แท็บเดียวกันของหน้าต่างเดียว
  • แบบสอง: เปิด 2 URL ใน คนละหน้าต่าง
สิทธิ์ไฟล์

ตรวจสอบให้แน่ใจว่าไฟล์มีสิทธิ์ให้รันได้:

chmod +x ~/.config/autostart/firefox-cctv.desktop
สรุป:
  • ตำแหน่งไฟล์: ~/.config/autostart/
  • ชื่อไฟล์: อะไรก็ได้ แต่ต้องลงท้ายด้วย .desktop
  • ตรวจสอบสิทธิ์: chmod +x

ถ้าอยากให้ทุก user ใช้ไฟล์นี้ → วางไว้ที่:

/etc/xdg/autostart/

, ,