Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

non-functioning rotation #36

Closed
cpbl opened this issue Jan 2, 2014 · 22 comments
Closed

non-functioning rotation #36

cpbl opened this issue Jan 2, 2014 · 22 comments

Comments

@cpbl
Copy link

cpbl commented Jan 2, 2014

No one else is complaining, so this comes as a question not a bug.

When I call

think-rotate

from the command line,

  • the screen rotates, a vkeyboard comes up, and my customizations are called (the unity bar is fixed to the side of the screen).
  • the reverse happense when I call it again.

But when I rotate my screen, the only visible change is that the display rotates. That is, the keyboard does not come up and the unity bar does not appear.

If I remove all my customizations, the behaviour is the same (bad).

The logs in syslog seem to be the same in the two cases (command-line and triggered). Here they are.

First, the triggered rotation and reversion:

Jan  2 11:43:17 mylaptop think-rotate-hook[26742]: Using user meuser.
Jan  2 11:43:17 mylaptop think-rotate-hook[26743]: Will run “DISPLAY=:0.0 kdialog=false /usr/bin/think-rotate ”.
Jan  2 11:43:17 mylaptop think-rotate[26753]: Script starting up (args: ) …
Jan  2 11:43:17 mylaptop think-rotate[26755]: Running as user meuser.
Jan  2 11:43:17 mylaptop think-rotate[26756]: $HOME is set to /home/meuser.
Jan  2 11:43:17 mylaptop think-rotate[26757]: $HOME is now set to /home/meuser.
Jan  2 11:43:17 mylaptop think-rotate[26758]: Executing pre-hooks
Jan  2 11:43:17 mylaptop think-rotate[26759]: Finding current rotation
Jan  2 11:43:17 mylaptop think-rotate[26767]: Current status is normal.
Jan  2 11:43:17 mylaptop think-rotate[26768]: Infering new rotation
Jan  2 11:43:17 mylaptop think-rotate[26769]: Using default, setting to right.
Jan  2 11:43:17 mylaptop think-rotate[26770]: Rotating screen
Jan  2 11:43:18 mylaptop think-rotate[26772]: Rotating Wacom devices to cw.
Jan  2 11:43:18 mylaptop think-rotate[26785]: Starting or killing virtual keyboard
Jan  2 11:43:18 mylaptop think-rotate[26787]: Enabling/Disabling TrackPoint and TouchPad
Jan  2 11:43:18 mylaptop think-rotate[26803]: Toggling input device 14 to 0.
Jan  2 11:43:18 mylaptop think-rotate[26806]: Toggling input device 13 to 0.
Jan  2 11:43:19 mylaptop think-rotate[26808]: Executing post-hooks
Jan  2 11:43:19 mylaptop think-rotate[26810]: MEUSER's hook: Found tablet mode

Jan  2 11:43:22 mylaptop think-rotate-hook[26827]: Using user meuser.
Jan  2 11:43:22 mylaptop think-rotate-hook[26828]: Will run “DISPLAY=:0.0 kdialog=false /usr/bin/think-rotate normal”.
Jan  2 11:43:22 mylaptop think-rotate[26838]: Script starting up (args: normal) …
Jan  2 11:43:22 mylaptop think-rotate[26840]: Running as user meuser.
Jan  2 11:43:22 mylaptop think-rotate[26841]: $HOME is set to /home/meuser.
Jan  2 11:43:22 mylaptop think-rotate[26842]: $HOME is now set to /home/meuser.
Jan  2 11:43:22 mylaptop think-rotate[26843]: Executing pre-hooks
Jan  2 11:43:22 mylaptop think-rotate[26844]: Finding current rotation
Jan  2 11:43:22 mylaptop think-rotate[26852]: Current status is right.
Jan  2 11:43:22 mylaptop think-rotate[26853]: Infering new rotation
Jan  2 11:43:22 mylaptop think-rotate[26854]: User chose to set to normal.
Jan  2 11:43:22 mylaptop think-rotate[26855]: Rotating screen
Jan  2 11:43:22 mylaptop think-rotate[26857]: Rotating Wacom devices to none.
Jan  2 11:43:23 mylaptop think-rotate[26868]: Starting or killing virtual keyboard
Jan  2 11:43:23 mylaptop think-rotate[26870]: Enabling/Disabling TrackPoint and TouchPad
Jan  2 11:43:23 mylaptop think-rotate[26881]: Toggling input device 14 to 1.
Jan  2 11:43:23 mylaptop think-rotate[26883]: Toggling input device 13 to 1.
Jan  2 11:43:23 mylaptop think-rotate[26885]: Executing post-hooks
Jan  2 11:43:23 mylaptop think-rotate[26887]: MEUSER's hook: Found normal

And here is the command-line version:

Jan  2 11:43:27 mylaptop think-rotate[26902]: Script starting up (args: ) …
Jan  2 11:43:27 mylaptop think-rotate[26904]: Running as user meuser.
Jan  2 11:43:27 mylaptop think-rotate[26905]: $HOME is set to /home/meuser.
Jan  2 11:43:27 mylaptop think-rotate[26906]: $HOME is now set to /home/meuser.
Jan  2 11:43:27 mylaptop think-rotate[26907]: Executing pre-hooks
Jan  2 11:43:27 mylaptop think-rotate[26908]: Finding current rotation
Jan  2 11:43:27 mylaptop think-rotate[26916]: Current status is normal.
Jan  2 11:43:27 mylaptop think-rotate[26917]: Infering new rotation
Jan  2 11:43:27 mylaptop think-rotate[26918]: Using default, setting to right.
Jan  2 11:43:27 mylaptop think-rotate[26919]: Rotating screen
Jan  2 11:43:28 mylaptop think-rotate[26922]: Rotating Wacom devices to cw.
Jan  2 11:43:28 mylaptop think-rotate[26933]: Starting or killing virtual keyboard
Jan  2 11:43:28 mylaptop think-rotate[26935]: Enabling/Disabling TrackPoint and TouchPad
Jan  2 11:43:28 mylaptop think-rotate[26946]: Toggling input device 14 to 0.
Jan  2 11:43:28 mylaptop think-rotate[26949]: Toggling input device 13 to 0.
Jan  2 11:43:28 mylaptop think-rotate[26951]: Executing post-hooks
Jan  2 11:43:28 mylaptop think-rotate[26953]: MEUSER's hook: Found tablet mode

Jan  2 11:43:41 mylaptop think-rotate[26976]: Script starting up (args: ) …
Jan  2 11:43:41 mylaptop think-rotate[26978]: Running as user meuser.
Jan  2 11:43:41 mylaptop think-rotate[26979]: $HOME is set to /home/meuser.
Jan  2 11:43:41 mylaptop think-rotate[26980]: $HOME is now set to /home/meuser.
Jan  2 11:43:41 mylaptop think-rotate[26981]: Executing pre-hooks
Jan  2 11:43:41 mylaptop think-rotate[26982]: Finding current rotation
Jan  2 11:43:41 mylaptop think-rotate[26990]: Current status is right.
Jan  2 11:43:41 mylaptop think-rotate[26991]: Infering new rotation
Jan  2 11:43:41 mylaptop think-rotate[26992]: Using default, reverting to normal.
Jan  2 11:43:41 mylaptop think-rotate[26993]: Rotating screen
Jan  2 11:43:42 mylaptop think-rotate[26995]: Rotating Wacom devices to none.
Jan  2 11:43:42 mylaptop think-rotate[27006]: Starting or killing virtual keyboard
Jan  2 11:43:42 mylaptop think-rotate[27009]: Enabling/Disabling TrackPoint and TouchPad
Jan  2 11:43:42 mylaptop think-rotate[27020]: Toggling input device 14 to 1.
Jan  2 11:43:42 mylaptop think-rotate[27022]: Toggling input device 13 to 1.
Jan  2 11:43:42 mylaptop think-rotate[27024]: Executing post-hooks
Jan  2 11:43:42 mylaptop think-rotate[27026]: MEUSER's hook: Found normal

Can anyone help me debug why the script is not working for me?
I'm on an X230-tablet, Ubuntu 13.10, ...

@jturner314
Copy link
Contributor

Based on the logs, it looks like your postrotate hook is getting called but is not working correctly. According to this, dconf uses D-Bus. I suspect that you're having issues modifying the Unity launcher because acpid doesn't set the DBUS_SESSION_BUS_ADDRESS environment variable. Try adding this to the beginning of your postrotate hook:

for pid in $(pgrep dbus); do
    if address="$(grep -z '^DBUS_SESSION_BUS_ADDRESS=' /proc/${pid}/environ)"; then
        eval "export ${address}"
    fi
done

If that doesn't work, also try replacing dbus in $(pgrep dbus) with part of a name of a program that should have the correct DBUS_SESSION_BUS_ADDRESS. For example, under XFCE, using xfce works well.

I'm not sure about the screen keyboard. Does think-rotate kill the screen keyboard when rotating the screen back to its normal orientation? Could you add some more logging to think-rotate around the call to the screen keyboard?

After just rotating your screen, do your Wacom devices (tablet and touchscreen) work properly? Is the TrackPoint disabled? (This is hard to test while the screen is rotated and laid down, but you can try rotating the screen while pushing down to try and push against the TrackPoint.)

@cpbl
Copy link
Author

cpbl commented Jan 3, 2014

Hi Jim. Thanks.
I'm going to put aside my customizations for a moment, since the problem
happens even if I have no .config/think-rotate.

I'm not sure about the screen keyboard. Does think-rotate kill the screen

Yes, when I call it from the command line. I think there's nothing to kill
when it's called automatically.

keyboard when rotating the screen back to its normal orientation? Could you
add some more logging to think-rotate around the call to the screen
keyboard?

I'd like to. I guess I'm asking for advice on how to do that. What would I
log?

After just rotating your screen, do your Wacom devices (tablet and
touchscreen) work properly? Is the TrackPoint disabled? (This is hard to

The touchpad is properly disabled. The touchscreen is properly rotated.
I can't tell about the trackpoint.

Chris

@jturner314
Copy link
Contributor

Okay, so it sounds like the only problems are that, when think-rotate is started by rotating the screen, (1) the virtual keyboard is not starting and (2) the customizations in your postrotate hook are not working. Everything else is working properly. Do I understand correctly?

I can think of two possibilities why you may not see the virtual keyboard:

  1. The virtual keyboard is never called or is called incorrectly.
  2. The virtual keyboard does not start when it is called or fails while starting.

You can add some additional logging as in the patch below that will help eliminate at least the first possibility. It's probably way more logging than what you actually need (it's effectively walking the code line-by-line), but with this much detail, we should be able to get a much better understanding of what's happening.

After applying the patch, will you paste the syslog output here and also any output from the virtual keyboard that goes to the temporary logging file (see the patch)?

diff --git a/bin/think-rotate b/bin/think-rotate
index 22d474c..180ced8 100755
--- a/bin/think-rotate
+++ b/bin/think-rotate
@@ -167,22 +167,35 @@ mylogger $"Starting or killing virtual keyboard"
 kdialog-update $"Starting or killing virtual keyboard"

 # Start the virtual keyboard, if it is installed.
+mylogger "Checking to see if '$virtual_kbd' is available"
 if type "$virtual_kbd" &> /dev/null
 then
+    mylogger "The virtual keyboard program '$virtual_kbd' is visible to 'type'"
+    mylogger "The value of setto is '${setto}'"
     if [[ "$setto" = "normal" ]]
     then
+        mylogger "The virtual keyboard '${virtual_kbd}' will be killed"
         # So the user reverts back to normal. Kill the virtual keyboard (if it
         # is running), since it does not make any sense to use that any more.
         if pgrep "$virtual_kbd" &> /dev/null
         then
+            mylogger "Virtual keyboard is running with PIDs: '$(pgrep $virtual_kbd)'; killing it"
             killall "$virtual_kbd"
         fi
+        mylogger "Virtual keyboard killed; remaining PIDs: '$(pgrep $virtual_kbd)'"
     else
         # The user rotated the screen. Start the virtual keyboard since he
         # might need it.
-        "$virtual_kbd" &> /dev/null &
+        mylogger "Making log file for virtual keyboard '$virtual_kbd'"
+        temp_logging_file="$(mktemp)"
+        mylogger "Starting virtual keyboard and directing output to '$temp_logging_file'"
+        "$virtual_kbd" &> "$temp_logging_file" &
+        mylogger "Virtual keyboard started; PIDs: '$(pgrep $virtual_kbd)'"
     fi
 fi
+mylogger "Sleeping 1 sec to check on status of virtual keyboard"
+sleep 1
+mylogger "Virtual keyboard PIDs: '$(pgrep $virtual_kbd)'"

 ###############################################################################
 #                           TrackPoint and TouchPad                           #

@cpbl
Copy link
Author

cpbl commented Jan 3, 2014

Thanks, Jim!!

After figuring out how to use a patch file.... I tried your help:

When initiated automatically, the temporary file looks like this:

QDBusConnection: session D-Bus connection created before QCoreApplication. Application may misbehave.
kvkbd(19485): KUniqueApplication: Cannot find the D-Bus session server:  "Failed to connect to socket /tmp/dbus-KNaGd8HkRW: Connection refused"

kvkbd(19480): KUniqueApplication: Pipe closed unexpectedly. 

When called from the command line, it is instead:

QDBusConnection: session D-Bus connection created before QCoreApplication. Application may misbehave.
QDBusConnection: session D-Bus connection created before QCoreApplication. Application may misbehave.

The syslog entries are as follows:

automated:

Jan  3 08:59:37 mylaptop think-rotate-hook[19430]: Using user meuser.
Jan  3 08:59:37 mylaptop think-rotate-hook[19431]: Will run “DISPLAY=:0.0 kdialog=false /usr/bin/think-rotate ”.
Jan  3 08:59:37 mylaptop think-rotate[19441]: Script starting up (args: ) …
Jan  3 08:59:37 mylaptop think-rotate[19443]: Running as user meuser.
Jan  3 08:59:37 mylaptop think-rotate[19444]: $HOME is set to /home/meuser.
Jan  3 08:59:37 mylaptop think-rotate[19445]: $HOME is now set to /home/meuser.
Jan  3 08:59:37 mylaptop think-rotate[19446]: Executing pre-hooks
Jan  3 08:59:37 mylaptop think-rotate[19447]: Finding current rotation
Jan  3 08:59:37 mylaptop think-rotate[19455]: Current status is normal.
Jan  3 08:59:37 mylaptop think-rotate[19456]: Infering new rotation
Jan  3 08:59:37 mylaptop think-rotate[19457]: Using default, setting to right.
Jan  3 08:59:37 mylaptop think-rotate[19458]: Rotating screen
Jan  3 08:59:38 mylaptop think-rotate[19460]: Rotating Wacom devices to cw.
Jan  3 08:59:38 mylaptop think-rotate[19473]: Starting or killing virtual keyboard
Jan  3 08:59:38 mylaptop think-rotate[19474]: Checking to see if 'kvkbd' is available
Jan  3 08:59:38 mylaptop think-rotate[19475]: The virtual keyboard program 'kvkbd' is visible to 'type'
Jan  3 08:59:38 mylaptop think-rotate[19476]: The value of setto is 'right'
Jan  3 08:59:38 mylaptop think-rotate[19477]: Making log file for virtual keyboard 'kvkbd'
Jan  3 08:59:38 mylaptop think-rotate[19479]: Starting virtual keyboard and directing output to '/tmp/tmp.l5AMTRWAKL'
Jan  3 08:59:38 mylaptop think-rotate[19482]: Virtual keyboard started; PIDs: '19480'
Jan  3 08:59:38 mylaptop think-rotate[19483]: Sleeping 1 sec to check on status of virtual keyboard
Jan  3 08:59:39 mylaptop think-rotate[19492]: Virtual keyboard PIDs: '19480#01219485'
Jan  3 08:59:39 mylaptop think-rotate[19493]: Enabling/Disabling TrackPoint and TouchPad
Jan  3 08:59:39 mylaptop think-rotate[19504]: Toggling input device 16 to 0.
Jan  3 08:59:39 mylaptop think-rotate[19506]: Toggling input device 13 to 0.
Jan  3 08:59:39 mylaptop think-rotate[19508]: Executing post-hooks
Jan  3 08:59:39 mylaptop think-rotate[19510]: MEUSER's hook: Found tablet mode

automated:

Jan  3 08:59:54 mylaptop think-rotate-hook[19529]: Using user meuser.
Jan  3 08:59:54 mylaptop think-rotate-hook[19530]: Will run “DISPLAY=:0.0 kdialog=false /usr/bin/think-rotate normal”.
Jan  3 08:59:54 mylaptop think-rotate[19540]: Script starting up (args: normal) …
Jan  3 08:59:54 mylaptop think-rotate[19542]: Running as user meuser.
Jan  3 08:59:54 mylaptop think-rotate[19543]: $HOME is set to /home/meuser.
Jan  3 08:59:54 mylaptop think-rotate[19544]: $HOME is now set to /home/meuser.
Jan  3 08:59:54 mylaptop think-rotate[19545]: Executing pre-hooks
Jan  3 08:59:54 mylaptop think-rotate[19546]: Finding current rotation
Jan  3 08:59:54 mylaptop think-rotate[19554]: Current status is right.
Jan  3 08:59:54 mylaptop think-rotate[19555]: Infering new rotation
Jan  3 08:59:54 mylaptop think-rotate[19556]: User chose to set to normal.
Jan  3 08:59:54 mylaptop think-rotate[19557]: Rotating screen
Jan  3 08:59:55 mylaptop think-rotate[19559]: Rotating Wacom devices to none.
Jan  3 08:59:55 mylaptop think-rotate[19571]: Starting or killing virtual keyboard
Jan  3 08:59:55 mylaptop think-rotate[19572]: Checking to see if 'kvkbd' is available
Jan  3 08:59:55 mylaptop think-rotate[19573]: The virtual keyboard program 'kvkbd' is visible to 'type'
Jan  3 08:59:55 mylaptop think-rotate[19574]: The value of setto is 'normal'
Jan  3 08:59:55 mylaptop think-rotate[19575]: The virtual keyboard 'kvkbd' will be killed
Jan  3 08:59:55 mylaptop think-rotate[19578]: Virtual keyboard killed; remaining PIDs: ''
Jan  3 08:59:55 mylaptop think-rotate[19579]: Sleeping 1 sec to check on status of virtual keyboard
Jan  3 08:59:56 mylaptop think-rotate[19582]: Virtual keyboard PIDs: ''
Jan  3 08:59:56 mylaptop think-rotate[19583]: Enabling/Disabling TrackPoint and TouchPad
Jan  3 08:59:56 mylaptop think-rotate[19594]: Toggling input device 16 to 1.
Jan  3 08:59:56 mylaptop think-rotate[19596]: Toggling input device 13 to 1.
Jan  3 08:59:56 mylaptop think-rotate[19598]: Executing post-hooks
Jan  3 08:59:56 mylaptop think-rotate[19600]: MEUSER's hook: Found tablet mode


command-line:

Jan  3 09:03:38 mylaptop think-rotate[20761]: Script starting up (args: ) …
Jan  3 09:03:38 mylaptop think-rotate[20763]: Running as user meuser.
Jan  3 09:03:38 mylaptop think-rotate[20764]: $HOME is set to /home/meuser.
Jan  3 09:03:38 mylaptop think-rotate[20765]: $HOME is now set to /home/meuser.
Jan  3 09:03:38 mylaptop think-rotate[20766]: Executing pre-hooks
Jan  3 09:03:38 mylaptop think-rotate[20767]: Finding current rotation
Jan  3 09:03:38 mylaptop think-rotate[20775]: Current status is normal.
Jan  3 09:03:38 mylaptop think-rotate[20776]: Infering new rotation
Jan  3 09:03:38 mylaptop think-rotate[20777]: Using default, setting to right.
Jan  3 09:03:38 mylaptop think-rotate[20778]: Rotating screen
Jan  3 09:03:39 mylaptop think-rotate[20780]: Rotating Wacom devices to cw.
Jan  3 09:03:39 mylaptop think-rotate[20793]: Starting or killing virtual keyboard
Jan  3 09:03:39 mylaptop think-rotate[20794]: Checking to see if 'kvkbd' is available
Jan  3 09:03:39 mylaptop think-rotate[20795]: The virtual keyboard program 'kvkbd' is visible to 'type'
Jan  3 09:03:39 mylaptop think-rotate[20796]: The value of setto is 'right'
Jan  3 09:03:39 mylaptop think-rotate[20797]: Making log file for virtual keyboard 'kvkbd'
Jan  3 09:03:39 mylaptop think-rotate[20799]: Starting virtual keyboard and directing output to '/tmp/tmp.qGHyuKp7Gq'
Jan  3 09:03:39 mylaptop think-rotate[20802]: Virtual keyboard started; PIDs: '20800'
Jan  3 09:03:39 mylaptop think-rotate[20803]: Sleeping 1 sec to check on status of virtual keyboard
Jan  3 09:03:40 mylaptop think-rotate[20814]: Virtual keyboard PIDs: '20804'
Jan  3 09:03:40 mylaptop think-rotate[20815]: Enabling/Disabling TrackPoint and TouchPad
Jan  3 09:03:40 mylaptop think-rotate[20826]: Toggling input device 16 to 0.
Jan  3 09:03:40 mylaptop think-rotate[20828]: Toggling input device 13 to 0.
Jan  3 09:03:40 mylaptop think-rotate[20830]: Executing post-hooks
Jan  3 09:03:40 mylaptop think-rotate[20832]: MEUSER's hook: Found tablet mode


command-line:

Jan  3 09:03:58 mylaptop think-rotate[20840]: Script starting up (args: ) …
Jan  3 09:03:58 mylaptop think-rotate[20842]: Running as user meuser.
Jan  3 09:03:58 mylaptop think-rotate[20843]: $HOME is set to /home/meuser.
Jan  3 09:03:58 mylaptop think-rotate[20844]: $HOME is now set to /home/meuser.
Jan  3 09:03:58 mylaptop think-rotate[20845]: Executing pre-hooks
Jan  3 09:03:58 mylaptop think-rotate[20846]: Finding current rotation
Jan  3 09:03:58 mylaptop think-rotate[20854]: Current status is right.
Jan  3 09:03:58 mylaptop think-rotate[20855]: Infering new rotation
Jan  3 09:03:58 mylaptop think-rotate[20856]: Using default, reverting to normal.
Jan  3 09:03:58 mylaptop think-rotate[20857]: Rotating screen
Jan  3 09:03:59 mylaptop think-rotate[20859]: Rotating Wacom devices to none.
Jan  3 09:04:00 mylaptop think-rotate[20872]: Starting or killing virtual keyboard
Jan  3 09:04:00 mylaptop think-rotate[20873]: Checking to see if 'kvkbd' is available
Jan  3 09:04:00 mylaptop think-rotate[20874]: The virtual keyboard program 'kvkbd' is visible to 'type'
Jan  3 09:04:00 mylaptop think-rotate[20875]: The value of setto is 'normal'
Jan  3 09:04:00 mylaptop think-rotate[20876]: The virtual keyboard 'kvkbd' will be killed
Jan  3 09:04:00 mylaptop think-rotate[20879]: Virtual keyboard is running with PIDs: '20804'; killing it
Jan  3 09:04:00 mylaptop think-rotate[20882]: Virtual keyboard killed; remaining PIDs: ''
Jan  3 09:04:00 mylaptop think-rotate[20883]: Sleeping 1 sec to check on status of virtual keyboard
Jan  3 09:04:01 mylaptop think-rotate[20886]: Virtual keyboard PIDs: ''
Jan  3 09:04:01 mylaptop think-rotate[20887]: Enabling/Disabling TrackPoint and TouchPad
Jan  3 09:04:01 mylaptop think-rotate[20898]: Toggling input device 16 to 1.
Jan  3 09:04:01 mylaptop think-rotate[20900]: Toggling input device 13 to 1.
Jan  3 09:04:01 mylaptop think-rotate[20902]: Executing post-hooks
Jan  3 09:04:01 mylaptop think-rotate[20904]: MEUSER's hook: Found tablet mode

On Thu, 2 Jan 2014, Jim Turner wrote:

Okay, so it sounds like the only problems are that, when think-rotate is started by rotating the screen, (1) the virtual keyboard is not starting
and (2) the customizations in your postrotate hook are not working. Everything else is working properly. Do I understand correctly?

I can think of two possibilities why you may not see the virtual keyboard:

  1. The virtual keyboard is never called or is called incorrectly.
  2. The virtual keyboard does not start when it is called or fails while starting.

You can add some additional logging as in the patch below that will help eliminate at least the first possibility. It's probably way more logging
than what you actually need (it's effectively walking the code line-by-line), but with this much detail, we should be able to get a much better
understanding of what's happening.

After applying the patch, will you paste the syslog output here and also any output from the virtual keyboard that goes to the temporary logging
file (see the patch)?

diff --git a/bin/think-rotate b/bin/think-rotate
index 22d474c..180ced8 100755
--- a/bin/think-rotate
+++ b/bin/think-rotate
@@ -167,22 +167,35 @@ mylogger $"Starting or killing virtual keyboard"
kdialog-update $"Starting or killing virtual keyboard"

Start the virtual keyboard, if it is installed.

+mylogger "Checking to see if '$virtual_kbd' is available"
if type "$virtual_kbd" &> /dev/null
then

  • mylogger "The virtual keyboard program '$virtual_kbd' is visible to 'type'"

  • mylogger "The value of setto is '${setto}'"
    if [[ "$setto" = "normal" ]]
    then

  •    mylogger "The virtual keyboard '${virtual_kbd}' will be killed"
     # So the user reverts back to normal. Kill the virtual keyboard (if it
     # is running), since it does not make any sense to use that any more.
     if pgrep "$virtual_kbd" &> /dev/null
     then
    
  •        mylogger "Virtual keyboard is running with PIDs: '$(pgrep $virtual_kbd)'; killing it"
         killall "$virtual_kbd"
     fi
    
  •    mylogger "Virtual keyboard killed; remaining PIDs: '$(pgrep $virtual_kbd)'"
    

    else
    # The user rotated the screen. Start the virtual keyboard since he
    # might need it.

  •    "$virtual_kbd" &> /dev/null &
    
  •    mylogger "Making log file for virtual keyboard '$virtual_kbd'"
    
  •    temp_logging_file="$(mktemp)"
    
  •    mylogger "Starting virtual keyboard and directing output to '$temp_logging_file'"
    
  •    "$virtual_kbd" &> "$temp_logging_file" &
    
  •    mylogger "Virtual keyboard started; PIDs: '$(pgrep $virtual_kbd)'"
    

    fi
    fi
    +mylogger "Sleeping 1 sec to check on status of virtual keyboard"
    +sleep 1
    +mylogger "Virtual keyboard PIDs: '$(pgrep $virtual_kbd)'"

    ###############################################################################

    TrackPoint and TouchPad


Reply to this email directly or view it onGitHub.[3696165__eyJzY29wZSI6Ik5ld3NpZXM6QmVhY29uIiwiZXhwaXJlcyI6MTcwNDI2NzE3MCwiZGF0YSI6eyJpZCI6MjI4MjY1NDB9fQ==--33d898a1d32c29894d553b6ec5d6f8f
045bf4ab4.gif]

@martin-ueding
Copy link
Owner

See #24, where the wireless is not disabled when think-dock is called via the hook, but called via the command line. I am getting the impression that the hooks do not set the user environment right, when they call the actual script with su. Maybe we need to put in another /usr/bin/env or so?

@martin-ueding
Copy link
Owner

I went through your output, it looks like the missing reference to DBus is causing the problem. I looked into the different environments that the command line and the hook have and documented it in the main documentation, in case we need this again. There is no DBUS_SESSION_BUS_ADDRESS in the environment that is created by the hook, therefore causing trouble with the other stuff.

However, I use kvkbd as well, and it seems to work on my machine. So even though that DBus information is missing, I get the virtual keyboard. That only makes it stranger, right?

@martin-ueding
Copy link
Owner

I added an env branch, where the hooks call env to recreate the users environment. Please check that out. It works really well on my machine, where I can use kdialog from the hooks as well. This little change creates the DBUS_SESSION_BUS_ADDRESS, therefore giving you all you need for your hooks.

It is such an improvement for me that I will merge it in a couple days. However, I do not want to cause regressions, so please test it.

@cpbl
Copy link
Author

cpbl commented Jan 6, 2014

A naive question: how do I do that? Should I install from the
think-rotate-dev zip? or can I use somethign on the deb repository I
already have added?
Thank you,
Chris

On Mon, 6 Jan 2014, Martin Ueding wrote:

I added an env branch, where the hooks call env to recreate the users environment. Please check that out. It works really well on my machine, where
I can use kdialog from the hooks as well. This little change creates the DBUS_SESSION_BUS_ADDRESS, therefore giving you all you need for your
hooks.


Reply to this email directly or view it onGitHub.[3696165__eyJzY29wZSI6Ik5ld3NpZXM6QmVhY29uIiwiZXhwaXJlcyI6MTcwNDU3Mjg5NiwiZGF0YSI6eyJpZCI6MjI4MjY1NDB9fQ==--bcdcf3c05458cc4ecf3a0362fc60913
bdb410582.gif]

@martin-ueding
Copy link
Owner

You have to install it from the git checkout:

git clone https://github.com/martin-ueding/think-rotate.git
cd think-rotate
git checkout env
make
sudo make install

@cpbl
Copy link
Author

cpbl commented Jan 6, 2014

Thanks.
Still feeling a bit clueless: I am not sure what I'm looking for. The
behaviour hasn't changed for me. Rotating my screen (hardware) rotates the
display, turns off the trackpad or point but still doesn't pop up a
keyboard, and nor do my custom scripts work properly.

I suppose I have undone the extra debugging output I had patched in ,
since syslog looks like it used to before the extra output.

Should I have noticed something different, or am I supposed to do
something more to test the branch?

thanks,
c

On Mon, 6 Jan 2014, Martin Ueding wrote:

You have to install it from the git checkout:

git clone https://github.com/martin-ueding/think-rotate.git
cd think-rotate
git checkout env
make
sudo make install


Reply to this email directly or view it onGitHub.[3696165__eyJzY29wZSI6Ik5ld3NpZXM6QmVhY29uIiwiZXhwaXJlcyI6MTcwNDU3Mzg5MCwiZGF0YSI6eyJpZCI6MjI4MjY1NDB9fQ==--a8a9f78289a03e854843048fb2022dd
369a2000f.gif]

@jturner314
Copy link
Contributor

@cpbl If you executed the commands that Martin sent and tested the behavior, I think that is what Martin was looking for. Since you noticed no change in behavior, it sounds like the change didn't work. And yes, checking out the env branch removed the extra logging. When you ran sudo make install, it basically overwrote the think-rotate files on your computer with those in the env branch. In the process, the extra logging code was lost.

@martin-ueding I might be missing something, but the way I read the man page for env, simply adding env in front of a command doesn't do anything. env is useful for two things: (1) displaying the current environment (when run without any arguments) and (2) running a command with a fresh environment (using the -i option). AFAIK, the only way to duplicate the graphical user's environment is to set the variables individually or duplicate the environment of a running process (which is located at /proc/<pid>/environ).

@jturner314
Copy link
Contributor

To copy all of the variables from the environment of process foo, the following works:

while read -rd '' var; do
    export "$var"
done < /proc/$(pidof -s foo)/environ

Note that this will not remove any previously-defined variables in the current environment (although it will overwrite their values if they are defined in the environment of foo).

It might be a good idea to do something like this at the beginning of think-dock-hook and think-rotate-hook. I'm not sure what process to copy the environment of, though. Is there something that would work for all systems?

@martin-ueding
Copy link
Owner

Hmm. I updated the documentation about the environments, and I did see what you say: There is no improvement using env. However, I get kdialog working with that, so I do think that is makes a difference somehow. But since @cpbl does not experience anything different, it does not make any difference.

But why do Perl programmers use /usr/bin/env perl instead of /usr/bin/perl? Just because of path uncertainties?

@jturner314 could you add the debugging code as a branch? That way, we can merge it with the current master branch and make it easier for @cpbl to use it.

jturner314 added a commit to jturner314/thinkpad-scripts that referenced this issue Jan 7, 2014
@jturner314
Copy link
Contributor

However, I get kdialog working with that, so I do think that is makes a difference somehow.

If adding env is the only difference, I don't know why there would be a difference in behavior. That's weird. It must be something other than the environment variables.

But why do Perl programmers use /usr/bin/env perl instead of /usr/bin/perl? Just because of path uncertainties?

That's the only reason I've ever seen. The #! line requires an absolute path, and env is very likely to be at /usr/bin/env, regardless of the *nix system. Depending on the system, perl may be installed in /opt, /usr/bin, /usr/local/bin, etc. env uses PATH to find the command, so it should be able to find perl even if it's in a weird place. This is often done for scripts written for other interpreters, as well, e.g. python and ruby. This page has a more detailed explanation, and this one explains some disadvantages to this approach.

@jturner314 could you add the debugging code as a branch?

Done. I also added a line to make it output the environment variables. It's in the jturner314/think-rotate/add-kvkbd-logging branch.

@cpbl
Copy link
Author

cpbl commented Jan 10, 2014

Did I mention that my home folder is encrypted? I cannot imagine that can make a difference here, but I thought I should mention it.
I've just tested the think-rotate-add-kvkbd-logging branch. No difference in behaviour. It gives the following in syslog:

Jan 10 06:11:46 meuser-x230 think-rotate-hook[5421]: Using user meuser.
Jan 10 06:11:46 meuser-x230 think-rotate-hook[5422]: Will run “DISPLAY=:0.0 kdialog=false /usr/bin/think-rotate ”.
Jan 10 06:11:46 meuser-x230 think-rotate[5432]: Script starting up (args: ) …
Jan 10 06:11:46 meuser-x230 think-rotate[5434]: Running as user meuser.
Jan 10 06:11:46 meuser-x230 think-rotate[5435]: $HOME is set to /home/meuser.
Jan 10 06:11:46 meuser-x230 think-rotate[5436]: $HOME is now set to /home/meuser.
Jan 10 06:11:49 meuser-x230 think-rotate[5444]: Executing pre-hooks
Jan 10 06:11:49 meuser-x230 think-rotate[5445]: Finding current rotation
Jan 10 06:11:49 meuser-x230 think-rotate[5452]: Current status is normal.
Jan 10 06:11:49 meuser-x230 think-rotate[5453]: Infering new rotation
Jan 10 06:11:49 meuser-x230 think-rotate[5454]: Using default, setting to right.
Jan 10 06:11:49 meuser-x230 think-rotate[5455]: Rotating screen
Jan 10 06:11:50 meuser-x230 think-rotate[5458]: Rotating Wacom devices to cw.
Jan 10 06:11:50 meuser-x230 think-rotate[5471]: Starting or killing virtual keyboard
Jan 10 06:11:50 meuser-x230 think-rotate[5473]: Environment variables: XDG_SESSION_ID=c8#012TERM=linux#012SHELL=/bin/bash#012XDG_SESSION_COOKIE=36bd8e6a2f35671272f3ef1e52ab6906-1389352306.610380-2055989495#012USER=meuser#012kdialog=false#012PATH=/home/meuser/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games#012MAIL=/var/mail/meuser#012PWD=/home/meuser#012LANG=en_CA.UTF-8#012HOME=/home/meuser#012SHLVL=2#012LANGUAGE=en_CA:en#012LOGNAME=meuser#012XDG_RUNTIME_DIR=/run/user/1000#012DISPLAY=:0.0#012_=/usr/bin/env
Jan 10 06:11:50 meuser-x230 think-rotate[5474]: Checking to see if 'kvkbd' is available
Jan 10 06:11:50 meuser-x230 think-rotate[5475]: The virtual keyboard program 'kvkbd' is visible to 'type'
Jan 10 06:11:50 meuser-x230 think-rotate[5476]: The value of setto is 'right'
Jan 10 06:11:50 meuser-x230 think-rotate[5477]: Making log file for virtual keyboard 'kvkbd'
Jan 10 06:11:50 meuser-x230 think-rotate[5479]: Starting virtual keyboard and directing output to '/tmp/tmp.cKyswlOvzD'
Jan 10 06:11:50 meuser-x230 think-rotate[5482]: Virtual keyboard started; PIDs: '5480'
Jan 10 06:11:50 meuser-x230 think-rotate[5483]: Sleeping 1 sec to check on status of virtual keyboard
Jan 10 06:11:51 meuser-x230 think-rotate[5492]: Virtual keyboard PIDs: '5480#0125485'
Jan 10 06:11:51 meuser-x230 think-rotate[5493]: Enabling/Disabling TrackPoint and TouchPad
Jan 10 06:11:51 meuser-x230 think-rotate[5504]: Toggling input device 16 to 0.
Jan 10 06:11:51 meuser-x230 think-rotate[5506]: Toggling input device 13 to 0.
Jan 10 06:11:51 meuser-x230 think-rotate[5508]: Executing post-hooks
Jan 10 06:11:51 meuser-x230 think-rotate[5510]: MEUSER's hook: Found tablet mode

Jan 10 06:12:05 meuser-x230 think-rotate-hook[5548]: Using user meuser.
Jan 10 06:12:05 meuser-x230 think-rotate-hook[5549]: Will run “DISPLAY=:0.0 kdialog=false /usr/bin/think-rotate normal”.
Jan 10 06:12:05 meuser-x230 think-rotate[5559]: Script starting up (args: normal) …
Jan 10 06:12:05 meuser-x230 think-rotate[5561]: Running as user meuser.
Jan 10 06:12:05 meuser-x230 think-rotate[5562]: $HOME is set to /home/meuser.
Jan 10 06:12:05 meuser-x230 think-rotate[5563]: $HOME is now set to /home/meuser.
Jan 10 06:12:08 meuser-x230 think-rotate[5570]: Executing pre-hooks
Jan 10 06:12:08 meuser-x230 think-rotate[5571]: Finding current rotation
Jan 10 06:12:08 meuser-x230 think-rotate[5579]: Current status is right.
Jan 10 06:12:08 meuser-x230 think-rotate[5580]: Infering new rotation
Jan 10 06:12:08 meuser-x230 think-rotate[5581]: User chose to set to normal.
Jan 10 06:12:08 meuser-x230 think-rotate[5582]: Rotating screen
Jan 10 06:12:09 meuser-x230 think-rotate[5584]: Rotating Wacom devices to none.
Jan 10 06:12:09 meuser-x230 think-rotate[5599]: Starting or killing virtual keyboard
Jan 10 06:12:09 meuser-x230 think-rotate[5601]: Environment variables: XDG_SESSION_ID=c9#012TERM=linux#012SHELL=/bin/bash#012XDG_SESSION_COOKIE=36bd8e6a2f35671272f3ef1e52ab6906-1389352325.406030-905732726#012USER=meuser#012kdialog=false#012PATH=/home/meuser/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games#012MAIL=/var/mail/meuser#012PWD=/home/meuser#012LANG=en_CA.UTF-8#012HOME=/home/meuser#012SHLVL=2#012LANGUAGE=en_CA:en#012LOGNAME=meuser#012XDG_RUNTIME_DIR=/run/user/1000#012DISPLAY=:0.0#012_=/usr/bin/env
Jan 10 06:12:09 meuser-x230 think-rotate[5602]: Checking to see if 'kvkbd' is available
Jan 10 06:12:09 meuser-x230 think-rotate[5603]: The virtual keyboard program 'kvkbd' is visible to 'type'
Jan 10 06:12:09 meuser-x230 think-rotate[5604]: The value of setto is 'normal'
Jan 10 06:12:09 meuser-x230 think-rotate[5605]: The virtual keyboard 'kvkbd' will be killed
Jan 10 06:12:09 meuser-x230 think-rotate[5608]: Virtual keyboard killed; remaining PIDs: ''
Jan 10 06:12:09 meuser-x230 think-rotate[5609]: Sleeping 1 sec to check on status of virtual keyboard
Jan 10 06:12:10 meuser-x230 think-rotate[5612]: Virtual keyboard PIDs: ''
Jan 10 06:12:10 meuser-x230 think-rotate[5613]: Enabling/Disabling TrackPoint and TouchPad
Jan 10 06:12:10 meuser-x230 think-rotate[5624]: Toggling input device 16 to 1.
Jan 10 06:12:10 meuser-x230 think-rotate[5626]: Toggling input device 13 to 1.
Jan 10 06:12:10 meuser-x230 think-rotate[5628]: Executing post-hooks
Jan 10 06:12:10 meuser-x230 think-rotate[5630]: MEUSER's hook: Found normal

@jturner314
Copy link
Contributor

I very much doubt that the encrypted home directory is the issue because think-rotate is still properly finding and executing your postrotate hook (which I assume is located in your home directory). So, we know that think-rotate has access to your decrypted home directory. Thanks for mentioning this, though.

The add-kvkbd-logging branch is just to add additional logging; it shouldn't change the behavior. Just to make sure, are those logs from an automated launch of think-rotate?

I thought of something interesting to try. Run the following in gnome-terminal (or whatever terminal emulator you use in your graphical environment) and report what happens:

env -i XDG_SESSION_ID=c8 TERM=linux SHELL=/bin/bash XDG_SESSION_COOKIE=36bd8e6a2f35671272f3ef1e52ab6906-1389352306.610380-2055989495 USER=meuser kdialog=false PATH=/home/meuser/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games MAIL=/var/mail/meuser PWD=/home/meuser LANG=en_CA.UTF-8 HOME=/home/meuser SHLVL=2 LANGUAGE=en_CA:en LOGNAME=meuser XDG_RUNTIME_DIR=/run/user/1000 DISPLAY=:0.0 _=/usr/bin/env kvkbd

If you've logged out since you posted those logs from 2 days ago, then you'll need to change the command to match your current environment variables. Basically, I grabbed the list of environment variables following

Jan 10 06:11:50 meuser-x230 think-rotate[5473]: Environment variables:

in your logs and placed them in the command

env -i [ENV VARS] kvkbd

If you execute the command in gnome-terminal, it will duplicate the environment of the automatically-called kvkbd but do it within your graphical environment. In this way, we can determine if the environment variables are really the issue, or if the problem is something else.

Please let me know if you need more explanation.

@martin-ueding
Copy link
Owner

I just tried to start kvkbd with an empty environment:

mu:~ env -i kvkbd
QDBusConnection: session D-Bus connection created before
QCoreApplication. Application may misbehave.
kvkbd(22246): KUniqueApplication: Cannot find the D-Bus session server:
"Unable to autolaunch a dbus-daemon without a $DISPLAY for X11"

kvkbd(22245): KUniqueApplication: Pipe closed unexpectedly.

mu:~ 255 env -i DISPLAY=:0.0 kvkbd
QDBusConnection: session D-Bus connection created before
QCoreApplication. Application may misbehave.
QDBusConnection: session D-Bus connection created before
QCoreApplication. Application may misbehave.
Aborting. $HOME not set!
trying to create local folder /.kde: Permission denied
kvkbd(22252)/KSharedDataCache
KSharedDataCache::Private::mapSharedMemory: Failed to establish shared
memory mapping, will fallback to private memory -- memory usage will
increase
KGlobal::locale(): Warning your global KLocale is being recreated with a
valid main component instead of a fake component, this usually means you
tried to call i18n related functions before your main component was
created. You should not do that since it most likely will not work
Aborting. $HOME not set!
trying to create local folder /.kde: Permission denied
kdialog(22258)/KSharedDataCache
KSharedDataCache::Private::mapSharedMemory: Failed to establish shared
memory mapping, will fallback to private memory -- memory usage will
increase
Aborting. $HOME not set!
trying to create local folder /.kde: Permission denied
Aborting. $HOME not set!
trying to create local folder /.kde: Permission denied
kdeinit4: Aborting. $HOME not set!kdialog(22258): Couldn't start knotify
from knotify4.desktop: "KLauncher could not be reached via D-Bus. Error
when calling start_service_by_desktop_path:
The name org.kde.klauncher was not provided by any .service files
"

It then started, though. And I have an encrypted home directory as well
(eCryptfs). kvkbd starts well for me with the master branch.

http://martin-ueding.de/#pk_campaign=Email

@cpbl
Copy link
Author

cpbl commented Jan 14, 2014

Hello. In my last message, I should indeed have tried both the
command-line and hardware-triggered initiation of think-rotate. Below, I
include syslog from both of those. Following those, I also tried calling
kvkbd with the same environment, and I tried calling my custom hook script
with the same. Neither worked.

Now, when I call think-rotate from the command line, I now see the
kdialog, which I didn't before, but kvkbd did not come up. The unity bar
appears as desired.
With the hardware-trigger, none of those three things happens.

Hardware-triggered, syslog from going into tablet mode:

Jan 13 17:13:55 meuser-lenovo think-rotate-hook[7850]: Using user meuser.
Jan 13 17:13:55 meuser-lenovo think-rotate-hook[7851]: Will run
“DISPLAY=:0.0 kdialog=false /usr/bin/think-rotate ”.
Jan 13 17:13:55 meuser-lenovo think-rotate[7861]: Script starting up
(args: ) …
Jan 13 17:13:55 meuser-lenovo think-rotate[7863]: Running as user meuser.
Jan 13 17:13:55 meuser-lenovo think-rotate[7864]: $HOME is set to
/home/meuser.
Jan 13 17:13:55 meuser-lenovo think-rotate[7865]: $HOME is now set to
/home/meuser.
Jan 13 17:13:59 meuser-lenovo think-rotate[7872]: Executing pre-hooks
Jan 13 17:13:59 meuser-lenovo think-rotate[7873]: Finding current rotation
Jan 13 17:13:59 meuser-lenovo think-rotate[7881]: Current status is
normal.
Jan 13 17:13:59 meuser-lenovo think-rotate[7882]: Infering new rotation
Jan 13 17:13:59 meuser-lenovo think-rotate[7883]: Using default, setting
to right.
Jan 13 17:13:59 meuser-lenovo think-rotate[7884]: Rotating screen
Jan 13 17:13:59 meuser-lenovo think-rotate[7886]: Rotating Wacom devices
to cw.
Jan 13 17:14:00 meuser-lenovo think-rotate[7899]: Starting or killing
virtual keyboard
Jan 13 17:14:00 meuser-lenovo think-rotate[7901]: Environment variables:
XDG_SESSION_ID=c11#012TERM=linux#012SHELL=/bin/bash#012XDG_SESSION_COOKIE=36bd8e6a2f35671272f3ef1e52ab6906-1389651235.948994-356112730#012USER=meuser#012kdialog=false#012PATH=/home/meuser/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games#012MAIL=/var/mail/meuser#012PWD=/home/meuser#012LANG=en_CA.UTF-8#012HOME=/home/meuser#012SHLVL=2#012LANGUAGE=en_CA:en#012LOGNAME=meuser#012XDG_RUNTIME_DIR=/run/user/1000#012DISPLAY=:0.0#012_=/usr/bin/env
Jan 13 17:14:00 meuser-lenovo think-rotate[7902]: Checking to see if
'kvkbd' is available
Jan 13 17:14:00 meuser-lenovo think-rotate[7903]: The virtual keyboard
program 'kvkbd' is visible to 'type'
Jan 13 17:14:00 meuser-lenovo think-rotate[7904]: The value of setto is
'right'
Jan 13 17:14:00 meuser-lenovo think-rotate[7905]: Making log file for
virtual keyboard 'kvkbd'
Jan 13 17:14:00 meuser-lenovo think-rotate[7907]: Starting virtual
keyboard and directing output to '/tmp/tmp.O69UeJYQBf'
Jan 13 17:14:00 meuser-lenovo think-rotate[7910]: Virtual keyboard
started; PIDs: ''
Jan 13 17:14:00 meuser-lenovo think-rotate[7911]: Sleeping 1 sec to check
on status of virtual keyboard
Jan 13 17:14:01 meuser-lenovo think-rotate[7942]: Virtual keyboard PIDs:
'7908#0127918'
Jan 13 17:14:01 meuser-lenovo think-rotate[7943]: Enabling/Disabling
TrackPoint and TouchPad
Jan 13 17:14:01 meuser-lenovo think-rotate[7958]: Toggling input device 16
to 0.
Jan 13 17:14:01 meuser-lenovo think-rotate[7960]: Toggling input device 13
to 0.
Jan 13 17:14:01 meuser-lenovo think-rotate[7962]: Executing post-hooks
Jan 13 17:14:01 meuser-lenovo think-rotate[7964]: MEUSER's hook: Found
tablet mode

Hardware-triggered, syslog from going FROM tablet mode:

Jan 13 17:14:05 meuser-lenovo think-rotate-hook[7982]: Using user meuser.
Jan 13 17:14:05 meuser-lenovo think-rotate-hook[7983]: Will run
“DISPLAY=:0.0 kdialog=false /usr/bin/think-rotate normal”.
Jan 13 17:14:05 meuser-lenovo think-rotate[7993]: Script starting up
(args: normal) …
Jan 13 17:14:05 meuser-lenovo think-rotate[7995]: Running as user meuser.
Jan 13 17:14:05 meuser-lenovo think-rotate[7996]: $HOME is set to
/home/meuser.
Jan 13 17:14:05 meuser-lenovo think-rotate[7997]: $HOME is now set to
/home/meuser.
Jan 13 17:14:08 meuser-lenovo think-rotate[8004]: Executing pre-hooks
Jan 13 17:14:08 meuser-lenovo think-rotate[8005]: Finding current rotation
Jan 13 17:14:08 meuser-lenovo think-rotate[8013]: Current status is right.
Jan 13 17:14:08 meuser-lenovo think-rotate[8014]: Infering new rotation
Jan 13 17:14:08 meuser-lenovo think-rotate[8015]: User chose to set to
normal.
Jan 13 17:14:08 meuser-lenovo think-rotate[8016]: Rotating screen
Jan 13 17:14:09 meuser-lenovo think-rotate[8018]: Rotating Wacom devices
to none.
Jan 13 17:14:09 meuser-lenovo think-rotate[8029]: Starting or killing
virtual keyboard
Jan 13 17:14:09 meuser-lenovo think-rotate[8031]: Environment variables:
XDG_SESSION_ID=c12#012TERM=linux#012SHELL=/bin/bash#012XDG_SESSION_COOKIE=36bd8e6a2f35671272f3ef1e52ab6906-1389651245.535673-1301273934#012USER=meuser#012kdialog=false#012PATH=/home/meuser/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games#012MAIL=/var/mail/meuser#012PWD=/home/meuser#012LANG=en_CA.UTF-8#012HOME=/home/meuser#012SHLVL=2#012LANGUAGE=en_CA:en#012LOGNAME=meuser#012XDG_RUNTIME_DIR=/run/user/1000#012DISPLAY=:0.0#012_=/usr/bin/env
Jan 13 17:14:09 meuser-lenovo think-rotate[8032]: Checking to see if
'kvkbd' is available
Jan 13 17:14:09 meuser-lenovo think-rotate[8033]: The virtual keyboard
program 'kvkbd' is visible to 'type'
Jan 13 17:14:09 meuser-lenovo think-rotate[8034]: The value of setto is
'normal'
Jan 13 17:14:09 meuser-lenovo think-rotate[8035]: The virtual keyboard
'kvkbd' will be killed
Jan 13 17:14:09 meuser-lenovo think-rotate[8038]: Virtual keyboard killed;
remaining PIDs: ''
Jan 13 17:14:09 meuser-lenovo think-rotate[8039]: Sleeping 1 sec to check
on status of virtual keyboard
Jan 13 17:14:10 meuser-lenovo think-rotate[8045]: Virtual keyboard PIDs:
''
Jan 13 17:14:10 meuser-lenovo think-rotate[8046]: Enabling/Disabling
TrackPoint and TouchPad
Jan 13 17:14:10 meuser-lenovo think-rotate[8057]: Toggling input device 16
to 1.
Jan 13 17:14:10 meuser-lenovo think-rotate[8059]: Toggling input device 13
to 1.
Jan 13 17:14:10 meuser-lenovo think-rotate[8061]: Executing post-hooks
Jan 13 17:14:10 meuser-lenovo think-rotate[8063]: MEUSER's hook: Found
normal

think-rotate called from command-line, syslog from going into tablet mode:

Jan 13 17:14:25 meuser-lenovo think-rotate[8161]: Script starting up
(args: ) …
Jan 13 17:14:25 meuser-lenovo think-rotate[8163]: Running as user meuser.
Jan 13 17:14:25 meuser-lenovo think-rotate[8164]: $HOME is set to
/home/meuser.
Jan 13 17:14:25 meuser-lenovo think-rotate[8165]: $HOME is now set to
/home/meuser.
Jan 13 17:14:26 meuser-lenovo think-rotate[8176]: Executing pre-hooks
Jan 13 17:14:26 meuser-lenovo think-rotate[8179]: Finding current rotation
Jan 13 17:14:26 meuser-lenovo think-rotate[8189]: Current status is
normal.
Jan 13 17:14:26 meuser-lenovo think-rotate[8190]: Infering new rotation
Jan 13 17:14:26 meuser-lenovo think-rotate[8193]: Using default, setting
to right.
Jan 13 17:14:26 meuser-lenovo think-rotate[8194]: Rotating screen
Jan 13 17:14:27 meuser-lenovo think-rotate[8198]: Rotating Wacom devices
to cw.
Jan 13 17:14:27 meuser-lenovo think-rotate[8213]: Starting or killing
virtual keyboard
Jan 13 17:14:27 meuser-lenovo think-rotate[8217]: Environment variables:
XDG_VTNR=7#012XDG_SESSION_ID=c3#012SSH_AGENT_PID=4404#012CLUTTER_IM_MODULE=xim#012GPG_AGENT_INFO=/run/user/1000/keyring-pcARe1/gpg:0:1#012VTE_VERSION=3406#012SHELL=/bin/bash#012TERM=xterm#012WINDOWID=54619907#012GNOME_KEYRING_CONTROL=/run/user/1000/keyring-pcARe1#012UPSTART_SESSION=unix:abstract=/com/ubuntu/upstart-session/1000/4331#012GTK_MODULES=overlay-scrollbar:unity-gtk-module#012USER=meuser#012LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:.tar=01;31:.tgz=01;31:.arj=01;31:.taz=01;31:.lzh=01;31:.lzma=01;31:.tlz=01;31:.txz=01;31:.zip=01;31:.z=01;31:.Z=01;31:.dz=01;31:.gz=01;31:.lz=01;31:.xz=01;31:.bz2=01;31:.bz=01;31:.tbz=01;31:.tbz2=01;31:.tz=01;31:.deb=01;31:.rpm=01;31:.jar=01;31:.war=01;31:.ear=01;31:.sar=01;31:.rar=01;31:.ace=01;31:.zoo=01;31:.cpio=01;31:.7z=01;31:.rz=01;31:.jpg=01;35:.jpeg=01;35:.gif=01;35:.bmp=01;3
5:.pbm=01;35:.pgm=01;35:.ppm=01;35:.tga=01;35:.xbm=01;35:.xpm=01;35:.tif=01;35:.tiff=01;35:.png=01;35:.svg=01;35:.svgz=01;35:.mng=01;35:.pcx=01;35:.mov=01;35:.mpg=01;35:.mpeg=01;35:.m2v=01;35:.mkv=01;35:.webm=01;35:.ogm=01;35:.mp4=01;35:.m4v=01;35:.mp4v=01;35:.vob=01;35:.qt=01;35:.nuv=01;35:.wmv=01;35:.asf=01;35:.rm=01;35:.rmvb=01;35:.flc=01;35:.avi=01;35:.fli=01;35:.flv=01;35:.gl=01;35:.dl=01;35:.xcf=01;35:.xwd=01;35:.yuv=01;35:.cgm=01;35:.emf=01;35:.axv=01;35:.anx=01;35:.ogv=01;35:.ogx=01;35:.aac=00;36:.au=00;36:.flac=00;36:.mid=00;36:.midi=00;36:.mka=00;36:.mp3=00;36:.mpc=00;36:.ogg=00;36:.ra=00;36:.wav=00;36:.axa=00;36:.oga=00;36:.spx=00;36:.xspf=00;36:#012XDG_SESSION_PATH=/org/freedesktop/DisplayManager/Session0#012XDG_SEAT_PATH=/org/freedesktop/DisplayManager/Seat0#012SSH_AUTH_SOCK=/run/user/1000/keyring-pcARe1/ssh#012DEFAULTS_PATH=/usr/share/gconf/ubuntu.default.path#012XDG_CONFIG_DIRS=/etc/xdg/xdg-ubuntu:/us
r/sha
Jan 13 17:14:27 meuser-lenovo think-rotate[8218]: Checking to see if
'kvkbd' is available
Jan 13 17:14:27 meuser-lenovo think-rotate[8219]: The virtual keyboard
program 'kvkbd' is visible to 'type'
Jan 13 17:14:27 meuser-lenovo think-rotate[8220]: The value of setto is
'right'
Jan 13 17:14:27 meuser-lenovo think-rotate[8225]: Making log file for
virtual keyboard 'kvkbd'
Jan 13 17:14:27 meuser-lenovo think-rotate[8227]: Starting virtual
keyboard and directing output to '/tmp/tmp.SwkL8mbR5W'
Jan 13 17:14:27 meuser-lenovo think-rotate[8231]: Virtual keyboard
started; PIDs: '8228'
Jan 13 17:14:27 meuser-lenovo think-rotate[8232]: Sleeping 1 sec to check
on status of virtual keyboard
Jan 13 17:14:28 meuser-lenovo think-rotate[8242]: Virtual keyboard PIDs:
'8230'
Jan 13 17:14:28 meuser-lenovo think-rotate[8243]: Enabling/Disabling
TrackPoint and TouchPad
Jan 13 17:14:28 meuser-lenovo think-rotate[8256]: Toggling input device 16
to 0.
Jan 13 17:14:28 meuser-lenovo think-rotate[8258]: Toggling input device 13
to 0.
Jan 13 17:14:28 meuser-lenovo think-rotate[8260]: Executing post-hooks
Jan 13 17:14:29 meuser-lenovo think-rotate[8264]: MEUSER's hook: Found
tablet mode

think-rotate called from command-line, syslog from going FROM tablet mode:

Jan 13 17:15:05 meuser-lenovo think-rotate[8273]: Script starting up
(args: ) …
Jan 13 17:15:05 meuser-lenovo think-rotate[8275]: Running as user meuser.
Jan 13 17:15:05 meuser-lenovo think-rotate[8276]: $HOME is set to
/home/meuser.
Jan 13 17:15:05 meuser-lenovo think-rotate[8277]: $HOME is now set to
/home/meuser.
Jan 13 17:15:06 meuser-lenovo think-rotate[8288]: Executing pre-hooks
Jan 13 17:15:06 meuser-lenovo think-rotate[8291]: Finding current rotation
Jan 13 17:15:06 meuser-lenovo think-rotate[8301]: Current status is right.
Jan 13 17:15:06 meuser-lenovo think-rotate[8302]: Infering new rotation
Jan 13 17:15:06 meuser-lenovo think-rotate[8305]: Using default, reverting
to normal.
Jan 13 17:15:06 meuser-lenovo think-rotate[8306]: Rotating screen
Jan 13 17:15:06 meuser-lenovo think-rotate[8310]: Rotating Wacom devices
to none.
Jan 13 17:15:07 meuser-lenovo think-rotate[8325]: Starting or killing
virtual keyboard
Jan 13 17:15:07 meuser-lenovo think-rotate[8329]: Environment variables:
XDG_VTNR=7#012XDG_SESSION_ID=c3#012SSH_AGENT_PID=4404#012CLUTTER_IM_MODULE=xim#012GPG_AGENT_INFO=/run/user/1000/keyring-pcARe1/gpg:0:1#012VTE_VERSION=3406#012SHELL=/bin/bash#012TERM=xterm#012WINDOWID=54619907#012GNOME_KEYRING_CONTROL=/run/user/1000/keyring-pcARe1#012UPSTART_SESSION=unix:abstract=/com/ubuntu/upstart-session/1000/4331#012GTK_MODULES=overlay-scrollbar:unity-gtk-module#012USER=meuser#012LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:.tar=01;31:.tgz=01;31:.arj=01;31:.taz=01;31:.lzh=01;31:.lzma=01;31:.tlz=01;31:.txz=01;31:.zip=01;31:.z=01;31:.Z=01;31:.dz=01;31:.gz=01;31:.lz=01;31:.xz=01;31:.bz2=01;31:.bz=01;31:.tbz=01;31:.tbz2=01;31:.tz=01;31:.deb=01;31:.rpm=01;31:.jar=01;31:.war=01;31:.ear=01;31:.sar=01;31:.rar=01;31:.ace=01;31:.zoo=01;31:.cpio=01;31:.7z=01;31:.rz=01;31:.jpg=01;35:.jpeg=01;35:.gif=01;35:.bmp=01;3
5:.pbm=01;35:.pgm=01;35:.ppm=01;35:.tga=01;35:.xbm=01;35:.xpm=01;35:.tif=01;35:.tiff=01;35:.png=01;35:.svg=01;35:.svgz=01;35:.mng=01;35:.pcx=01;35:.mov=01;35:.mpg=01;35:.mpeg=01;35:.m2v=01;35:.mkv=01;35:.webm=01;35:.ogm=01;35:.mp4=01;35:.m4v=01;35:.mp4v=01;35:.vob=01;35:.qt=01;35:.nuv=01;35:.wmv=01;35:.asf=01;35:.rm=01;35:.rmvb=01;35:.flc=01;35:.avi=01;35:.fli=01;35:.flv=01;35:.gl=01;35:.dl=01;35:.xcf=01;35:.xwd=01;35:.yuv=01;35:.cgm=01;35:.emf=01;35:.axv=01;35:.anx=01;35:.ogv=01;35:.ogx=01;35:.aac=00;36:.au=00;36:.flac=00;36:.mid=00;36:.midi=00;36:.mka=00;36:.mp3=00;36:.mpc=00;36:.ogg=00;36:.ra=00;36:.wav=00;36:.axa=00;36:.oga=00;36:.spx=00;36:.xspf=00;36:#012XDG_SESSION_PATH=/org/freedesktop/DisplayManager/Session0#012XDG_SEAT_PATH=/org/freedesktop/DisplayManager/Seat0#012SSH_AUTH_SOCK=/run/user/1000/keyring-pcARe1/ssh#012DEFAULTS_PATH=/usr/share/gconf/ubuntu.default.path#012XDG_CONFIG_DIRS=/etc/xdg/xdg-ubuntu:/us
r/sha
Jan 13 17:15:07 meuser-lenovo think-rotate[8330]: Checking to see if
'kvkbd' is available
Jan 13 17:15:07 meuser-lenovo think-rotate[8331]: The virtual keyboard
program 'kvkbd' is visible to 'type'
Jan 13 17:15:07 meuser-lenovo think-rotate[8332]: The value of setto is
'normal'
Jan 13 17:15:07 meuser-lenovo think-rotate[8333]: The virtual keyboard
'kvkbd' will be killed
Jan 13 17:15:07 meuser-lenovo think-rotate[8336]: Virtual keyboard is
running with PIDs: '8230'; killing it
Jan 13 17:15:07 meuser-lenovo think-rotate[8339]: Virtual keyboard killed;
remaining PIDs: ''
Jan 13 17:15:07 meuser-lenovo think-rotate[8340]: Sleeping 1 sec to check
on status of virtual keyboard
Jan 13 17:15:08 meuser-lenovo think-rotate[8347]: Virtual keyboard PIDs:
''
Jan 13 17:15:08 meuser-lenovo think-rotate[8348]: Enabling/Disabling
TrackPoint and TouchPad
Jan 13 17:15:08 meuser-lenovo think-rotate[8361]: Toggling input device 16
to 1.
Jan 13 17:15:08 meuser-lenovo think-rotate[8363]: Toggling input device 13
to 1.
Jan 13 17:15:08 meuser-lenovo think-rotate[8365]: Executing post-hooks
Jan 13 17:15:08 meuser-lenovo think-rotate[8369]: MEUSER's hook: Found
normal

Now, calling kvkbd with same environment as think-rotate used:

env -i
XDG_SESSION_ID=c11#012TERM=linux#012SHELL=/bin/bash#012XDG_SESSION_COOKIE=36bd8e6a2f35671272f3ef1e52ab6906-1389651235.948994-356112730#012USER=meuser#012kdialog=false#012PATH=/home/meuser/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games#012MAIL=/var/mail/meuser#012PWD=/home/meuser#012LANG=en_CA.UTF-8#012HOME=/home/meuser#012SHLVL=2#012LANGUAGE=en_CA:en#012LOGNAME=meuser#012XDG_RUNTIME_DIR=/run/user/1000#012DISPLAY=:0.0#012_=/usr/bin/env
kvkbd
QDBusConnection: session D-Bus connection created before QCoreApplication.
Application may misbehave.
kvkbd(8684): KUniqueApplication: Cannot find the D-Bus session server:
"Unable to autolaunch a dbus-daemon without a $DISPLAY for X11"

kvkbd(8683): KUniqueApplication: Pipe closed unexpectedly.

[1719][meuser@meuser-lenovo:~]$ kvkbd
QDBusConnection: session D-Bus connection created before QCoreApplication.
Application may misbehave.
QDBusConnection: session D-Bus connection created before QCoreApplication.
Application may misbehave.

[Weird. kvkbd is not visible. But...: ]

[1719][meuser@meuser-lenovo:~]$ ps -A|grep kvkbd
8688 pts/15 00:00:00 kvkbd

env -i
XDG_SESSION_ID=c11#012TERM=linux#012SHELL=/bin/bash#012XDG_SESSION_COOKIE=36bd8e6a2f35671272f3ef1e52ab6906-1389651235.948994-356112730#012USER=meuser#012kdialog=false#012PATH=/home/meuser/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games#012MAIL=/var/mail/meuser#012PWD=/home/meuser#012LANG=en_CA.UTF-8#012HOME=/home/meuser#012SHLVL=2#012LANGUAGE=en_CA:en#012LOGNAME=meuser#012XDG_RUNTIME_DIR=/run/user/1000#012DISPLAY=:0.0#012_=/usr/bin/env
~/.config/think-rotate/hooks/postrotate tablet
Found tablet mode

(process:8980): dconf-WARNING **: failed to commit changes to dconf: Error
spawning command line 'dbus-launch
--autolaunch=36bd8e6a2f35671272f3ef1e52ab6906 --binary-syntax
--close-stderr': Child process exited with code 1

On Sat, 11 Jan 2014, Jim Turner wrote:

I very much doubt that the encrypted home directory is the issue because think-rotate is still properly finding and executing your postrotate hook (which I assume is located in your
home directory). So, we know that think-rotate has access to your decrypted home directory. Thanks for mentioning this, though.

The add-kvkbd-logging branch is just to add additional logging; it shouldn't change the behavior. Just to make sure, are those logs from an automated launch of think-rotate?

I thought of something interesting to try. Run the following in gnome-terminal (or whatever terminal emulator you use in your graphical environment) and report what happens:

env -i XDG_SESSION_ID=c8 TERM=linux SHELL=/bin/bash XDG_SESSION_COOKIE=36bd8e6a2f35671272f3ef1e52ab6906-1389352306.610380-2055989495 USER=meuser kdialog=false PATH=/home/meuser/bin:/
usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games MAIL=/var/mail/meuser PWD=/home/meuser LANG=en_CA.UTF-8 HOME=/home/meuser SHLVL=2 LANGUAGE=en_CA:en LOGNAME=meuser XDG_RUNTIME
_DIR=/run/user/1000 DISPLAY=:0.0 _=/usr/bin/env kvkbd

If you've logged out since you posted those logs from 2 days ago, then you'll need to change the command to match your current environment variables. Basically, I grabbed the list of
environment variables following

Jan 10 06:11:50 meuser-x230 think-rotate[5473]: Environment variables:

in your logs and placed them in the command

env -i [ENV VARS] kvkbd

If you execute the command in gnome-terminal, it will duplicate the environment of the automatically-called kvkbd but do it within your graphical environment. In this way, we can
determine if the environment variables are really the issue, or if the problem is something else.


Reply to this email directly or view it on
GitHub.[3696165__eyJzY29wZSI6Ik5ld3NpZXM6QmVhY29uIiwiZXhwaXJlcyI6MTcwNTAxNjAyNSwiZGF0YSI6eyJpZCI6MjI4MjY1NDB9fQ==--b946f1db20041ef76b6cc320e8f0f384c30936af.gif]

@martin-ueding
Copy link
Owner

I had an idea about this whole thing: If we do #39, we could have some server process running from the user. Then instead of the hooks trying to regenerate the user's environment, it could tell the user-server to perform the given action (DBus, socket, …). That way, the correct environment would be used.

I have no idea whether this would be an improvement.

@jturner314
Copy link
Contributor

Another advantage to having a daemon is that we could avoid double-executing scripts as sometimes happens with repeated hardware events.

@martin-ueding
Copy link
Owner

Indeed. However, this will require a process to run in the context of the user. Is that really worth it to have a think-daemon running all the time? We are getting away from just having some rotation scripts.

What really bugs me is that I have the KDE screen settings, and it does stuff when I attach screens and so on. But I work with basic xrandr stuff, which ignores all the KDE stuff. Also, KDE has some support for Wacom settings, but we do not use it. Running our own daemon would make it work across DEs and WMs. I am just not sure whether we can justify creating a running program.

I will have time starting from 2014-02-14, unless I fail one of the exams. Then, I should be able to look into D-Bus and whether we could use that with Python.

@martin-ueding
Copy link
Owner

While porting this to Python, I stumpled across sudo -u USER -i COMMAND which lets you run the command, but with an inital login. So this might be something worth a try. You could either try out the python3 branch, which I am currently testing myself. Or you could try the cbpl branch I just created which uses the Bash version, but has the sudo in it. It would be great if you could test that :-)

Get the git repo, then do:

git checkout cbpl
make
sudo make install

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants