Skip to content

Instantly share code, notes, and snippets.

@stefanwatt
Created February 11, 2023 01:16
Show Gist options
  • Save stefanwatt/c65a19776f6168b598a7931730ccc3b6 to your computer and use it in GitHub Desktop.
Save stefanwatt/c65a19776f6168b598a7931730ccc3b6 to your computer and use it in GitHub Desktop.
xrandr startup
#!/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