Skip to content

Instantly share code, notes, and snippets.

@guibou
Created April 8, 2021 11:48
Show Gist options
  • Select an option

  • Save guibou/ed5a21238353d9e6e8410ab542b4ae80 to your computer and use it in GitHub Desktop.

Select an option

Save guibou/ed5a21238353d9e6e8410ab542b4ae80 to your computer and use it in GitHub Desktop.
This runs my xephyr windows for OBS and ensure that window manager and interesting tools are started
import subprocess
import time
import sys
import os
# Start xephyr
xephyr = subprocess.Popen(
"Xephyr -br -ac -noreset -screen 1920x1080 -dpi 300 :1".split()
)
os.environ["DISPLAY"] = ":1"
i3 = subprocess.Popen(["i3"])
# Wait for i3 launch
time.sleep(1)
# Hide i3 bar
subprocess.run("i3 bar mode invisible".split())
# Runs the following background commands to populate
cmds = ["nix run nixpkgs.firefox -c firefox https://github.com/guibou/streamray",
"alacritty",
"nix run nixpkgs.xournal -c xournal"]
ps = [subprocess.Popen(cmd.split()) for cmd in cmds]
# move windows to their right place
subprocess.run("i3 move container to workspace 3".split())
subprocess.run("i3 move container to workspace 2".split())
os.environ["DISPLAY"] = ":0"
# Change the resolution
subprocess.run("xrandr -s 1920x1080".split())
try:
i3.wait()
except KeyboardInterrupt:
pass
for i in [i3, xephyr] + ps:
i.kill()
# Restore resolution
subprocess.run("xrandr -s 3840x2160".split())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment