Created
February 11, 2023 01:16
-
-
Save stefanwatt/c65a19776f6168b598a7931730ccc3b6 to your computer and use it in GitHub Desktop.
xrandr startup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
import childProcess from "node:child_process"; | |
import { promisify } from "util"; | |
const exec = promisify(childProcess.exec); | |
const {stdout,stderr} = await exec('xrandr') | |
const xrandrLines=stdout.split('\n') | |
const hdmiLine = xrandrLines.find(line => line.includes('HDMI-1')) | |
const isHdmiConnected = !hdmiLine.includes("disconnected") | |
if(isHdmiConnected){ | |
await exec("xrandr --output eDP-1 --off") | |
await exec("xrandr --output eDP1 --off") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment