Created
February 11, 2023 01:16
-
-
Save stefanwatt/f5a04aac22e33f8c6c726e466e6944c5 to your computer and use it in GitHub Desktop.
switch resolution
This file contains 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 UWQHD = '3440x1440' | |
const FHD = '1920x1080' | |
const OUTPUT = 'HDMI-1' | |
const exec = promisify(childProcess.exec); | |
const {stdout,stderr} = await exec('xrandr') | |
const xrandrLines=stdout.split('\n') | |
const currentResLine = xrandrLines.find(line => line.includes('*')) | |
const currentRes = currentResLine.trim().split(' ')[0] | |
const newRes = currentRes === UWQHD ? FHD : UWQHD | |
const setResolutionCmd = mode => `xrandr --output ${OUTPUT} --mode ${mode}` | |
await exec(setResolutionCmd(newRes)) | |
await exec("i3-msg reload") | |
await exec("i3-msg restart") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment