Skip to content

Update turn-off-monitors for Ubuntu 26.04 - #20

Open
laugeo2 wants to merge 1 commit into
hopeseekr:trunkfrom
laugeo2:patch-1
Open

Update turn-off-monitors for Ubuntu 26.04#20
laugeo2 wants to merge 1 commit into
hopeseekr:trunkfrom
laugeo2:patch-1

Conversation

@laugeo2

@laugeo2 laugeo2 commented Aug 2, 2026

Copy link
Copy Markdown

In Ubuntu 26.04 Gnome :
XDG_SESSION_DESKTOP=ubuntu

add
 || $XDG_SESSION_DESKTOP == ubuntu*
@pantoaibot

pantoaibot Bot commented Aug 2, 2026

Copy link
Copy Markdown

PR Summary:

Treat Ubuntu's "ubuntu" session as GNOME Wayland: the script now matches XDG_SESSION_DESKTOP == ubuntu* and routes it to the GNOME Wayland handlers (for Ubuntu 26.04).

  • Changed condition in turn-off-screen-in-wayland to: if [[ $XDG_SESSION_DESKTOP == gnome* || $XDG_SESSION_DESKTOP == ubuntu* ]].
  • Intent: Ubuntu 26.04 uses "ubuntu" as the session identifier; this ensures the GNOME Wayland path (_trigger-monitors-off/on-in-gnome-wayland) is used.
  • Functional effect: No change to how monitors are toggled (still uses busctl PowerSaveMode for GNOME and kscreen-doctor for KDE).
  • No dependency updates, no breaking changes; error handling for unsupported desktops remains.

Reviewed by Panto AI

Comment thread turn-off-monitors
{
echo "Turning off monitors..."
if [[ $XDG_SESSION_DESKTOP == gnome* ]]; then
if [[ $XDG_SESSION_DESKTOP == gnome* || $XDG_SESSION_DESKTOP == ubuntu* ]]; then

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[VALIDATION] The new condition adds matching for 'ubuntu*' which is good for Ubuntu 26.04, but relying solely on XDG_SESSION_DESKTOP is brittle (values vary: 'ubuntu', 'GNOME', 'ubuntu:GNOME', etc.). Normalize and check both XDG_SESSION_DESKTOP and XDG_CURRENT_DESKTOP case-insensitively so you catch variants. Example approach to replace the single if-line:

desktop="${XDG_SESSION_DESKTOP:-${XDG_CURRENT_DESKTOP:-}}"
desktop_lc=$(printf '%s' "$desktop" | tr '[:upper:]' '[:lower:]')
if [[ "$desktop_lc" == gnome* || "$desktop_lc" == gnome || "$desktop_lc" == ubuntu* ]]; then
...
fi

This handles values like 'Ubuntu:GNOME', 'gnome', 'ubuntu' and avoids false negatives.

function turn-off-screen-in-wayland()
{
    echo "Turning off monitors..."

    local desktop
    desktop="${XDG_SESSION_DESKTOP:-${XDG_CURRENT_DESKTOP:-}}"
    local desktop_lc
    desktop_lc=$(printf '%s' "$desktop" | tr '[:upper:]' '[:lower:]')

    if [[ "$desktop_lc" == gnome* || "$desktop_lc" == *gnome* || "$desktop_lc" == ubuntu* ]]; then
        _trigger-monitors-off-in-gnome-wayland

        local interaction_event
        interaction_event=$(wait_until_mouse_or_keyboard_event)
        echo "Event Type: ${interaction_event}"

        echo "Turning monitors back on..."
        _trigger-monitors-on-in-gnome-wayland

    elif [[ "$desktop_lc" == *plasma* || "$desktop_lc" == *kde* ]]; then
        _trigger-monitors-off-in-kde-wayland
    else
        echo "ERROR: Unsupported Wayland Desktop Environment: $desktop"
        exit 2
    fi
}

@pantoaibot

pantoaibot Bot commented Aug 2, 2026

Copy link
Copy Markdown

Reviewed up to commit:7fa78c92e0e84479388a2788c3847b9fb1191aca

Additional Suggestion
turn-off-monitors, line:29-31 The KDE/plasma branch uses exact string comparisons ("plasma" or "KDE"); keep matching logic consistent and case-insensitive by using the same normalized variable as suggested above. For example:

elif [[ "$desktop_lc" == plasma || "$desktop_lc" == kde ]]; then
_trigger-monitors-off-in-kde-wayland

This reduces missed matches for variants like 'Plasma', 'kde', or 'KDE'.

    local desktop
    desktop="${XDG_SESSION_DESKTOP:-${XDG_CURRENT_DESKTOP:-}}"
    local desktop_lc
    desktop_lc=$(printf '%s' "$desktop" | tr '[:upper:]' '[:lower:]')

    if [[ "$desktop_lc" == gnome* || "$desktop_lc" == *gnome* || "$desktop_lc" == ubuntu* ]]; then
        _trigger-monitors-off-in-gnome-wayland
        # ...
    elif [[ "$desktop_lc" == *plasma* || "$desktop_lc" == *kde* ]]; then
        _trigger-monitors-off-in-kde-wayland
    else
        echo "ERROR: Unsupported Wayland Desktop Environment: $desktop"
        exit 2
    fi

Reviewed by Panto AI

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant