Skip to content
TheChatArchiveThe Chat Archive
gpt-4o-mini-2024-07-18· OpenAIAi2 WildChat-4.8M (AI2)

How to get Wayland monitor resolution in Linux?

  1. User

    How to get Wayland monitor resolution in Linux?

  2. Assistant

    To get the monitor resolution in a Wayland session on Linux, you can use various tools or commands that are designed to work with Wayland. Here are a few methods you can try:

    Method 1: Using wlr-randr

    wlr-randr is a utility for Wayland systems similar to xrandr on X11. If it's not installed, you can usually find it in your distribution’s package manager.

    To install it, you might run:

    # On Debian/Ubuntu-based systems
    sudo apt install wlr-randr
    
    # On Arch-based systems
    sudo pacman -S wlr-randr
    
    # On Fedora
    sudo dnf install wlr-randr
    

    After installation, you can use it like this:

    wlr-randr
    

    This command will display the connected monitors along with their resolutions.

    Method 2: Using swaymsg (if using Sway)

    If you are using the Sway window manager, you can use the swaymsg command to query monitor details:

    swaymsg -t get_outputs
    

    This will provide detailed information about connected outputs, including their resolutions.

    Method 3: Using gnome-settings (if using GNOME)

    If you're using a GNOME-based environment under Wayland, you can use dconf or gsettings to get monitor settings:

    gsettings get org.gnome.desktop.interface scaling-factor
    

    However, checking the current resolution specifically is less direct here. You can also check monitor settings through the GNOME display settings GUI.

    Method 4: Using weston-info (if using Weston)

    If you are using the Weston compositor, you can use weston-info to get information about connected monitors:

    weston-info
    

    This will output various details about the compositor, including connected monitors and their resolutions.

    Method 5: Using loginctl for generic outputs

    You can also check if you are using a Wayland session by using:

    loginctl show-session $XDG_SESSION_ID
    

    This command can help confirm if you are running a Wayland session, but it won't give monitor resolutions directly.

    Summary

    The most straightforward method typically involves using wlr-randr or swaymsg if you are working with a Wayland compositor like Sway. If you're using a specific desktop environment like GNOME, the settings manager or the GUI is often the easiest way to check your monitor's resolution settings.