10

cross-posted from: https://lemmy.world/post/48010802

I created a simple Nushell script that will always disable the default/internal monitor(s) on your laptop or external display when using AR glasses. I find this useful for when using AR glasses such as the XReal One which allows you to change the mode from regular mode to ultra-wide mode and when doing this, it will act as your unplugging the XReal ones and plugging in XReal one again in a new mode, causing the other display to become enabled.

To keep the laptop display always off, weather the laptop lid is either closed or open, this simple Nushell script will always disable the screen every X seconds (You can change it by changing the wait constant)

Simply copy this script and create a new Nushell script such as disable-displays.nu, add it to your startup applications with the command of nu /path/to/disable-displays.nu and it will run in the background. You will need to run xrandr command with all of your displays enabled to get the names of the displays and change the constants values in the script accordingly.

NOTE: This script may not work with a full Wayland setup and may only work on X11.

Enjoy

# RUN xrandr TO GET THE NAMES OF THE DISPLAYS AND SET THE VARIABLES TO THESE NAMES
const ar_glasses_display = 'USB-C-0'
const displays = [
    'eDP',
    'HDMI-0'
]

const wait = 5

def is-ar-glasses-connected [] {
    return (xrandr | str contains $"($ar_glasses_display) connected")
}

def disable-display [display: string] {
    xrandr --output $display --off
}

def enable-display [display: string] {
    xrandr --output $display --auto
}

loop {
    if (is-ar-glasses-connected) {
        for current_display in $displays {
            disable-display $current_display
        }
    } else {
        for current_display in $displays {
            enable-display $current_display
        }
    }

    sleep ($wait * 1sec)
}
no comments (yet)
sorted by: hot top new old
there doesn't seem to be anything here
this post was submitted on 10 Jun 2026
10 points (100.0% liked)

Linux

17769 readers
55 users here now

Welcome to c/linux!

Welcome to our thriving Linux community! Whether you're a seasoned Linux enthusiast or just starting your journey, we're excited to have you here. Explore, learn, and collaborate with like-minded individuals who share a passion for open-source software and the endless possibilities it offers. Together, let's dive into the world of Linux and embrace the power of freedom, customization, and innovation. Enjoy your stay and feel free to join the vibrant discussions that await you!

Rules:

  1. Stay on topic: Posts and discussions should be related to Linux, open source software, and related technologies.

  2. Be respectful: Treat fellow community members with respect and courtesy.

  3. Quality over quantity: Share informative and thought-provoking content.

  4. No spam or self-promotion: Avoid excessive self-promotion or spamming.

  5. No NSFW adult content

  6. Follow general lemmy guidelines.

founded 3 years ago
MODERATORS