
나는 테마, 배경 등을 설정하기 위해 일부 dconf 재정의를 설정하는 대학의 Ubuntu 컴퓨터에 대한 간단한 스크립트를 작성했습니다. 그러나 로그인 화면 배경을 올바르게 설정하도록 할 수 없는 것 같습니다.
이 목적을 위한 스크립트 섹션:
#Set login background and remove dots
echo "Setting lightdm dconf settings"
xhost +SI:localuser:lightdm
su lightdm -c "gsettings set com.canonical.unity-greeter background '/background.png'"
su lightdm -c "gsettings set com.canonical.unity-greeter draw-grid false"
lightdm 사용자로 로그인한 터미널에 직접 입력하면 동일한 명령이 작동합니다. 예를 들면 다음과 같습니다.
sudo su lightdm -s /bin/bash
gsettings set com.canonical.unity-greeter background '/background.png'
gsettings set com.canonical.unity-greeter draw-grid false
배경화면을 미세하게 설정합니다.
명령은 작동하지만 스크립트는 작동하지 않는 이유에 대한 아이디어가 있습니까?
감사해요
답변1
"sudo bash"를 실행하거나 귀하의 경우 "sudo -c"(사용자를 변경할 때 스크립트를 일시 중지하거나 단순히 작동하지 않음)를 실행하는 대신 세 개의 작은 스크립트를 실행하는 방법으로 문제를 해결했습니다.
("chmod +x script_name.sh"를 사용하여 각 스크립트를 실행 가능하게 만드는 것을 잊지 마십시오)
첫 번째 스크립트는 내 install.sh입니다.
sudo cp third_script.sh /tmp # Copy third_script to tmp for easier access
sudo chmod 0755 /tmp/third_script.sh # This needs to be executable by lightdm
sudo bash second_script.sh # Runs next file
sudo rm /tmp/third_script.sh # Now we can remove the third script
그런 다음 second_script.sh에서 xhost에 lightdm을 추가하고 세 번째 스크립트 파일을 lightdm-user로 실행합니다.
#!/bin/bash
echo "$USER" # To see if root is running the script
xhost +SI:localuser:lightdm
su lightdm -s /tmp/third_script.sh
그리고 third_script는 마법이 일어나는 곳입니다:
#!/bin/bash
echo "$USER" # To see if lightdm is running the script
gsettings set com.canonical.unity-greeter background '/background.png'
gsettings set com.canonical.unity-greeter draw-grid false
이것은 나에게 효과적입니다! 더 쉬운 방법이 있으면 알려주세요.