Jump to content

Steam

From SameTeem
Revision as of 15:33, 3 May 2026 by Admin (talk | contribs)

Steam Chat Window Doesn’t Show When a Message Is Received

Make a new user systemd unit. Replace /home/user/ with your username.

mkdir -p $HOME/.config/systemd/user/
nano $HOME/.config/systemd/user/fixsteamchat.service
[Unit]
Description=Steam Chat Window Fixer
After=graphical-session.target
PartOf=graphical-session.target

[Service]
Type=simple
ExecStart=/home/user/fixsteamchat.sh
Restart=on-failure
RestartSec=5

[Install]
WantedBy=graphical-session.target

Make the actual script to show the chat window.

nano $HOME/fixsteamchat.sh
#!/bin/bash

# 1 = Bring new chat window front even if some window is full-screen
BRING_TO_FRONT_WHEN_FULLSCREEN=0

# Don't bring the chat window front if one of these programs is running
PROGRAM_BLOCKLIST=("first-program" "another-program")


is_any_window_fullscreen() {
    local window_ids
    window_ids=$(xprop -root _NET_CLIENT_LIST | grep -o '0x[0-9a-fA-F]\+')

    for win_id in $window_ids; do
        local state
        state=$(xprop -id "$win_id" _NET_WM_STATE 2>/dev/null)
        if [[ $state == *"_NET_WM_STATE_FULLSCREEN"* ]]; then
            return 0
        fi
    done

    return 1
}

is_program_running() {
    local program="$1"
    if pgrep -x "$program" >/dev/null 2>&1; then
        return 0
    else
        return 1
    fi
}

is_any_program_running() {
    local programs=("$@")

    for program in "${programs[@]}"; do
        if is_program_running "$program"; then
            return 0
        fi
    done

    return 1
}

map_window() {
    local window_id="$1"
    xdotool windowmap --sync "$window_id" >/dev/null 2>&1
}

bring_to_front() {
    local window_id="$1"

    if is_any_program_running "${PROGRAM_BLOCKLIST[@]}"; then
        echo "A blocklisted program is running. Keeping chat window minimized"
        return 1
    fi

    if [[ "$BRING_TO_FRONT_WHEN_FULLSCREEN" == "0" ]]; then
        if is_any_window_fullscreen; then
            echo "Another program is full-screen. Keeping chat window minimized"
            return 1
        fi
    fi

    xdotool windowactivate "$window_id" >/dev/null 2>&1
}


if ! command -v xdotool &>/dev/null; then
    echo "Error: xdotool is not installed. Please install it first: sudo apt install xdotool"
    exit 1
fi

if ! command -v xprop &>/dev/null; then
    echo "Error: xprop is not installed. Please install it first: sudo apt install xprop"
    exit 1
fi

LOG_FILE="$HOME/.steam/steam/logs/webhelper.txt"
touch "$LOG_FILE"
echo "Listening to $LOG_FILE"

tail -f "$LOG_FILE" | while read -r line; do
    if [[ $line =~ ChatWindow_ && $line =~ System\ window:\ (0x[0-9a-fA-F]+) ]]; then
        window_id="${BASH_REMATCH[1]}"

        echo "New chat window: $window_id"

        map_window "$window_id"
        bring_to_front "$window_id"
    fi
done

Reload the service list and start is.

systemctl --user daemon-reload
systemctl --user enable fixsteamchat --now