A chave é definir a variável de ambiente DBUS_SESSION_BUS_ADDRESS
.
Em este tópico , encontrei o seguinte script, que ajuda a obter o valor correto dessa variável. Requer o nome do processo, que está sendo executado na área de trabalho, no qual queremos alterar as configurações do dbus. (Pode haver mais de 1 executando sessões gráficas em paralelo). Vamos chamá-lo de 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 '. ./discover_session_bus_address.sh unity
gsettings set org.compiz.core:/org/compiz/profiles/unity/plugins/core/ hsize "4"
' '\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
Com este script, podemos fazer o seguinte, assumindo que unity
processo está sendo executado na área de trabalho, no qual queremos aplicar nossas configurações:
#!/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 '. ./discover_session_bus_address.sh unity
gsettings set org.compiz.core:/org/compiz/profiles/unity/plugins/core/ hsize "4"
' '\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
E as coisas devem funcionar bem.