X初始化時執行腳本一次

X初始化時執行腳本一次
  1. 如果我希望 bash 腳本在 X 啟動期間作為系統啟動的一部分執行一次,我應該將它放在哪裡。例如,我想在 X 啟動後以 root 使用者身分在我的電腦上啟動 VPN。

  2. 當 X 初始化時(在我的例子中假設為 GDM)或當使用者使用 DM(桌面管理器)登入時,它是否被視為登入 shell?

  3. 另外,我想只要使用 X 登入就可以執行程式。

答案1

當使用者登入 X 會話時您想要執行的任何內容,您都希望將.xinitrc.xsession文件放入使用者的$HOME.

這個頁面有一個很好的解釋:

http://fluxbox.sourceforge.net/docbook/en/html/app-setup.html

答案2

你應該把它們放進去.xinitrc。這是我的 :

#!/bin/zsh
#Map Capslock to ESC
setxkbmap -option caps:escape &
#Wallpaper
feh --bg-scale /mnt/data/Dropbox/pic/character/samurai.png
#turn off beep sound
xset -b
#mouse speed
xset m 1/5
#keyboard repeat speed
xset r rate 200 30
#font
xset +fp /usr/share/fonts/local
xset fp rehash
#urxvtd daemon
urxvtd -q -f -o &
#Disable touchpad tapping and scrolling when typing
syndaemon -t -i 2 &
#Hide cursor
unclutter -keystroke &
#Redshift - change your screen temp to reduce eyestrain
redshift &
# Dropbox
dropboxd &
#dwm status
while true
do
  xsetroot -name "nXqd"
    sleep 20s
done &
#Window manager
exec dwm

相關內容