Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion turn-off-monitors
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
function turn-off-screen-in-wayland()
{
echo "Turning off monitors..."
if [[ $XDG_SESSION_DESKTOP == gnome* ]]; then
if [[ $XDG_SESSION_DESKTOP == gnome* || $MUTTER_PROPERTY_SUPPORTED ]]; then

Choose a reason for hiding this comment

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

high

To align with the suggested fix and shell scripting best practices, this variable should be updated to its new lowercase name. This change is necessary for the new GNOME detection logic to function correctly.

    if [[ $XDG_SESSION_DESKTOP == gnome* || $mutter_property_supported ]]; then

_trigger-monitors-off-in-gnome-wayland

local interaction_event=$(wait_until_mouse_or_keyboard_event)
Expand Down Expand Up @@ -89,6 +89,13 @@ function wait_until_mouse_or_keyboard_event()
}
### END framework/wait_until_mouse_or_keyboard_event.sh

# C
if busctl --user get-property org.gnome.Mutter.DisplayConfig \
/org/gnome/Mutter/DisplayConfig org.gnome.Mutter.DisplayConfig \
PowerSaveMode &>/dev/null; then
MUTTER_PROPERTY_SUPPORTED=true
fi
Comment on lines +92 to +97

Choose a reason for hiding this comment

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

critical

There's a critical issue in the busctl command. The object path and interface are being passed as a single argument because of a missing line continuation (\). This will likely cause the check to always fail, preventing the new detection mechanism from working.

I've included a fix in the suggestion below, and also took the opportunity to make a few other improvements for maintainability:

  • The comment # C is not descriptive. I've replaced it with one that explains the purpose of the check.
  • It's good practice to initialize variables. I've initialized mutter_property_supported to false for clarity and robustness.
  • Shell script convention is to use lowercase for script-local variables to avoid conflicts with environment variables. I've renamed MUTTER_PROPERTY_SUPPORTED to mutter_property_supported.
# Check if Mutter's PowerSaveMode property is available (for GNOME 48+).
mutter_property_supported=false
if busctl --user get-property \
    org.gnome.Mutter.DisplayConfig \
    /org/gnome/Mutter/DisplayConfig \
    org.gnome.Mutter.DisplayConfig \
    PowerSaveMode &>/dev/null; then
    mutter_property_supported=true
fi

Copy link
Author

Choose a reason for hiding this comment

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

I don't get the bot's suggestion, this was previously tested and worked just fine :-)


if [ "$XDG_SESSION_TYPE" == "wayland" ]; then
turn-off-screen-in-wayland
else
Expand Down