IT HOW

무엇이는 물어보세요

컨텐츠로 건너뛰기
  • 프로그래밍
  • 파이썬
  • 자바
  • 자바스크립트
  • 리눅스
  • c#

원격 쉘을 통해 Gsettings를 변경하는 방법? autolaunch D-Bus

Puppet, 가상 터미널 또는 ssh를 통해 데스크톱 구성을 자동화해야합니다.

불행히도 gsettingsssh 또는 가상 터미널 을 통한 호출은 다음 을 제공합니다.

gsettings set org.compiz.core:/org/compiz/profiles/unity/plugins/core/ hsize "4"

(process:29520): dconf-WARNING **: failed to commit changes to dconf: Cannot autolaunch D-Bus without X11 $DISPLAY

내가 설정 한 경우 $DISPLAY와 export DISPLAY=:0.0는 다른 오류를 제공합니다 :

(process:29862): dconf-WARNING **: failed to commit changes to dconf: Could not connect: Connection refused

내가 무엇을 할 수 있을지?



답변

핵심은 DBUS_SESSION_BUS_ADDRESS환경 변수 를 설정하는 것입니다.

에 이 스레드 그 변수의 정확한 값을 얻을하는 데 도움이 다음과 같은 스크립트를 발견했다. dbus 설정을 변경하려는 데스크탑에서 실행중인 프로세스 이름이 필요합니다. (병렬로 실행중인 그래픽 세션이 둘 이상있을 수 있습니다). 전화합시다discover_session_bus_address.sh

#!/bin/bash

# Remember to run this script using the command "source ./filename.sh"

# Search these processes for the session variable
# (they are run as the current user and have the DBUS session variable set)
compatiblePrograms=( nautilus kdeinit kded4 pulseaudio trackerd )

# Attempt to get a program pid
for index in ${compatiblePrograms[@]}; do
    PID=$(pidof -s ${index})
    if [[ "${PID}" != "" ]]; then
        break
    fi
done
if [[ "${PID}" == "" ]]; then
    echo "Could not detect active login session"
    return 1
fi

QUERY_ENVIRON="$(tr '\0' '\n' < /proc/${PID}/environ | grep "DBUS_SESSION_BUS_ADDRESS" | cut -d "=" -f 2-)"
if [[ "${QUERY_ENVIRON}" != "" ]]; then
    export DBUS_SESSION_BUS_ADDRESS="${QUERY_ENVIRON}"
    echo "Connected to session:"
    echo "DBUS_SESSION_BUS_ADDRESS=${DBUS_SESSION_BUS_ADDRESS}"
else
    echo "Could not find dbus session ID in user environment."
    return 1
fi

return 0

이 스크립트를 사용하면 unity프로세스가 데스크탑에서 실행 중이고 설정을 적용하려는 경우 다음을 수행 할 수 있습니다 .

. ./discover_session_bus_address.sh unity
gsettings set org.compiz.core:/org/compiz/profiles/unity/plugins/core/ hsize "4"

그리고 일이 잘 작동합니다.


답변

프로비저닝하는 동안 SSH를 통해 방랑자 이미지를 변경하려고 시도하는 동안 이와 동일한 문제가 발생했습니다.

이 솔루션 /ubuntu//a/326773 은 적극적인 연결을 위해 모든 낚시를하지 않고 환경을 속이려고하는 트릭을 만들었습니다. YMMV …


답변

내 gsetting을 설정하는 POST-Install 스크립트가 있습니다. EUID가 0으로 스크립트를 실행하기 때문에 $ RUID (실제 사용자 ID)를 찾아야합니다.

여기 내 접근 방식이 있습니다 :

#!/usr/bin/env bash
# Get the Real Username
RUID=$(who | awk 'FNR == 1 {print $1}')

# Translate Real Username to Real User ID
RUSER_UID=$(id -u ${RUID})

# Set gsettings for the Real User
sudo -u ${RUID} DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/${RUSER_UID}/bus" gsettings set org.gnome.desktop.interface clock-show-date false

exit


답변


이 글은 우분투 카테고리에 분류되었고 dconf, gsettings, puppet, remote-access, remote-login 태그가 있으며 [호호] 야야님에 의해 2022년 1월 04일에 작성되었습니다.

글 네비게이션

← 그놈 터미널을 대체 할 수있는 좋은 방법은 무엇입니까? [닫은] 포인터를 삭제 한 후 포인터를 NULL로 만드는 것이 좋습니다. (Neil Butterworth)의 →

태그

  • android
  • apt
  • backup
  • bash
  • boot
  • c#
  • c++
  • command-line
  • css
  • debian
  • email
  • firefox
  • git
  • google-chrome
  • hard-drive
  • html
  • ios
  • iphone
  • java
  • javascript
  • keyboard
  • linux
  • mac
  • macbook
  • macos
  • microsoft-excel
  • mysql
  • networking
  • performance
  • php
  • python
  • security
  • shell
  • ssh
  • terminal
  • ubuntu
  • unix
  • usb
  • vim
  • virtualbox
  • windows
  • windows-7
  • windows-8
  • windows-10
  • wireless-networking

최신 글

  • 디스크 정리에 많은 시간과 CPU가 필요한 이유는 무엇입니까? 많은 시간을 소비하는 것 같습니다. 파일을
  • Vim에서 일반 모드와 삽입 모드 사이에서 커서를 어떻게 변경합니까? 모양 등)를 변경하는 방법을 알고
  • 집계 대 구성 무엇인지 이해하지만 집계가 무엇인지에 대한 명확한
  • Python 생성기 패턴에 해당하는 C ++
  • 소프트웨어 일반인의 경력 경로는 무엇입니까? [닫은] 전문에 대한 질문 이 질문에 영감을. 소프트웨어 전문가가

카테고리

  • c#
  • c++
  • git
  • html
  • 리눅스
  • 서버
  • 소프트웨어
  • 슈퍼유저
  • 안드로이드
  • 애플
  • 우분투
  • 자바
  • 자바스크립트
  • 파이썬
  • 프로그래밍
apthow.com powered by hoya
Go to mobile version