This forum has been archived. All content is frozen. Please use KDE Discuss instead.

suspend/resume issues: black screen and mouse cursor

Tags: None
(comma "," separated)
dreamz
Registered Member
Posts
70
Karma
0
OS
i ended up creating a hook for pm-utils. i called it 00togglecompositing and put it in /etc/pm/sleep.d.

Code: Select all
#!/bin/bash
USER=`who | grep ':0' | grep -o '^\w*' | head -n1`
. /home/$USER/.dbus/session-bus/*
case $1 in
   hibernate)
       ;;
   suspend)
       if `sudo -u $USER -i DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS qdbus org.kde.kwin /KWin compositingActive`;
       then
               sudo -u $USER -i DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS qdbus org.kde.kwin /KWin toggleCompositing;
               sleep 1
       fi
       ;;
   thaw)
       ;;
   resume)
               kwin --replace
               sudo -u $USER -i DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS qdbus org.kde.kwin /KWin toggleCompositing;
       ;;
   *)
       ;;
esac


but for some reason, i get these errors:

Code: Select all
/etc/pm/sleep.d/00togglecompositing suspend suspend: Could not connect to D-Bus server: org.freedesktop.DBus.Error.NoServer: Failed to connect to socket /tmp/dbus-x2WQfx6PSQ: Connection refused
success.


and

Code: Select all
/etc/pm/sleep.d/00togglecompositing resume suspend: kwin: cannot connect to X server
Could not connect to D-Bus server: org.freedesktop.DBus.Error.NoServer: Failed to connect to socket /tmp/dbus-x2WQfx6PSQ: Connection refused
Returned exit code 1.
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
You need to set DISPLAY to ":0"

additionally, I would recommend sourcing ~/.dbus/session-bus/* as the user, not as root, for both security and multiple user support.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
dreamz
Registered Member
Posts
70
Karma
0
OS
bcooksley wrote:You need to set DISPLAY to ":0"

can you elaborate? i just copied the code from the arch wiki: http://wiki.archlinux.org/index.php/Pm- ... re_suspend

how do i set it? what does that command do?

additionally, I would recommend sourcing ~/.dbus/session-bus/* as the user, not as root, for both security and multiple user support.

can you explain what you mean here as well?

i was doing some more research, and it seems an alternative approach would be to write a script that accomplishes the same task and link it to powerdevil. this is easier than creating a hook for pm-utils in the sense that pm-utils is outside of x.

what do you think of the alternative approach? is it possible to implement?
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
Add the following scripts:

~/.local/prepare-suspend.sh
Code: Select all
eval 'cat $HOME/.dbus/session-bus/*'
export DISPLAY=:0

if 'qdbus org.kde.kwin /KWin compositingActive` then
        qdbus org.kde.kwin /KWin toggleCompositing
        sleep 2s
fi


~/.local/resume-suspend.sh
Code: Select all
eval 'cat $HOME/.dbus/session-bus/*'
export DISPLAY=:0

qdbus org.kde.kwin /KWin toggleCompositing


Change 00togglecompositing to:
Code: Select all
#!/bin/bash
USER=`who | grep ':0' | grep -o '^\w*' | head -n1`
case $1 in
   hibernate)
       ;;
   suspend)
       sudo -u $USER -i /home/$USER/.local/prepare-suspend.sh
       ;;
   thaw)
       ;;
   resume)
       sudo -u $USER -i /home/$USER/.local/resume-suspend.sh
       ;;
   *)
       ;;
esac


In your script, if KWin had managed to access the display, then it would have started and KWin would have been running as root which is EXTREMELY dangerous.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
dreamz
Registered Member
Posts
70
Karma
0
OS
thank you, bcooksley!

note: there are two minor errors in the first script. first, the quotation mark before 'qdbus' should be a left quotation mark '`'. second, a semicolon is needed before the 'then'.

the fixed script:

Code: Select all
eval 'cat $HOME/.dbus/session-bus/*'
export DISPLAY=:0

if `qdbus org.kde.kwin /KWin compositingActive`; then
        qdbus org.kde.kwin /KWin toggleCompositing
        sleep 2s
fi


seems to work.

also, the second script is problematic on occasion; either the screen goes black when compositing is enabled or everything comes back properly, but some windows are missing borders, etc. to get around this problem, i added 'kwin --replace' after the last line.

interestingly, i get the following error in pm-suspend.log:

Code: Select all
WARNING: Application calling GLX 1.3 function "glXCreatePixmap" when GLX 1.3 is not supported!  This is an application bug!
WARNING: Application calling GLX 1.3 function "glXQueryDrawable" when GLX 1.3 is not supported!  This is an application bug!
WARNING: Application calling GLX 1.3 function "glXDestroyPixmap" when GLX 1.3 is not supported!  This is an application bug!


not sure why. however, thus far, everything appears to be working properly.

i'm going to continue testing this, but the solution is promising.
dreamz
Registered Member
Posts
70
Karma
0
OS
i removed the 'kwin --replace' command and everything works (moreover, no errors). i haven't had a black screen since. i guess i didn't need it after all.

i'm marking this thread as solved. thank you again, bcooksley.
dreamz
Registered Member
Posts
70
Karma
0
OS
sorry to bring this back up, but the fix noted earlier no longer works (at least not consistently).

to get around the problem, i've created a new hook called 00restartkdm with the following code:

Code: Select all
#!/bin/bash
case $1 in
   hibernate)
       ;;
   suspend)
       ;;
   thaw)
       ;;
   resume)
       /etc/rc.d/kdm restart
       ;;
   *)
       ;;
esac


is there anything wrong with this workaround?
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
As far as I am aware, there shouldn't be, assuming it works fine for you with no ill effects ( such as being thrown back to the login screen )


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
dreamz
Registered Member
Posts
70
Karma
0
OS
thanks, bcooksley.

i get the splash screen upon resume, which is expected. i just want to make sure that there are no issues with security or data integrity associated with the workaround.

is there a better way to restart the graphics (x server)?

edit: i noticed this in pm-suspend.log:

Code: Select all
/etc/pm/sleep.d/00restartkdm resume suspend: :: Stopping KDE Desktop Manager    [BUSY]    [DONE]
:: Starting KDE Desktop Manager    [BUSY]    [FAIL]
success.


but kdm (and my desktop) starts properly.
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
There is no issue associated with security, however if it succeeds ( which it seems to not ) then you will likely end up back at the login screen. I do not know of any method to restart the X server as such. Changing to a virtual terminal, then back to X is common to trigger the display to be reconfigured.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
dreamz
Registered Member
Posts
70
Karma
0
OS
i tried switching to a virtual terminal and then back to x with this:

Code: Select all
#!/bin/bash
case $1 in
   hibernate)
       ;;
   suspend)
       chvt 1
       ;;
   thaw)
       ;;
   resume)
       chvt 7
       ;;
   *)
       ;;
esac


but that didn't work. i still ended up with a black screen and a cursor.

i guess i'll just use my 00restartkdm hook for now and see how it works out.
dan2003
Registered Member
Posts
4
Karma
0
Seems to me that this issue is caused not by the gfx driver but by a bug in KDE's lock screen mechanism.

After resume I can seen the screen saver, and the unlock screen dialog (password entry). After this the screen goes black, revealing only the mouse cursor, clicking around and doing things suggest the system is still running , cursor changes to text entry symbol, dragging reveals a document icon under certain situations etc.

As others have noted if an app is open and maximised on suspend the issue does not appear to happen on resume. If no app is open or maximised the problem is apparent.


I marked on my screen the position of the battery icon and suspend button so that I could do this blindly when it messed up - upon resuming again the screen comes back correctly, repeat this several times, the resume cycles alternate between correctly drawn screen and black screen with mouse cursor.

Running pm-suspend in a tty seems to produce different behavouir, the screen always remains black on resume.

I then decided to uncheck the "lock screen on resume" box in the settings, the problem is gone altogether, with the slight problem that the screen is not locked on resume.


Hope this helps somebody.


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Sogou [Bot]