You are here: Start Linux and Computers Launch program via DBus
Launch program via DBus PDF Print E-mail
Written by Andreas Böhler   
Monday, 22 March 2010 15:22

My brand new Tablet-PC features a sensor that detects in which position the screen is and triggers an acpi event upon swivel-up and swivel-down. I found quite some scripts to automatically rotate the screen and adjust the tablet according to the rotation, but most of them failed either immediately or stopped working after the upgrade to xf86-input-wacom. Here is a simple yet effective way to overcome this limitation.

 

I use the DBus system to send a message to a daemon running with user privileges that then executes the program. This way everything runs as the user it is intended for, including all environment variables. xrandr and xsetwacom are working quite well!

 

 

I launch dbus-exec-server.py via my session manager (XFCE) and then execute dbus-exec.py as the root user with the program to run as parameter.

Rotating the screen would become: dbus-exec.py xrandr -o normal

With the included dbus-exe.conf (which needs to be copied to  /etc/dbus-1/system.d) only the root user can send messages to dbus-exec!

 

Attachments:
Download this file (dbus-exec-server.py)dbus-exec-server.py[dbus-exec-server.py to be run as normal user]1 Kb
Download this file (dbus-exec.conf)dbus-exec.conf[dbus-exec.conf to be put in /etc/dbus-1/system.d that restricts access to the root user]0 Kb
Download this file (dbus-exec.py)dbus-exec.py[dbus-exec.py is the client to execute programs via DBus (need to be root!)]0 Kb
Comments (0)
Write comment
Your Contact Details:
Comment:
[b] [i] [u] [url] [quote] [code] [img]   
:angry::0:confused::cheer:B):evil::silly::dry::lol::kiss::D:pinch:
:(:shock::X:side::):P:unsure::woohoo::huh::whistle:;):S
:!::?::idea::arrow:
Security
Please input the anti-spam code that you can read in the image.
Last Updated on Monday, 22 March 2010 15:31
 
Template is Powered by www.schaffenskraft.info © 2008 | CSS 2.1 | XHTML 1.0