View previous topic :: View next topic |
Author |
Message |
seVes n00b
Joined: 06 Jan 2011 Posts: 54 Location: Germany
|
Posted: Mon Apr 15, 2013 4:37 am Post subject: notify-send as root |
|
|
hey guys,
i've some understanding-problems with notify-send and root.
let me explain:
i wrote a custom automount-script for udev, which only automount devices with specific id.
the rule is executed properly and the given script too.
in that script i want to make a bubble-notify to the user. the user is "alex" (its me ). X runs as alex. udev is running as root in boot-runlevel.
i found out, that this is a mistake by xauthority xcookie or something like that. i also tried to use sux or sudo but it doesnt work within the script.
except the script, by using a root-terminal in X it works. something is wrong but i dont know how to fix this.
automount.sh
Code: | ...
# for example, these variables are set:
# ICON="drive-removable-media-usb2"
# TYPE="USB stick"
# LABEL="my sexy usbstick"
# MNTPOINT="/media/usbstick"
...
notify-send -u low -i ${ICON} "${TYPE}" "Status:\t\tmounted\nLabel:\t\t${LABEL}\nMountpoint:\t${MNTPOINT}"' alex
...
|
thanks for helping me to fix this. +1
kind regards _________________ Alex / seVes |
|
Back to top |
|
|
amospalla n00b
Joined: 08 Mar 2013 Posts: 26
|
Posted: Mon Apr 15, 2013 9:41 am Post subject: |
|
|
$ emerge x11-misc/tinynotify-send-1.2.1 x11-misc/sw-notify-send
(mask tinynotify-send-1.2.1-r1 which has dependency problems)
then execute :
$ tinynotify-send -w message
Last edited by amospalla on Mon Apr 15, 2013 11:08 am; edited 1 time in total |
|
Back to top |
|
|
ppurka Advocate
Joined: 26 Dec 2004 Posts: 3256
|
Posted: Mon Apr 15, 2013 11:02 am Post subject: |
|
|
You can try three things, in succession (i.e., do 2. after you have tried out 1., but don't remove the modification of 1.) and see which one gives you the desired result.
1. Export the DISPLAY variable in your automount script. Like Code: | export DISPLAY=":0.0" |
2. Run the notify-send as the user alex by running it through su. Like Code: | su alex -c "your command" | Since it is run as root, there is no need to give the password.
3. If 2. doesn't work, then try to export the DBUS_SESSION_BUS_ADDRESS variable from the user's dbus session. You can also try to make the notification into a separate script that is run completely by the user alex. The code below tries to do this, assuming that the script is being run by alex. Code: | #!/usr/bin/env bash
cd "$HOME/.dbus/session-bus"
dbus_file="$( ls -t1 | head -n 1 )"
export DBUS_SESSION_BUS_ADDRESS="$( source "$dbus_file"; echo $DBUS_SESSION_BUS_ADDRESS )"
export DISPLAY=":0.0"
notify-send .... | And you can call this script, let's say it is called notify_user, from inside automount.sh by running it as the user Code: | #from automount.sh
su alex -c "/path/to/notify_user $MOUNT_POINT ..." |
The third part is the most elaborate and might be needed if 1, and 2 fails to show you the notification. Given how cryptic all the *kits are, you might need this part 3. _________________ emerge --quiet redefined | E17 vids: I, II | Now using kde5 | e is unstable :-/ |
|
Back to top |
|
|
seVes n00b
Joined: 06 Jan 2011 Posts: 54 Location: Germany
|
Posted: Mon Apr 15, 2013 1:53 pm Post subject: |
|
|
Thanks ppurka, 1 + 2 works perfectly for me.
Nice shoot! Thank you very much, for sure! +1 _________________ Alex / seVes |
|
Back to top |
|
|
SamuliSuominen Retired Dev
Joined: 30 Sep 2005 Posts: 2133 Location: Finland
|
Posted: Mon Apr 15, 2013 4:15 pm Post subject: |
|
|
amospalla wrote: | $ emerge x11-misc/tinynotify-send-1.2.1 x11-misc/sw-notify-send
(mask tinynotify-send-1.2.1-r1 which has dependency problems)
then execute :
$ tinynotify-send -w message |
You are solving the dependency problem wrong. You should NOT be masking 1.2.1-r1, or use 1.2.1. I'll remove 1.2.1 from tree to prevent others from making the same mistake.
Opened https://bugs.gentoo.org/466004 which will make it easier to install, but for now you can simply add all of...
Quote: |
~x11-libs/libnotify-0.7.5
=app-admin/eselect-notify-send-0*
~x11-misc/tinynotify-send-1.2.1
~x11-misc/sw-notify-send-1.2.1
|
...to /etc/portage/package.keywords |
|
Back to top |
|
|
amospalla n00b
Joined: 08 Mar 2013 Posts: 26
|
Posted: Mon Apr 15, 2013 4:56 pm Post subject: |
|
|
Thank you ssuominen, have it working with that. |
|
Back to top |
|
|
|