You are not logged in.
Pages: 1
I want to have run a script after resume from hibernation in order to set my wacom tablet.
What is the appropriate way to do this?
I looked into https://wiki.archlinux.org/index.php/Pm-utils but couldn't find a solution.
Using Gnome 3.
Last edited by lunyx (2011-09-10 06:15:00)
Offline
Offline
I have seen this, but the hooks obviously apply system wide. Per user settings seem to be not possible.
Offline
You can script something that checks whether a user is logged on and only execute then. Suspend/resume actions are system-wide.
Got Leenucks? :: Arch: Power in simplicity :: Get Counted! Registered Linux User #392717 :: Blog thingy
Offline
Still a problem:
The script "setwacom" runs on resume but without effect. Starting the script manually works fine.
My hook:
#!/bin/bash
case "$1" in
hibernate|suspend)
;;
thaw|resume)
export DISPLAY=0:0
/home/my-user/bin/setwacom
;;
*)
;;
esac
Has anybody any idea, why it isn't working?
Last edited by lunyx (2011-09-10 08:01:30)
Offline
I think the problem is, that the hook runs as root and your trying to connect to the users desktop as root. Try something like
DISPLAY=:0 sudo -u your_user -H your_skript
Have a look at man sudo for details.
Offline
check the environment settings for your script.
how does setwacom actually set wacom? dbus? you need the propper dbus session variables set up.
i used to have something like this for gconf and netcfg, but it stopped working due to a dbus update some time ago, and since i dont use a proxy anymore, never bothered to fix it...
here it is (example, you need to fix this, and its an ugly hack).
#!/bin/bash
PROXY=$1
PORT=$2
ON_USER=$(cat /etc/passwd | grep :1000: | cut -d ':' -f 1)
#Assumes user directory is /home/$ON_USER
# Picks up the running dbus session if there is one
export $(grep -v "^#" /home/$ON_USER/.dbus/session-bus/`cat /var/lib/dbus/machine-id`-0)
# if there is no dbus session running, start one
if sudo -u $ON_USER test -z "$DBUS_SESSION_BUS_ADDRESS" ; then
eval `sudo -u $ON_USER dbus-launch --sh-syntax --exit-with-session`
fi
# some debugging info here, feel free to comment these out
echo $ON_USER
echo $DBUS_SESSION
echo $DBUS_SESSION_BUS_ADDRESS
echo $DBUS_SESSION_BUS_WINDOWID
echo $DBUS_SESSION_BUS_PID
if [ -n "$PROXY" ]; then
sudo -u $ON_USER "DBUS_SESSION_BUS_ADDRESS="$DBUS_SESSION_BUS_ADDRESS gconftool-2 --type bool --set /system/http_proxy/use_http_proxy true
sudo -u $ON_USER "DBUS_SESSION_BUS_ADDRESS="$DBUS_SESSION_BUS_ADDRESS gconftool-2 --type bool --set /system/http_proxy/use_same_proxy true
sudo -u $ON_USER "DBUS_SESSION_BUS_ADDRESS="$DBUS_SESSION_BUS_ADDRESS gconftool-2 --type string --set /system/http_proxy/host "$PROXY"
sudo -u $ON_USER "DBUS_SESSION_BUS_ADDRESS="$DBUS_SESSION_BUS_ADDRESS gconftool-2 --type int --set /system/http_proxy/port $PORT
sudo -u $ON_USER "DBUS_SESSION_BUS_ADDRESS="$DBUS_SESSION_BUS_ADDRESS gconftool-2 --type string --set /system/proxy/mode "manual"
else
sudo -u $ON_USER "DBUS_SESSION_BUS_ADDRESS="$DBUS_SESSION_BUS_ADDRESS "DBUS_SESSION_BUS_PID="$DBUS_SESSION_BUS_PID gconftool-2 --type string --set /system/proxy/mode "none"
sudo -u $ON_USER "DBUS_SESSION_BUS_ADDRESS="$DBUS_SESSION_BUS_ADDRESS gconftool-2 --type bool --set /system/http_proxy/use_http_proxy false
fi
hope it helps
ps. if your script does not require dbus, it might be even easier,
Last edited by eldragon (2011-09-10 12:09:26)
Offline
My setwacom script looks like this:
#!/bin/bash
xsetwacom set "Wacom Bamboo Pen Pen stylus" Threshold 12
xsetwacom set "Wacom Bamboo Pen Pen stylus" Suppress 1
xsetwacom set "Wacom Bamboo Pen Pen stylus" Rawsample 1
xsetwacom set "Wacom Bamboo Pen Pen stylus" Rotate Halftouch /home/my-user/bambooIsSet
The "touch" line changes the time stamp of bambooIsSet and shows, that the script in fact is executed but without any effect.
Very simple and no dbus involved. "xsetwacom" is delivered by the wacom tablet driver.
lula's proposal doesn't change anything.
Last edited by lunyx (2011-09-10 12:59:27)
Offline
When I open a terminal with Ctrl+Alt+F1 and try to execute a xsetwacom command, I get a error message "Invalid MIT-MAGIC-COOKIE-1 key ...".
As I understand it this means that the Xserver refuses the connection. Maybe that is what causes the above problem.
Is there a way to get the "valid MIT-MAGIC-COOKIE-1 key" in order to enable a connection? I found something related in the file .Xauthotity, but how to use it?
edit:
xauth list
delivers the MIT-MAGIC-COOKIE-1
Last edited by lunyx (2011-09-10 23:00:04)
Offline
With the following hook I get an error log after a resume:
#!/bin/bash
case "$1" in
hibernate|suspend)
;;
thaw|resume)
DISPLAY=:0 sudo -u my-user xsetwacom set "Wacom Bamboo Pen Pen stylus" Rotate half &> /home/my-user/hook_log
;;
*)
;;
esac
The error log shows:
Invalid MIT-MAGIC-COOKIE-1 keyFailed to open Display .
Obviously there is some kind of authentication needed. How to do that?
Last edited by lunyx (2011-09-11 15:37:03)
Offline
Pages: 1