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

RDP Session doesn't respond to key press. tried both i3 and regolith-session as WM. #1097

Open
2 tasks done
kundeng opened this issue Jan 14, 2025 · 0 comments
Open
2 tasks done
Labels
bug Something isn't working needs-triage Any bug that requires classification by a contributor

Comments

@kundeng
Copy link

kundeng commented Jan 14, 2025

Describe the bug
I followed some instruction and suggestion and here is the script I am using. I am almost there except the RDP session doesn't seem to respond to WIN-XXX keyboard shortcuts.

To Reproduce

#!/bin/bash

# Script to backup and restore RDP configuration for i3 window manager

# Variables
BACKUP_DIR="/etc/xrdp/backup_startwm"
STARTWM_SH="/etc/xrdp/startwm.sh"
XSSESSION="$HOME/.xsession"

# Function to backup original startwm.sh
backup() {
    echo "Backing up original startwm.sh to $BACKUP_DIR/startwm.sh.bak"
    sudo mkdir -p "$BACKUP_DIR"
    sudo cp "$STARTWM_SH" "$BACKUP_DIR/startwm.sh.bak"
    echo "Backup completed."
}

# Function to apply changes to startwm.sh
apply_changes() {
    echo "Creating ~/.xsession with 'i3'"
    echo "regolith-session" > "$XSSESSION"
    chmod +x "$XSSESSION"
    echo "Modifying $STARTWM_SH to enable i3 over RDP"

    sudo cp "$STARTWM_SH" "$BACKUP_DIR/startwm.sh.bak2"

    # Define the original lines to replace
    ORIGINAL_LINE1="test -x /etc/X11/Xsession && exec /etc/X11/Xsession"
    ORIGINAL_LINE2="exec /bin/sh /etc/X11/Xsession"

    # Read the last two lines of startwm.sh
    LAST_TWO_LINES=$(sudo tail -n 2 "$STARTWM_SH")

    # Check if the last two lines match the original lines
    if [ "$LAST_TWO_LINES" == "$ORIGINAL_LINE1
$ORIGINAL_LINE2" ]; then
        echo "Original lines match. Proceeding with replacement."

        # Remove the last two lines
        sudo sed -i '$d' "$STARTWM_SH" # Delete last line
        sudo sed -i '$d' "$STARTWM_SH" # Delete second last line

        # Append the new configuration
        sudo bash -c "cat >> $STARTWM_SH <<EOF
if [ -r ~/.xsession ]; then
    exec /bin/bash --login ~/.xsession
elif command -v regolith-session  >/dev/null 2>&1; then
    exec  regolith-session
else
    exec /etc/X11/Xsession
fi
EOF"

        echo "Changes applied successfully."
    else
        echo "The last two lines of $STARTWM_SH do not match the expected original lines."
        echo "Aborting modification to prevent accidental deletion."
    fi
}

# Function to restore original startwm.sh
restore() {
    if [ -f "$BACKUP_DIR/startwm.sh.bak" ]; then
        echo "Restoring original startwm.sh from backup"
        sudo cp "$BACKUP_DIR/startwm.sh.bak" "$STARTWM_SH"
        echo "Restoration completed."
    else
        echo "Backup file not found. Cannot restore."
    fi
}

# Check for arguments
if [ "$#" -ne 1 ]; then
    echo "Usage: $0 {backup|apply|restore}"
    exit 1
fi

case "$1" in
    backup)
        backup
        ;;
    apply)
        backup
        apply_changes
        ;;
    restore)
        restore
        ;;
    *)
        echo "Invalid option: $1"
        echo "Usage: $0 {backup|apply|restore}"
        exit 1
        ;;
esac
@kundeng kundeng added bug Something isn't working needs-triage Any bug that requires classification by a contributor labels Jan 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs-triage Any bug that requires classification by a contributor
Projects
None yet
Development

No branches or pull requests

1 participant