codeblog

8/5/2008

dbus session access from remote

Filed under: Blogging, Networking, Ubuntu — kees @ 8:49 pm

In order to turn off the music playing on my desktop (in audacious) from my laptop in another room, I must figure out the DBUS session, and set it up before using the audacious session management control (like “--play-pause“).

$ ssh MACHINE "set -x
export DISPLAY=:0.0
PID=\$(pidof audacious)
if [ -z \"\$PID\" ]; then
    rhythmbox-client --pause
else
    export DBUS_SESSION_BUS_ADDRESS=\\
        \$(cat /proc/\$PID/environ | xargs -0 -n1 \\
            | grep ^DBUS_SESSION_BUS_ADDRESS= | cut -d= -f2-)
    audacious --play-pause
fi"

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google
  • Technorati
  • Identi.ca
  • Reddit
  • TwitThis

3 Comments »

  1. Useful tip, thanks!

    Do you know how to pull the DBUS_SESSION_BUS_ADDRESS for an active user, as opposed to a running program?

    I’d like to start a remote shell on demand that attaches to my remote dbus session (similar to above), but I don’t know what programs might be running at that time…

    Comment by SeanNo Gravatar — 1/6/2009 @ 9:48 am

  2. If the remote user is logged into X, you have all kinds of things. Use “pstree -lup” to see them. Probably the best might be x-session-manager, nautilus, or gnome-panel.

    Comment by keesNo Gravatar — 1/6/2009 @ 10:52 am

  3. which language is it? if i want to make a script out of it?
    #!/bin/bash doesnt work…

    Comment by GrunschNo Gravatar — 2/8/2009 @ 3:39 am

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress