Update turn-off-monitors for Ubuntu 26.04 - #20
Conversation
add || $XDG_SESSION_DESKTOP == ubuntu*
|
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).
|
| { | ||
| echo "Turning off monitors..." | ||
| if [[ $XDG_SESSION_DESKTOP == gnome* ]]; then | ||
| if [[ $XDG_SESSION_DESKTOP == gnome* || $XDG_SESSION_DESKTOP == ubuntu* ]]; then |
There was a problem hiding this comment.
[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
}|
Reviewed up to commit:7fa78c92e0e84479388a2788c3847b9fb1191aca Additional Suggestionturn-off-monitors, line:29-31The 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 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 |
In Ubuntu 26.04 Gnome :
XDG_SESSION_DESKTOP=ubuntu