Skip to content

Instantly share code, notes, and snippets.

@khodges42
Created April 15, 2019 03:07
Show Gist options
  • Save khodges42/cef6197188327cc50ac59eef2086fced to your computer and use it in GitHub Desktop.
Save khodges42/cef6197188327cc50ac59eef2086fced to your computer and use it in GitHub Desktop.
hacky way to switch headphone to speakers in windows. Requires nircmd.exe in the same dir.
import os
try:
os.stat("./.switch")
switcher = 1
os.remove("./.switch")
except:
file = open("./.switch", "w")
switcher = 0
os.system('{} setdefaultsounddevice "{}" 1'.format(os.path.dirname(os.path.realpath(__file__))+"\\"+"nircmd.exe", ['Speakers', 'Headphones'][switcher]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment