Quantcast
Channel: Active questions tagged ubuntu - Stack Overflow
Viewing all articles
Browse latest Browse all 5952

Scripts launched from udev do not have DISPLAY access anymore?

$
0
0

I have a script that runs from udev when I plug in my external drive. It always worked. But after upgrading from Linux 3.8/Xorg 1.12/Mint 14 (Ubuntu 12.10 compatible) to Linux 3.11/Xorg 1.14/Mint 16 (Ubuntu 13.10 compatible), it doesn't work anymore.

The script still runs, but none of the commands that require the display work. I figured that out by quitting the udev daemon and manually run udevd --debug for verbose output (more below).

This script used to work in Mint 14/12.10:

export DISPLAY=:0UUID=$1DEV=$2notify-send -t 700 "mounting $DEV ($UUID)"gnome-terminal -t "Backing up home..." -x rsync long line of datazenity --warning --text="Done."

But not anymore in Mint 16/13.10. In case you are wondering about possible solutions, I gradually added stuff and now it looks like this:

export DISPLAY=:0.0xhost +local:xhost +si:localuser:rootxhost +DISPLAY=:0.0export DISPLAY=:0.0UUID=$1DEV=$2notify-send -t 700 "mounting $DEV ($UUID)"gnome-terminal -t "Backing up home..." -x rsync long line of datazenity --warning --text="Done." --display=:0.0

But it still doesn't work. udevd --debug still shows this:

'(err) 'No protocol specified''(err) '''(err) '** (gnome-terminal:24171): WARNING **: Could not open X display''(err) 'No protocol specified''(err) 'Failed to parse arguments: Cannot open display: ''(err) 'No protocol specified''(err) '''(err) '** (zenity:24173): WARNING **: Could not open X display''(err) 'No protocol specified''(err) '''(err) '(zenity:24173): Gtk-WARNING **: cannot open display: :0.0''(err) 'No protocol specified'

Note that any bash logic works. Echoing test vars to >>/tmp/test.log works. It's just accessing the display that does not work anymore.

This is driving me crazy. What is the correct way to achieve this now?

Update 2013-12-20

So, in the previous Ubuntu, X commands would automatically find it's way to the current X using user.

Now, I seem to need these two things every time:

  • On the X using user:
    • xhost +si:localuser:root
  • On the root/udev side:
    • Copy X using users'~/.Xauthority file to /root

This 'feels' like a step back in time. This only works scripted when I log in as the same user everytime, so I can copy the .Xauthority file from that users' home when the script executes.

What 'trick' did the old Ubuntu use to have this done auto'magic'ally?


Viewing all articles
Browse latest Browse all 5952

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>