Xfce Forum

Sub domains
 

You are not logged in.

#1 2024-01-01 22:32:59

ziko55kiko
Member
Registered: 2024-01-01
Posts: 1

can't resume from suspend mode

hello guys,

i just installed mint xfce 21.2 few days ago ago and start discovering the features and new apps, and appreciating the lightness.
during this period, i noticed that i can not start my computer from suspended. first, when i suspend the computer from the shut down menu then wake it up, the desktop starts (i hear the hard drive spinning and desktop light turns on) but not the rest (monitor, mouse, keyboard...) and i'm just stuck at my shutted down screen, so i need to restart from the power button and do all my work again.
second, when i leave the computer alone a long period it goes to the screen where i need to log in my password, i type it (that screen is very smooth) then i get a black screen with the mouse that i can freely move (but to where ?). this time i was looking at the forums for a solution, i did alt+ctrl+backspace and it got me back to the login screen where i could type my password again, and this time it got me back to the desktop after a small time of black screen (3s apprx) but, i lost all my work again. it was like it rebooted.

i looked around and posted a topic on mint forums but it couldn't be solved. they suggested me to come here see if it's not an os issue instead of a specific one for me.

can anyone help ? thx

Offline

#2 2024-01-04 00:20:16

JayGursky
Member
Registered: 2023-07-04
Posts: 21

Re: can't resume from suspend mode

I think Linux systems might require some additional steps to make Power management/Suspend and hibernate work. Some info:
https://wiki.archlinux.org/title/Power_ … _hibernate

Offline

#3 2025-04-06 07:02:20

rchfox
Member
Registered: 2024-03-12
Posts: 2
LinuxChrome 135.0

Re: can't resume from suspend mode

SOLVED!

I had a very similar problem. Apparently it's related to XFCE resume/wake up process after suspend or hibernate. In my case only occurred under certain conditions (see below).

I managed to find a good enough solution (see below).

This is my laptop configuration:
- System: ThinkPad P1
- Kernel: 6.11.0-21-generic x86_64
- Distro: Xubuntu 24.04.2 LTS
- Desktop: XFCE 4.18.3
- Display Manager: LightDM 1.30
- Graphics: NVIDIA RTX A1000
- Driver: NVIDIA UNIX x86_64 Kernel Module  550.120

TL;DR

I've found two concurrent problems, and these are their solutions: 

  1. Enabling a custom service "fix-resume" which calls a simple script that executes xrandr with the proper parameters after resume (see below)

  2. XFCE: Window Manager Tweaks -> Compositor -> disable "Display fullscreen overlay windows directly".

THE PROBLEMS

PROBLEM #1

When I trigger suspend or hibernate manually (from XFCE Panel's menu or from command line) everything is OK when my laptop wakes up again: Resuming works like a charm, Lightdm login screen is displayed requesting my credentials to resume my session.

On the other hand, when the laptop suspends or hibernate by closing the lid, on waking up the resume procedure is initiated but the result is a blank display (like powered off).

Anyway, I still can Ctrl+Alt+F1, login in text mode and do normal stuff: ps shows that XFCE related processes are up and running, all my processes restored properly, etc, except by the blank screen instead of the GUI.

PROBLEM #2

This is a concurrent but independent problem. Apparently XFCE's screen locker somehow interferes with the resuming after the laptop suspends or hibernate by closing the lid. I barely understand this issue: Once the laptop resumes the screen locker is kept in foreground waiting for inputs (keyboard, mouse) but its widgets (i.e. login window, top bar, etc.) are not displayed. Somehow the screen locker is there, blocking the screen, but it's not visible at all.

THE SOLUTIONS

Workaround for problem #1:

Create a systemd service that will run a script after resume from suspend or hibernate:

sudo vi /etc/systemd/system/fix-resume.service

This is my service

[Unit]
Description=Run commands after resume from suspend or hibernate
After=suspend.target hibernate.target hybrid-sleep.target

[Service]
ExecStart=/bin/bash /opt/fix-resume/fix-resume-lid-close.sh

[Install]
WantedBy=suspend.target hibernate.target hybrid-sleep.target

Enable the service:

sudo systemctl enable fix-resume.service
sudo systemctl daemon-reload

The script "fix-resume-lid-close.sh" is very simple at its core, it just executes xrandr with the proper parameters after resume:

#!/bin/bash

# Workaround for XFCE blank display after resume from suspend or hibernate 

# Change this to your session type if needed. Xubuntu uses "x11",
# other distros might use "wayland"
readonly TARGET_TYPE="x11"

# Change this to your desktop environment if needed. Xubuntu runs XFCE but 
# goes for the name "xubuntu", other distros might use the label "xfce"
readonly TARGET_DESKTOP="xubuntu"  


# ------------------------------------------------------------------------------
# FUNCTIONS
# ------------------------------------------------------------------------------

get_xfce_display_info() {
    # Retrieves the display resolution and refresh rate
    # from XFCE configuration file for a given user

    local user="$1"
    local config_file="/home/$user/.config/xfce4/xfconf/xfce-perchannel-xml/displays.xml"

    local resolution rate
    resolution=$(xmllint --xpath 'string(//property[@name="Active"]/../property[@name="Resolution"]/@value)' "$config_file")
    rate=$(xmllint --xpath 'string(//property[@name="Active"]/../property[@name="RefreshRate"]/@value)' "$config_file")

    # Returns the resolution and refresh rate 
    printf "%s %.2f\n" "$resolution" "$rate"
}


get_mode_name() {
    # Finds the mode name for a given resolution and refresh rate
    # from the output of the `xrandr --query` command

    local resolution="$1"
    local refreshrate="$2"
    local xrandr_qresult="$3"
    local pattern="^\s+${resolution}\s+${refreshrate}\s*"
    local mode_name=$(egrep "$pattern" <<< "$xrandr_qresult" | awk '{print $1; exit}')

    # Returns the mode name 
    echo "$mode_name"
}



# ------------------------------------------------------------------------------
# MAIN
# ------------------------------------------------------------------------------

declare -A session_data

# iterate over all sessions
for session in $(loginctl list-sessions --no-legend | awk '{print $1}'); do
    # Clear previous data
    session_data=()

    # Load current session data
    while IFS='=' read -r key value; do
        session_data["$key"]="$value"
    done < <(loginctl show-session "$session")

    id=${session_data[Id]}
    type=${session_data[Type]}
    desktop=${session_data[Desktop]}
    display=${session_data[Display]}
    username=${session_data[Name]}

    # Process only the sessions that match the target type and desktop
    if [[ "${type}" == "${TARGET_TYPE}" && "${desktop}" == "${TARGET_DESKTOP}" && -n "$display" ]]; then
        
        logger -it fix-resume "Session data: Id=${id}, Desktop=${desktop}, Display=${display}, username=${username}"

        xauth_file=/home/${username}/.Xauthority
        
        # Check if the XAUTHORITY file exists, dont't mess with weird stuff
        if [[ ! -f "$xauth_file" ]]; then
            logger -it fix-resume "XAUTHORITY file not found for user ${username}. Skipping..."
            continue
        fi
        if [[ -f "$xauth_file" ]]; then

            # Capture the output of xrandr --query
            xrandr_qresult=$(DISPLAY=${display} XAUTHORITY=/home/${username}/.Xauthority xrandr --query) 

            # Detect the primary connected outout device name
            output_device=$(echo "${xrandr_qresult}" | awk '/ connected primary/{print $1}')
            if [[ -z "$output_device" ]]; then
                # If no primary output device is found, get the first connected device
                output_device=$(echo "${xrandr_qresult}" | awk '/ connected/{print $1; exit}')

                if [[ -z "$output_device" ]]; then
                    # If no connected device is found, skip this session
                    logger -it fix-resume "No connected output device found for user ${username}. Skipping..."
                    continue
                fi
            fi

            # Get resolution refreshrate from user's current XFCE configuration
            read resolution refreshrate <<< $(get_xfce_display_info "${username}")
            
            # Get de mode name of the connected output device 
            mode_name=$(get_mode_name "$resolution" "$refreshrate" "$xrandr_qresult")
            if [[ -z "$mode_name" ]]; then
                logger -it fix-resume "No mode name found for resolution ${resolution} and refreshrate ${refreshrate}. Skipping..."
                continue
            fi

            # Prepare the xrandr command to set the mode appropriate line  
            xrandr_set_mode_command="DISPLAY=${display} XAUTHORITY=${xauth_file} xrandr --output ${output_device} --mode ${mode_name}"

            logger -it fix-resume "Executing: su \"${username}\" -c \"${xrandr_set_mode_command}\""

            # Execute randr as the user to set the appropriate mode
            su "${username}" -c "${xrandr_set_mode_command}"
            if [[ $? -ne 0 ]]; then
                logger -it fix-resume "Failed to set mode for user ${username}. Skipping..."
                continue
            fi
        fi
    fi
	
done

exit

Workaround for problem #2:

Open XFCE Settings:
Window Manager Tweaks -> Compositor -> disable "Display fullscreen overlay windows directly".

I don't know why or how, but disabling fullscreen overlay windows directly solved the "invisibility problem" of the screen locker.

Offline

#4 2025-04-06 07:25:56

burgess_m
Member
Registered: 2025-03-10
Posts: 4
UbuntuFirefox 136.0

Re: can't resume from suspend mode

Thank you @rchfox - your workaround #2 has solved a suspend problem for me in Xubuntu 24.10.

Offline

#5 2025-05-29 17:00:12

kagi3624
Member
Registered: 2020-04-08
Posts: 1
LinuxChrome 136.0

Re: can't resume from suspend mode

rchfox wrote:
#!/bin/bash

# Workaround for XFCE blank display after resume from suspend or hibernate 

# Change this to your session type if needed. Xubuntu uses "x11",
# other distros might use "wayland"
readonly TARGET_TYPE="x11"

# Change this to your desktop environment if needed. Xubuntu runs XFCE but 
# goes for the name "xubuntu", other distros might use the label "xfce"
readonly TARGET_DESKTOP="xubuntu"  


# ------------------------------------------------------------------------------
# FUNCTIONS
# ------------------------------------------------------------------------------

get_xfce_display_info() {
    # Retrieves the display resolution and refresh rate
    # from XFCE configuration file for a given user

    local user="$1"
    local config_file="/home/$user/.config/xfce4/xfconf/xfce-perchannel-xml/displays.xml"

    local resolution rate
    resolution=$(xmllint --xpath 'string(//property[@name="Active"]/../property[@name="Resolution"]/@value)' "$config_file")
    rate=$(xmllint --xpath 'string(//property[@name="Active"]/../property[@name="RefreshRate"]/@value)' "$config_file")

    # Returns the resolution and refresh rate 
    printf "%s %.2f\n" "$resolution" "$rate"
}


get_mode_name() {
    # Finds the mode name for a given resolution and refresh rate
    # from the output of the `xrandr --query` command

    local resolution="$1"
    local refreshrate="$2"
    local xrandr_qresult="$3"
    local pattern="^\s+${resolution}\s+${refreshrate}\s*"
    local mode_name=$(egrep "$pattern" <<< "$xrandr_qresult" | awk '{print $1; exit}')

    # Returns the mode name 
    echo "$mode_name"
}



# ------------------------------------------------------------------------------
# MAIN
# ------------------------------------------------------------------------------

declare -A session_data

# iterate over all sessions
for session in $(loginctl list-sessions --no-legend | awk '{print $1}'); do
    # Clear previous data
    session_data=()

    # Load current session data
    while IFS='=' read -r key value; do
        session_data["$key"]="$value"
    done < <(loginctl show-session "$session")

    id=${session_data[Id]}
    type=${session_data[Type]}
    desktop=${session_data[Desktop]}
    display=${session_data[Display]}
    username=${session_data[Name]}

    # Process only the sessions that match the target type and desktop
    if [[ "${type}" == "${TARGET_TYPE}" && "${desktop}" == "${TARGET_DESKTOP}" && -n "$display" ]]; then
        
        logger -it fix-resume "Session data: Id=${id}, Desktop=${desktop}, Display=${display}, username=${username}"

        xauth_file=/home/${username}/.Xauthority
        
        # Check if the XAUTHORITY file exists, dont't mess with weird stuff
        if [[ ! -f "$xauth_file" ]]; then
            logger -it fix-resume "XAUTHORITY file not found for user ${username}. Skipping..."
            continue
        fi
        if [[ -f "$xauth_file" ]]; then

            # Capture the output of xrandr --query
            xrandr_qresult=$(DISPLAY=${display} XAUTHORITY=/home/${username}/.Xauthority xrandr --query) 

            # Detect the primary connected outout device name
            output_device=$(echo "${xrandr_qresult}" | awk '/ connected primary/{print $1}')
            if [[ -z "$output_device" ]]; then
                # If no primary output device is found, get the first connected device
                output_device=$(echo "${xrandr_qresult}" | awk '/ connected/{print $1; exit}')

                if [[ -z "$output_device" ]]; then
                    # If no connected device is found, skip this session
                    logger -it fix-resume "No connected output device found for user ${username}. Skipping..."
                    continue
                fi
            fi

            # Get resolution refreshrate from user's current XFCE configuration
            read resolution refreshrate <<< $(get_xfce_display_info "${username}")
            
            # Get de mode name of the connected output device 
            mode_name=$(get_mode_name "$resolution" "$refreshrate" "$xrandr_qresult")
            if [[ -z "$mode_name" ]]; then
                logger -it fix-resume "No mode name found for resolution ${resolution} and refreshrate ${refreshrate}. Skipping..."
                continue
            fi

            # Prepare the xrandr command to set the mode appropriate line  
            xrandr_set_mode_command="DISPLAY=${display} XAUTHORITY=${xauth_file} xrandr --output ${output_device} --mode ${mode_name}"

            logger -it fix-resume "Executing: su \"${username}\" -c \"${xrandr_set_mode_command}\""

            # Execute randr as the user to set the appropriate mode
            su "${username}" -c "${xrandr_set_mode_command}"
            if [[ $? -ne 0 ]]; then
                logger -it fix-resume "Failed to set mode for user ${username}. Skipping..."
                continue
            fi
        fi
    fi
	
done

exit


How to fix the scrip for my Desktop with two Screens? It seems to get the resolution from the second screen. Not the primary one.

 kagi fix-resume[21213]: Executing: su "kagi" -c "DISPLAY=:0 XAUTHORITY=/home/kagi/.Xauthority xrandr --output DP-0 --mode 1920x1080" 
Screen 0: minimum 8 x 8, current 4480 x 1440, maximum 32767 x 32767
HDMI-0 connected 1920x1080+2560+360 (normal left inverted right x axis y axis) 510mm x 290mm
   1920x1080     60.00*+  59.94    50.00  
   1680x1050     59.95  
   1600x900      60.00  
   1440x900      59.89  
   1400x1050     59.98  
   1280x1024     60.02  
   1280x800      59.81  
   1280x720      60.00    59.94    50.00  
   1152x864      60.00  
   1024x768      60.00  
   800x600       60.32  
   720x576       50.00  
   720x480       59.94  
   640x480       59.94    59.93  
DP-0 connected primary 2560x1440+0+0 (normal left inverted right x axis y axis) 700mm x 390mm
   2560x1440    164.96*+ 143.97   120.00    99.95    59.95  
   1920x1080    119.88   100.00    60.00    59.94    50.00  
   1280x720      59.94    50.00  
   1024x768      60.00  
   800x600       60.32  
   720x480       59.94  
   640x480       59.94    59.93  

Offline

Registered users online in this topic: 0, guests: 1
[Bot] ClaudeBot

Board footer

Powered by FluxBB
Modified by Visman

[ Generated in 0.009 seconds, 7 queries executed - Memory usage: 598.23 KiB (Peak: 615.51 KiB) ]