Created
July 25, 2017 08:30
-
-
Save aduzsardi/cee1bed6662bd48ec1b1d86f9d2336ac to your computer and use it in GitHub Desktop.
How to change Gsettings via remote shell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://askubuntu.com/questions/457016/how-to-change-gsettings-via-remote-shell | |
#!/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 |
Author
aduzsardi
commented
Jul 25, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment